MessageProducer and MessageConsumer Understanding the JMS API

2-14 Programming JMS for Oracle WebLogic Server has its own JNDI name. The members of the set are typically distributed across multiple servers within a cluster, with each member belonging to a separate JMS server. Applications that use a distributed destination are more highly available than applications that use standalone destinations because WebLogic JMS provides load balancing and failover for the members of a distributed destination in a cluster. ■ For more information on using a distributed destination with your applications, see Chapter 9, Using Distributed Destinations. ■ For instructions on configuring a distributed queue destination, see Configure uniform distributed queues in the Oracle WebLogic Server Administration Console Help. ■ For instructions on configuring a distributed topic destination, see Configure uniform distributed topics in the Oracle WebLogic Server Administration Console Help.

2.4.5 MessageProducer and MessageConsumer

A MessageProducer sends messages to a queue or topic. A MessageConsumer receives messages from a queue or topic. Message producers and consumers operate independently of one another. Message producers generate and send messages regardless of whether a message consumer has been created and is waiting for a message, and vice versa. A Session see Section 2.4.3, Session creates the MessageProducers and MessageConsumers that are attached to queues and topics. The message sender and receiver objects are created as subclasses of the MessageProducer and MessageConsumer classes. The following table describes the MessageProducer and MessageConsumer subclasses. The PTP model, as shown in the figure Figure 2–3 , allows multiple sessions to receive messages from the same queue. However, a message can only be delivered to one queue receiver. When there are multiple queue receivers, WebLogic JMS defines the next queue receiver that will receive a message on a first-come, first-serve basis. The pubsub model, as shown in the figure Figure 2–4 , allows messages to be delivered to multiple topic subscribers. Topic subscribers can be durable or non-durable, as described in Section 6.7, Setting Up Durable Subscriptions. Note: For this release, you can use the JMS Version 1.1 specification message producer and consumer objects or you can choose to use the subclasses. Table 2–9 MessageProducer and MessageConsumer Subclasses Subclass In Messaging Model Performs the Following Function QueueSender PTP Sends messages for a JMS point-to-point provider. QueueReceiver PTP Receives messages for a JMS point-to-point provider. TopicPublisher Pubsub Sends messages for a JMS pubsub provider. TopicSubscriber Pubsub Receives messages for a JMS pubsub provider. Understanding WebLogic JMS 2-15 An application can use the same JMS connection to both publish and subscribe to a topic. Because topic messages can be delivered to all subscribers, an application can receive messages it has published itself. To prevent clients from receiving messages that they publish, a JMS application can set a noLocal attribute on the topic subscriber, as described in Section 5.2.5, Step 5: Create Message Producers and Message Consumers.