Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMS QueueConnectionFactory vs ConnectionFactory

Tags:

java

jms

jndi

mq

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.

like image 751
bvdb Avatar asked May 08 '15 10:05

bvdb


People also ask

What is ConnectionFactory in JMS?

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).

What is JMS and JNDI?

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.


1 Answers

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

like image 173
Evgeniy Dorofeev Avatar answered Sep 20 '22 22:09

Evgeniy Dorofeev