Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

JMS Fundamentals

The JMS specification defines both PTP and pub/sub APIs. A JMS Server can implement one or both of these APIs. The WebLogic Server's JMS implementation includes both the PTP and pub/sub APIs.

The JMS APIs define a set of fundamental objects. Each object is separately defined in the PTP and pub/sub domains, but their function is nearly identical in both domains.

Connection Factories

Connection factories are created by the server administrator and bound into the Java Naming and Directory Interface (JNDI) tree. A JMS client uses JNDI to look up the ConnectionFactory and then uses the ConnectionFactory to establish a JMS connection. The PTP connection factory is javax.jms.QueueConnectionFactory while the pub/sub domain uses javax.jms.TopicConnectionFactory.

The WebLogic Server binds a standard connection factory with the name weblogic.jms.ConnectionFactory. It also is possible to define additional connection factories with the WebLogic Server's Administration Console. An application uses a user-defined ConnectionFactory if needed to impose additional security constraints on the ConnectionFactory.

Connections

A JMS connection represents the active connection between the JMS client and the WebLogic Server. The JMS client creates the JMS connection by calling the createQueueConnection or the createTopicConnection methods on the ConnectionFactory. A JMS connection is a relatively heavyweight object and normally each client uses a single JMS connection. Each JMS connection can be associated with many JMS destinations. The PTP connection is javax.jms.QueueConnection while the pub/sub connection is javax.jms.TopicConnection.

Sessions

The JMS session represents a client's conversational state with a JMS Server. A session is created from the JMS connection, and it represents a single thread of conversation between a JMS client and server. Sessions define message ordering, and JMS uses sessions for transactional messaging. The PTP model uses javax.jms.QueueSession while the pub/sub model uses javax.jms.TopicSession.

Destinations

JMS destinations are the actual messaging resource. PTP messaging defines javax.jms.Queue while pub/sub includes javax.jms.Topic. The server administrator uses the WebLogic Console to create destinations with a specified JNDI name. The JMS client then performs a JNDI lookup to locate the JMS destination.

Table 7.1 compares the terminology for PTP and pub/sub APIs.

Table 7.1 Comparing PTP and Pub/Sub APIs

 

PTP

Pub/Sub

Connection Factory

QueueConnectionFactory

TopicConnectionFactory

Connection

QueueConnection

TopicConnection

Session

QueueSession

TopicSession

Destination

Queue

Topic


  • + Share This
  • 🔖 Save To Your Account