ActiveMQ Artemis upgrade question: HornetQ to Artemis 2.0

315 Views Asked by At

I have been upgrading an old HornetQ project to Artemis and I ran into some issues with the JMSServerControl. My original code looked like this.

final ObjectName on = ObjectNameBuilder.DEFAULT.getJMSServerObjectName();
final JMSServerControl sControl = jmxConnectorFactory.newProxyInstance( mbsc, on, JMSServerControl.class, false );
final boolean success = sControl.createQueue( canonicalName, jndiBinding );

I actually upgraded to ActiveMQ Artemis 1.3 first where this code still works. I am planning on going to 2.15.0 eventually, but I just wasn't sure what other things may have been deprecated so I took a smaller jump to 2.0. The above code broke when I moved to 2.0 so I am using the following.

final ObjectName on = ObjectNameBuilder.DEFAULT.getActiveMQServerObjectName();
final ActiveMQServerControl sControl = jmxConnectorFactory.newProxyInstance( mbsc, on, ActiveMQServerControl.class, false );
...

Now createQueue has been deprecated. Any suggestion of what I could use instead to get the same behavior?

1

There are 1 best solutions below

2
On BEST ANSWER

You should use one of the non-deprecated createQueue methods, i.e.:

  • org.apache.activemq.artemis.core.management.impl.ActiveMQServerControlImpl#createQueue(java.lang.String)
  • org.apache.activemq.artemis.core.management.impl.ActiveMQServerControlImpl#createQueue(java.lang.String, boolean)

For example:

final ObjectName on = ObjectNameBuilder.DEFAULT.getActiveMQServerObjectName();
final ActiveMQServerControl sControl = jmxConnectorFactory.newProxyInstance( mbsc, on, ActiveMQServerControl.class, false );
sControl.createQueue(new QueueConfiguration(canonicalName).setRoutingType(RoutingType.ANYCAST).toJSON());

This code will create a core queue and a core address with the same name (i.e. canonicalName) using the ANYCAST routing-type. This will provide the semantics equivalent to a JMS queue. I recommend you read the chapter from the documentation about JMS-to-core mapping. That will help you understand more about what configuration you need for the core resources to get the semantics you want for your JMS clients.