My question is about the use of the following 2 factories:
At the moment I just use a ConnectionFactory
to initialize everything:
Connection conn = factory.createConnection(user, pw);
Session session = conn.createSession()
Destination dest = session.createQueue('xyz')
...
If I understand correctly, the QueueConnectionFactory
works pretty much the same way. Is it the exact same thing ?
I am wondering especially because I'm using a JNDI context which contains both objects. So, I'm not sure which one I should prefer to use.
A connection factory is an object that a JMS client (a JMS program that uses the JMS API) uses to create a connection with a JNDI provider (a messaging provider such as IBM® MQ).
The Java™ Naming and Directory Interface (JNDI) API enables JMS clients to look up configured JMS objects. By delegating all the provider-specific work to administrative tasks for creating and configuring these objects, the clients can be completely portable between environments.
javax.jms package API says:
For historical reasons JMS offers four alternative sets of interfaces for sending and receiving messages:
•JMS 1.0 defined two domain-specific APIs, one for point-to-point messaging (queues) and one for pub/sub (topics). Although these remain part of JMS for reasons of backwards compatibility they should be considered to be completely superseded by the later APIs.
•JMS 1.1 introduced a new unified API which offered a single set of interfaces that could be used for both point-to-point and pub/sub messaging. This is referred to here as the classic API.
•JMS 2.0 introduces a simplified API which offers all the features of the classic API but which requires fewer interfaces and is simpler to use.
Each API offers a different set of interfaces for connecting to a JMS provider and for sending and receiving messages. However they all share a common set of interfaces for representing messages and message destinations and to provide various utility features.
In other words QueueConnectionFactory is simply a legacy interface
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With