简体   繁体   中英

JMS QueueConnectionFactory vs ConnectionFactory

My question is about the use of the following 2 factories:

  • ConnectionFactory
  • QueueConnectionFactory

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM