Reputation:
ActiveMQ Classic 5.15.3 does not support the JMS 2.0 API. Most developers suggest projects use ActiveMQ Artemis if they want JMS 2.0 client support. Can an ActiveMQ Artemis client connect to an ActiveMQ Classic broker?
Upvotes: 2
Views: 2288
Reputation: 18411
No, the Artemis JMS client uses the Artemis Core protocol which the ActiveMQ 5.x broker does not understand so you cannot connect to it with that client. Even if you could that wouldn't enable any JMS 2.0 features as the broker needs to support the 2.0 features like shared subscriptions etc.
Depending on what you are trying to do there's a good chance you can still do it with the ActiveMQ JMS client over JMS 1.1 APIs such as using Virtual Topics to implement shared style subscription behaviors.
The Artemis Broker does understand the OpenWire protocol so you can use the same ActiveMQ 5.x JMS client to connect to both however that client is limited to the JMS 1.1 API.
Both brokers also support AMQP 1.0 so the Qpid JMS AMQP 1.0 client would be able to talk to either broker. Qpid-JMS is a JMS 2.0 based client so the features of 2.0 like shared subscriptions wouldn't work against ActiveMQ 5.x but some of the other syntactic sugar type APIs of 2.0 like JMSContext based bits would mostly work.
Upvotes: 4
Reputation: 22279
As Tim states, the Artemis client is not supported. However, at least some parts* of the JMS 2.0 API works if you are using the QPid client and the AMQP 1.0 protocol instead.
The following code, for instance, works to put a message to ActiveMQ 5.15
Hashtable<String,Object> properties = new Hashtable<>();
properties.put("connectionfactory.connectionFactory","amqp://localhost:5672");
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
Context jndiContext = new InitialContext(properties);
ConnectionFactory connectionFactory
= (ConnectionFactory) jndiContext.lookup("connectionFactory");
try (JMSContext context = connectionFactory.createContext();) {
context.createProducer().send(context.createQueue("QueueX"),"Hello World" );
}
Using qpid-jms-client 0.29.
You also need to configure the amqp connector i ActiveMQ with transport.transformer=jms
.
*) I have not tried all features such as shared subscribers etc as the broker may or may not have trouble with these.
Upvotes: 1