Java Messaging Service


‡ JMS basics
± ± ± ± ± ± ± ± ± ± JMS Objects Messaging Models Message Browsing Message Headers Message Persistence Delivery Modes Message Selectors Temporary Destinations MDB Reinitializing on server failure

‡ JMS with Transactions


WebLogic JMS



‡ Advanced JMS
± ± ± ± ± ± ‡ FrontEnd Vs BackEnd Distributed Destinations Flow Control JMS Bridge JMS Migration Foreign JMS Server

Common JMS problems ± JMS OOM ± JMS lost Message ± JMS Message Redelivery ± JMS with JDBC store hung under load ± Pending Messages ± Clients unable to recover from a failed JMS Server ± Poison Messages


WebLogic JMS


Agenda ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Tuning JMS Performance ± Configuration Tuning ± Application Design ‡ JMS Debug 6/13/2011 WebLogic JMS 4 .

A common JMS application ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Application A wishes to send messages to Application B ± A is the ³Producer´ .³Sender´ ± ³Publisher´ ± B is the ³Consumer´ ± ³Receiver´ ± ³Subscriber´ 6/13/2011 WebLogic JMS 5 .

JMS Basics ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Messaging models: ± Point to point (Queue) ± Publish/subscribe (Topic) ‡ JMS Administered objects ± ± ± ± ± ± Connection Factory Connection Session Destination Producer/Publisher Receiver/Subscriber 6/13/2011 WebLogic JMS 6 .

6/13/2011 WebLogic JMS 7 . ‡ Created by ConnectionFactory ‡ Creates Sessions ‡ Due to the authentication and communication setup done when a Connection is created.What is a Connection? ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Definition: represents an open connection to the messaging system. a Connection is a relatively heavyweight JMS object.

setClientID() ± Using JMSConnectionFactory How can I force a ConnectionFactory to issue just one connection at a time? 6/13/2011 WebLogic JMS 8 . it is in stopped mode. When a connection is created. It is typical to leave the connection in stopped mode until setup is complete to minimize confusions. ± Note: Does not need to be started to produce messages! ‡ ClientID can be set on the connection in two ways: ± Connection.What is a Connection? ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Must be started to consume messages.

± weblogic.ConnectionFactory ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ WebLogic automatically provides three connection factories: ± weblogic.MessageDrivenBeanConnectionFactory²an XAcapable factory for message driven EJBs. MessageMaximum: Maximum number of messages that may exist for an asynchronous session and that have not yet been passed to the message listener ± Default is 10 ± Not applicable for Topics ± Acts like a sliding window ‡ 6/13/2011 WebLogic JMS 9 .jms.jms.ConnectionFactory²a non-XA capable factory.jms.XAConnectionFactory²an XA-capable factory ± weblogic.

createConnection() Method Level 6/13/2011 WebLogic JMS 10 .ConnectionFactory ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Connection Factory Load-Balancing and Fail-Over ± Works Just Like Stateless EJB Clustering at the ConnectionFactory.

and messages.What is a Session? ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Definition: object that manages the active exchange of messages between producers and consumers ‡ Creates producers. ‡ Must create separate Session if a client wishes to simultaneously produce and consume messages (singlethreaded) ‡ Adds value to Connection: ± Defines order of messages consumed and messages produced (done serially) ± Guarantees delivery by storing message until ACK by consumer queue 6/13/2011 WebLogic JMS 11 . consumers.

AUTO_ACKNOWLEDGE).What is a Session? ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Session types ± Non-transacted QueueSession session = queueConnection. and restarts message delivery with the oldest unacknowledged message. 6/13/2011 WebLogic JMS 12 . ‡ recover() : Stops message delivery in this session. Session.createQueueSession (true.createQueueSession (false. Session.AUTO_ACKNOWLEDGE). ± Transacted QueueSession session = queueConnection.

PTP Queues ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Many producers can serialize messages to multiple receivers in a queue. first serve 6/13/2011 WebLogic JMS Message   13 . Message 3 Producer Message Receiver1 Distribution Queue Receiver2 9 Producer Message 8 7 6 5 4 Message 1 Queue Manager (MOM Server) Receiver3 ‡For multiple receivers. first come. Messages are delivered to a single client.

Subscriber1 1 Publisher 2 Message Drama Movies Topic Publisher Message 3 1 3 2 Subscriber2 Topic Manager (MOM Server) 6/13/2011 WebLogic JMS ¡ ¢ £ ¤ ¥ ¦ 3 2 1 Subscriber3 14 .Pub/Sub Topics ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Publishing and subscribing to a topic decouples producers from consumers.

println("Message ID " + m.hasMoreElements()) { m = (Message) e. Enumeration e = qbrowser. } ‡ The application can view the messages in the queue.QueueBrowser) QueueBrowser qbrowser = qsession.createBrowser(queue). System. 6/13/2011 WebLogic JMS 15 . while (e.jms.getEnumeration(). but the messages are not considered read and are not removed from the queue.out. not for topic (javax.getJMSMessageID() +" delivered " + new Date(m.nextElement().getJMSDestination()).getJMSTimestamp())+" to " + m. Message m = null.Message Browsing ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Only for queue.

Depends on the JMS provider. ‡ The JMS API does not require the content of an enumeration to be a static snapshot of queue content.x. WLS produces a snapshot of the messages in the queue at the time the queue browser is created. 6/13/2011 WebLogic JMS 16 . Requested by many customers and its possible in diablo.Message Browsing ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Not possible to view the pending messages in 8.

Message Headers ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ JMSCorrelationID JMSDeliveryMode JMSDeliveryTime JMSDestination JMSExpiration JMSMessageID JMSPriority JMSRedelivered JMSReplyTo JMSTimestamp JMSType 6/13/2011 WebLogic JMS 17 .

and it might not ± At-least-once: No message may be lost. but some messages may be duplicated ± At-most-once: It is better to lose a message than to deliver it twice ± Exactly-once: No message may be lost.JMS Basics: QOS ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Quality of service´ is a popular term with many nuances ‡ For this discussion. consider these terms: ± Unreliable: The message might get from point ³A´ to point ³B´. and no message may be delivered more than once 6/13/2011 WebLogic JMS 18 .

6/13/2011 WebLogic JMS 19 . They are guaranteed to be delivered at least once unless there is a system failure. WebLogic JMS writes persistent messages to a persistent backing store (file or JDBC database) assigned to each JMS server during configuration. in which case messages may be lost. ‡ Non-persistent messages are not stored. it will not be redelivered. all non-persistent messages that have not yet been acknowledged will be redelivered.JMS Basics: Persistence ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ A persistent message is guaranteed to be delivered at least once²it is not considered sent until it has been safely written in the file or database. If a connection is closed or recovered. Once a non-persistent message is acknowledged.

JMS Basics: Persistence ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Question: Whats the minimum I need to configure in weblogic to make a message persistent? Answer: ± Default Delivery Mode=Persistent on the connectionFactory ± Persistent Store configured on JMSServer ‡ Question: How can I read the messages in the persistent store? 6/13/2011 WebLogic JMS 20 .

then retargeting JMS. ‡ There is no file store compression pre-9. When messages get deleted from the file.0. What should I do? Answer: Wait for diablo! It has multi pool support. Customer can bounce JMSServer by untargeting the JMSServer. the files keep the size they had at peak load. but it has free space for new messages. ‡ If the size is a problem and the customer doesn¶t want a server bounce. ‡ Question: One single JDBC pool for JDBC JMS Store is a big bottleneck for my store performance.Persistence: JMS Store ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Question: What stops the JMS File stores to grow in size? Answer: A file store never shrinks. 6/13/2011 WebLogic JMS 21 . deleting the store.

sorting. ‡ Bytes/messages high and low thresholds can be configured at various levels in Admin console to start and stop paging. ‡ A paged-out message does not free all of the memory that it consumes. 6/13/2011 WebLogic JMS 22 . The message header and message properties remain in memory for use with searching. and filtering. as even persistent messages cache their data in memory.Persistence: Paging Store ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ JMS message paging saves memory for both persistent and non-persistent messages .

Paged persistent messages continue to be written to the regular backing store (file or database) but the message bodies are removed from memory. Answer: Persistent messages are never paged to the paging store since we already have a persistent copy of the message (in the file or JDBC store).Persistence: Paging Store ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Question: I have paging enabled and I don¶t see my ³persistent´ messages being paged out to paging store? But I do see non persistent messages going to paging store. Paged non-persistent messages are written to the JMS server's message paging store. 6/13/2011 WebLogic JMS 23 .

Exercise 1 ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Configure JMS FileStore and Paging Store and execute the following: ± Case1: Run a simple test that persist the messages in the store. 6/13/2011 WebLogic JMS 24 . ± Case2: Run a test to page persistent and non persistent messages using various threshold parameters.

JMS Basics: Delivery Modes ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ APIs to get messages ± Synchronous (the ³receive´ call) Message msg = qreceiver. ± Asynchronous (the MessageListener interface) public class QueueReceive implements MessageListener{ public void onMessage(Message msg)(){ ««««««.receive(). } } 6/13/2011 WebLogic JMS 25 .

6/13/2011 WebLogic JMS 26 .JMS Basics: Delivery Modes ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Acknowledgement modes when non-transacted ± ± ± ± ± AUTO_ACKNOWLEDGE DUPS_OK_ACKNOWLEDGE CLIENT_ACKNOWLEDGE NO_ACKNOWLEDGE MULTICAST_NO_ACKNOWLEDGE Note: NO_ACKNOWLEDGE and MULTICAST_NO_ACKNOWLEDGE are just weblogic specific acknowledge modes.

public final static String JMS_FACTORY=´javax. } } Get a JNDI Initial Context Get a JMS Topic and ConnectionFactory from JNDI Create the connection.INITIAL_CONTEXT_FACTORY. public final static String TOPIC="jms.close(). message. publisher. env.exampleTopic".TopicConnectionFactory".lookup(TOPIC).close().Sending a JMS Message ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ public class TopicSend { public final static String JNDI_FACTORY="weblogic.put(Context. Topic topic = (Topic) ctx. args[0]). TopicSession session = connection.jndi.createTextMessage(). InitialContext ctx = new InitialContext(env). TopicConnection connection = connectionFactory.AUTO_ACKNOWLEDGE). TopicPublisher publisher = session.createPublisher(topic).PROVIDER_URL. publisher.jms.publish(message).put(Context. Session.lookup(JMS_FACTORY). TopicConnectionFactory connectionFactory = (TopicConnectionFactory) ctx. connection.createTopicSession(false.topic. session.createTopicConnection().setText(³hello world´). TextMessage message = session. session and publisher Create & publish the message Close up shop 6/13/2011 WebLogic JMS 27 . env. public static void main(String[] args) throws Exception { Hashtable env = new Hashtable(). JNDI_FACTORY).close().WLInitialContextFactory".

connection. public final static String TOPIC="jms.createTopicConnection().jndi.close().close().INITIAL_CONTEXT_FACTORY.Receiving a JMS Message synchronously ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ public class TopicReceive { public final static String JNDI_FACTORY="weblogic. TopicConnection connection = connectionFactory.lookup(JMS_FACTORY).createSubscriber(topic). Topic topic = (Topic) ctx. public static void main(String[] args) throws Exception { Hashtable env = new Hashtable(). TopicConnectionFactory connectionFactory = (TopicConnectionFactory) ctx. } } Get a JNDI Initial Context Get a JMS Topic and ConnectionFactory from JNDI Create & Start the connection Get a JMS message Close up shop 6/13/2011 WebLogic JMS 28 .WLInitialContextFactory".put(Context.topic. Message m = subscriber.exampleTopic". TopicSession session = connection. Session. args[0]). env.lookup(topicName). public final static String JMS_FACTORY=´javax.put(Context. session. TopicSubscriber subscriber = session.receive(). JNDI_FACTORY).PROVIDER_URL.TopicConnectionFactory".createTopicSession(false. InitialContext ctx = new InitialContext(env). subscriber.jms.start().close(). connection.AUTO_ACKNOWLEDGE). env.

session = connection. connectionFactory = (TopicConnectionFactory) ctx..getIntProperty(³y´).lookup(JMS_FACTORY). connection = connectionFactory.lookup(topicName).createSubscriber(topic). subscriber = session.AUTO_ACKNOWLEDGE).Receiving JMS messages asynchronously ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ Implement MessageListener Set message listener to receive JMS messages public class TopicReceive implements MessageListener { «.createTopicSession(false. } } 6/13/2011 WebLogic JMS 29 . int y = message. Session. subscriber. «.getIntProperty(³x´). } MessageListener interface for receiving JMS messages asynchronously public void onMessage(Message message) { int x = message. void setup(Context ctx.. connection. String topicName) { topic = (Topic) ctx.setMessageListener(this).createTopicConnection().start().

‡ A message selector is a boolean expression.´testMe in (µrais¶)´). ‡ The receiving applications specify a simple query string to filter the messages that they want to receive. eg: salary > 64000 and dept in ('eng'.Message Selectors ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Message selectors can be used to filter unwanted messages. ‡ The sending application sets message header or property fields to classify a message. session. and subsequently improve performance by minimizing their impact on network traffic.createReceiver( testQueue. msg.'qa') 6/13/2011 WebLogic JMS 30 . ³rais´).setStringProperty(³testMe".

There is never any duplicate work. use selectors with Topics. ‡ Topic selectors only incur a charge once per message per subscriber. ‡ When using queues. if there are a lot of messages that don't match what you are looking for. ‡ Decision is made on the server side. If the message doesn't match a subscriber's selection criteria.Message Selectors ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ If really needed. so less network traffic. 6/13/2011 WebLogic JMS 31 . not with Queues. you are going to compare your selector against those messages over and over again each time you go back to look for one of yours. it is simply ignored and not placed in that subscriber's "subscription".

Exercise 2 ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Creating consumers using Message Selectors: ± Case1: Create and run a simple queue receiver using a selector ± Case2: Create and run a simple topic subscriber using a selector Notice the difference in behavior 6/13/2011 WebLogic JMS 32 .

MDB ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ ‡ MDB is an EJB that acts as a JMS message listener MDB: ± Function as async stateless Service ± Consumes messages from Queue/topic ± Are managed by EJB container ± Only ³Required´ and ³NotSupported´ values supported for <trans- attribute>(default is ³NotSupported´) ‡ maxConcurrentMDBs = Min(max-beans-free-pool. container create ± one connection to the JMS provider ± Multiple Sessions and consumers (for queue only) depending on the size of maxConcurrentMDB¶s. default-thread-pool-size/2+1). WebLogic JMS 33 ‡ 6/13/2011 . For each MDB.

this behavior was not well defined. or 'guest' if no run-as role is provided.MDB ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Question : Which security principal does an MDB use to connect to JMS? Answer. This is either the principle that is mapped to the run-as role specified for the bean.1 SP2. As of WLS 6. Prior to WLS 6. an MDB uses the same principle to connect to JMS as it does to process messages. 6/13/2011 WebLogic JMS 34 .1 SP2.

Reinitializing on server failure: ExceptionListeners ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ ± ± ± ± ± ± If a Java client crashes then the JMS server will clean up all the outstanding server-side resource from the crashed client JVM. such as: JMS connection(s) from the crashed client JVM JMS temporary destination(s) created under the above JMS connection(s) JMS session(s) created under the above JMS connection(s) JMS client(s) created under the above JMS session(s) (connection consumer and regular consumer) JMS browser(s) created under the above session(s) JMS producer(s) created under the above session(s) Well. it all depends if the server ever received PeerGone. What if it never received peergone due to failed network? 6/13/2011 WebLogic JMS 35 .

Reinitializing on server failure: ExceptionListeners ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ If WebLogic Server crashes and it is the frontend to the JMS server.setExceptionListener is set) with a LostServerException. ± The client's javax.. 6/13/2011 WebLogic JMS 36 .) will be called (if javax.jms. which extends JMSException.onException(.jms.. then: ± A JMS client will lose all the server-side resources listed above.ExceptionListener.JMSConnection.

Reinitializing on server failure: ExceptionListeners ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ 6/13/2011 WebLogic JMS 37 .

setExceptionListener(this). ExceptionListener public void onException(JMSException exception) {««. public class QueueReceive implements MessageListener.WLSession)session). if one has been registered.setExceptionListener(classna me).Reinitializing on server failure: ExceptionListeners ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Its best to set ExceptionListeners on both connection and session. } } ‡ ExceptionListener is meant for only for asynchronous listeners. 6/13/2011 WebLogic JMS 38 .} public void init( «««««««. ((weblogic.extensions. If a JMS provider detects a problem with a connection/session.jms..start(). qcon.. qcon. it will inform the connection¶s ExceptionListener.

± In order to make JMS session infected with User Transaction. or a user transaction explicitly started by an application. make sure ConnectionFactory being used is XA enabled or has ³users transactions enabled´ configured to be true.JMS with Transactions ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Transacted Session vs. but not transacted. 6/13/2011 WebLogic JMS 39 . User Transactions ± Transacted sessions ignore JTA user transactions ± A transacted session therefore can not participate in an EJB or MDB container managed transaction. A WebLogic MDB can be user transaction aware.

However. you may NOT consume the same message you produced with the same Tx ‡ Three ways to demarcate the transactions with JMS ± Create transacted session ± Use the java TX API (JTA) user TX with JMS Session ± Use Message Driven Beans ‡ Container managed Tx ‡ Bean managed TX 6/13/2011 WebLogic JMS 40 .JMS with Transactions ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Same JMS client may produce AND consume messages in the same Tx .

Tx Session commits before UserTransaction rollsback.Exercise 4 ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Demonstrate the behavior of synchronous consumer with both transacted session as well as UserTransaction ± Case1: Both Tx session and UserTransaction are used. ± Case2: Both Tx session and UserTransaction are used. 6/13/2011 WebLogic JMS 41 .Tx Session rollsback before UserTransaction commits.

only AUTO_ACK and DUPS_OK_ACK modes are supported.MDB in Transactions ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ When running with ³NotSupported´ tx attribute. we discard that MDB instance (as per the ejb specs) 6/13/2011 WebLogic JMS 42 . ‡ For MDB to run in a distributed Tx: ± Connection factory should be XA enabled ± Should use container managed transaction with ³Required´ Tx-attribute. ± If onMessage() of MDB throws a system exception (even if its running with ³NotSupported´ tx attribute).

JMS as an XA Resource ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ ‡ ‡ ‡ ‡ Distributed Tx is a TX that spans multiple resource managers Coordination of multiple resources is done by a TM 2PC is used to coordinate the TX Make sure to use XA connection factory Sample scenario¶s ± ± ± ± MDB sending message to other Queue in other JMS Server MDB making a DB call MDB calling a CMP in turn making a DB call Standalone java client pulling a message from one queue and pushing to other queue in a global Transaction. For example . ‡ JMS Server is an XA resource.Two queues in the same JMS server constitute just one single resource WebLogic JMS 43 6/13/2011 .

6/13/2011 WebLogic JMS 44 . WebLogic JMS is its own resource manager. That means whenever you are using JMS and a database (even if it is the same database as the JMS messages are stored) then it is 2PC. That is JMS itself implements XAResource and handles the transactions without depending on the database (even when the messages are stored in the database).JMS as an XA Resource ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ Question : Is it a one-phase tx if my WebLogic JMS JDBC store is on the same database for which I am doing other database work? Answer: No.

MDB consumes persistent messages from a JDBC JMSStore and makes some DB updates through ejbs using a TXDatasource (using a non xa pool). Do I need to use xa-pool for the TxDatasource used by ejbs (since there can be at the most 1 non xa resource in dist tx) ?? Answer: JMS *is* the XAResource . JDBC JMS Store uses a non xa pool which is fine. At a minimum. you would have to enable two phase commit on the TxDatasource. Only the JMSServer in front of it. and that would be the one non-XA resource in the transaction.JMS as an XA Resource ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ Question : In a distributed tx. then I don't think underneath it has to be XA.the store behind it must use a non-xa driver. 6/13/2011 WebLogic JMS 45 . If all of the EJBs are using the same TxDataSource. The interactions with the store are not part of the distributed transaction as a separate resource.

Advanced JMS Topics ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ FrontEnd Vs BackEnd ‡ Distributed Destination ‡ Flow Control ‡ Message Bridge ‡ JMS Migration ‡ Foreign JMS Server 6/13/2011 WebLogic JMS 46 .

FrontEnd Vs BackEnd ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ 6/13/2011 WebLogic JMS 47 .

send() call ‡ Failover: When a member becomes unavailable due a server failure. (new) traffic is then redirected toward other available destination members in the set. 6/13/2011 WebLogic JMS 48 .Distributed Destinations ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Completely transparent to senders and receivers ‡ Members of the distributed destination can be located anywhere. but must all be served by JMS servers in a single server cluster ‡ Load Balancing for: ± Producers ± Consumers ± Each Producer.

queues with zero consumers are not considered for message production.Distributed Queues ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ When a message is sent to a distributed queue. ‡ QueueReceivers ± a single physical queue member is chosen for the receiver at creation time 6/13/2011 WebLogic JMS 49 . ‡ QueueSenders ± each time a message is produced using the sender a decision is made as to which queue member will receive the message. unless all instances of the given queue have zero consumers. ‡ when producers are sending messages. it is sent to exactly one of the physical queues in the set of members for the distributed queue ‡ Queue member (but which has no consumers ) can forward messages to other queue members by configuring the Forward Delay attribute (in seconds).

it will first attempt to load balance across any local members that are running on the same WebLogic Server instance.Server Affinity ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ When the Server Affinity option is enabled for distributed destinations. 6/13/2011 WebLogic JMS 50 . then before a WebLogic Server instance attempts to load balance consumers or producers across all the members of a distributed destination in a domain.

Distributed Queue Routing ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ 6/13/2011 WebLogic JMS 51 .

Distributed Queue Routing ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ 6/13/2011 WebLogic JMS 52 .

which member it got pinned to. It shows that the consumers are pinned to a particular member at startup. ± Messages would be received from just one member. ± Start a receiver listening on DistQueue. ± Start the sender as: ‡ Java QueueSend t3://localhost:port [queueName] ± Send a message on either member1 or member2 directly. ± Check on admin console. 6/13/2011 WebLogic JMS 53 .Exercise 5: ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Objective: To demonstarte that Consumers listening on a distributed queue are pinned to a particular member.

± Check all the MBeans ± Send multiple messages. 6/13/2011 WebLogic JMS 54 . ± Go to admin console and turn off the server affinity of connection factory. ± Restart the consumers and the producer and send the messages again.Exercise 6 ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Objective: Demonstrate Server Affinity Attribute for ConnectionFactory ± Start consumer1 on Dist Queue ± Start consumer2 on Dist queue ± Check the admin console if both the members of dist queue have one consumer ± Start the producer. All the messages would be received by just one consumer.

it is sent to all of the topic members in the distributed topic set . you can still create a durable subscription on distributed topic member. ‡ When a message is sent to a distributed topic. just as publishing a message to a distributed topic 6/13/2011 WebLogic JMS 55 . However. ‡ The topic members can be located anywhere but must all be served either by a single WebLogic Server or any number of servers in a cluster. ‡ Publishing a message to a specific distributed topic member automatically forwards it to all the other distributed topic members.Distributed Topics ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Durable subscribers cannot be created for distributed topics.

Distributed Topics Routing ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ 6/13/2011 WebLogic JMS 56 .

DistributedTopic: Publishers

‡ If one or more of the distributed topic members is not reachable, and the message being sent is non-persistent, then the message is sent only to the available topic members. ‡ If one or more of the distributed topic members is not reachable, and the message being sent is persistent, then the message is stored and forwarded to the other topic members when they become reachable.


WebLogic JMS


DistributedTopic: Subscribers

Same as is the case with publishers
‡ Any persistent messages published to one or more unreachable distributed topic members are eventually received by topic subscribers of those topic members once they become reachable. ‡ Any non-persistent messages published to those unreachable distributed topic members will not be received by that topic subscriber.
Ultimately, a topic subscriber is pinned to a physical topic member. Why are the docs so confusing ??


WebLogic JMS


Failure Recovery of Consumers

‡ ‡

If the consumer is synchronous, then the exception is returned to the user directly. If the topic subscriber is asynchronous, then the exception is delivered inside of a ConsumerClosedException that is delivered to the ExceptionListener defined for the consumer session, if any.
The above statements hold true for both Queue Receivers and Topic Subscribers. The above statements hold true for both distributed and non distributed destinations because ultimately a distributed destination consumeris pinned to a single physical member of distributed destination.

Note: ±



WebLogic JMS


Both the connection factory and the distributed topic members will use their local system clock to see if a consumer is created after a message is published. Messages published to topics before consumers are created are not visible to consumers.Distributed Destinations ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Question: How important is it to keep the system clocks synchronized among server instances hosting distributed destination members and their connection factories? Answer: It is very important when using distributed topics with nondurable subscribers and may lead to non delivery of messages. 6/13/2011 WebLogic JMS 60 .

the initial flow limit for that producer is set to Flow Maximum. at which point they are no longer flow controlled ‡ Flow Control Parameters on ConnectionFactory ± Flow Maximum:If a producer is not currently limiting its flow when a threshold condition is reached. then the producer will continue at its current flow limit until the next time the flow is evaluated. ± Flow Minimum ± Flow Interval 6/13/2011 WebLogic JMS 61 .Flow Control ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Threshold Parameters ± Bytes/Messages Threshold High ± Bytes/Messages Threshold Low:Flow control is still in effect for producers that are below their message flow maximum. Producers can move their rate upward until they reach their flow maximum. If a producer is already limiting its flow when a threshold condition is reached (the flow limit is less than Flow Maximum).

5). or vice versa.Flow Control ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ Flow Steps ± The number of steps used when a producer is adjusting its flow from the Flow Minimum amount of messages to the Flow Maximum amount. 12. 100. ± The movement upward is linear. 25. 6/13/2011 WebLogic JMS 62 . The difference is simply divided by the number of steps. 50. ± The downward movement (the decay) is geometric (For example.

JMS Bridge

‡ Messaging Bridge :
It allows you to configure a forwarding mechanism between any two messaging products, thereby providing interoperability between separate implementations of BEA WebLogic JMS or between WebLogic JMS and another messaging product . ± Source and target bridge destinations can be either queues or topics. ± You can specify a quality of service (QOS), message filters, transaction semantics, and connection retry policies ± Console allows to temporarily suspend bridge traffic whenever necessary, tune the execute thread pool size, and monitor the status of all configured bridges.


WebLogic JMS


JMS Bridge

‡ If you configure a bridge instance to forward non-persistent messages, configure and use a connection factory that has the Default Delivery Mode set to Non-Persistent. ‡ Make sure to enable trust between two domains (why?) ‡ WLS provides 3 adaptors by default: ± jms-xa-adp.rar: QOS is Exactly-once. This envelops a received message and sends it within a user transaction (XA/JTA). The source and target JMS connection factories must be configured to use the XAConnectionFactory. ± jms-notran-adp.rar: no transaction semantics. Used when the required QOS is Atmost-once or Duplicate-okay. ± jms-notran-adp51.rar
6/13/2011 WebLogic JMS 64

JMS Bridge

‡ Increase bridge thread pool to match number of bridge instances if there are more than five synchronous bridges targeted to the same WebLogic Server.
The way to configure it is to add one entry in the Server entry in config.xml. <Server Name="foo"> .............. <ExecuteQueue Name="MessagingBridge" ThreadCount="XXX"> </Server> The name of the execute queue is hard-coded.


Quality of service degradation ± If enabled, bridge automatically degrades to next achievable QOS Selector ± The message selector for the bridge allows you to filter the messages that are sent across the bridge.



WebLogic JMS


JMS Bridge ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ 2 1 3 4 6/13/2011 WebLogic JMS 66 .

WebLogic JMS 67 6/13/2011 . it may have a performance impact. so there is no need to insert a messaging bridge in the message path to provide higher availability.JMS Bridge ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Question: When should I use a messaging bridge? Answer: When you need store-and-forward functionality/high availability at the cost slightly lower throughput.MDBs automatically retry connecting to their source destination if the source destination is inaccessible. I want to listen on a weblogic destination !! ‡ Question: When should I avoid using a messaging bridge? Answer: ± Receiving from a remote destination²use an message driven EJB or implement a client consumer directly.

6/13/2011 WebLogic JMS 68 .JMS Bridge ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ± Send messages to a local destination²send directly to the local destination. ± Environment with low tolerance for message latency.

the best practice is to send to the distributed destination using the distributed destination's JNDIName and disable server affinity. the best practice is to configure one bridge for each member of a distributed destinations using the member's JNDIName. This allows the distributed destination to load balance incoming messages. If the target is a distributed destination. ± 6/13/2011 WebLogic JMS 69 .JMS Bridge ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Question: What¶s the recommended way to use JMS Bridge with distributed destinations? Answer: ± If the source is distributed destination.

Make sure the ³Guest Disabled´ on the domain is unchecked. Create a queue ³TestQ´ in domain1 and a queue ³TestBridgeQueue´ in domain2.rar file (JNDI: eis. Setup the trust between two domains Deploy the jms-xa-adp.jms.WLSConnectionFactoryJNDIXA) Make sure the ConnectionFactories being used are XA Enabled. configure and test a JMS Bridge between two domains using a queue as a source destination and a queue as a target destination. Create the bridge with Exactly-Once QOS Test the bridge 6/13/2011 WebLogic JMS 70 . ± ± ± ± ± ± ± ± ± Create two domains Make sure all the names are unique in the two domains.Exercise 7 ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Objective: Setup.

JMS Bridge .User Name/Password. ± Actual destination is not running and cannot communicate with the messaging bridge. Destination JNDI Name. 6/13/2011 WebLogic JMS 71 . like ‡ Failed to find the source/target adapter ‡ Failed to look up the source/target adapter are either because the adapter is not deployed properly or the JNDI name in the JMSBridgeDestination instance is incorrect . viz.Troubleshooting ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Most of the problems are related to: ± Bridge's destination is not configured correctly. Connection Factory JNDI Name . Connection URL. ± Most of the adaptor related errors.

DebugMessagingBridgeRuntime=³true´ -Dweblogic. ‡ The actual cause of the problem (such as JMSException or NamingException) is lost.xml <ServerDebug ««««««« DebugMessagingBridgeRuntime=³true" DebugMessagingBridgeStartup=³true³ Name="myserver³/> 6/13/2011 WebLogic JMS 72 .debug.debug.Debugging ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ In almost all cases. it throws a Resource Exception with a message.JMS Bridge . ‡ To specify debug parameters either start WebLogic with -Dweblogic.DebugMessagingBridgeStartup=³true´ ‡ Or you can specify in the config.

‡ Currently. ‡ Currently. Its manual. The RMI stub keeps track of which server currently hosts the pinned service. WebLogic Server does not support automatic migration.JMS Migration ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Clients access a migratable service in a cluster using a migration-aware RMI stub. migration is supported only for JMS servers and the JTA Transaction Recovery Service . 6/13/2011 WebLogic JMS 73 . and it directs client requests accordingly.

But? ‡ All constrained candidate servers of a migratable target must belong to the same cluster ‡ What is a migratable target? 6/13/2011 WebLogic JMS 74 . However. ‡ Generally JTA migration should be followed by JMS migration. This ensures that the transaction integrity is maintained before and after the migration. since the JTA provides the transaction control. JMS is usually migrated along with JTA.JMS Migration ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ JMS can be migrated independent of the JTA .

JMS Migration ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ 6/13/2011 WebLogic JMS 75 .

java weblogic.Admin -url AdminHost:7001 -username adminuser -password adminpassword \MIGRATE -migratabletarget myserver2(migratable) -destination myserver3 6/13/2011 WebLogic JMS 76 .JMS Migration ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ JMS Stores have to be configured such that both the source and destination servers have access to them. ‡ Migration can be done through Admin Console or the commandline interface utility. it is recommended to have either a SAN (Storage Area Network) or a Dual ported SCSI disk. ‡ If the application uses file-based persistence (JMSFileStore).

JMS Migration ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Migration not Always Required ± Persistent Queuing of Time-Sensitive Messages ± Persistent Pub/Sub with Durable Subscribers ± Pending XA Transactions ‡ Alternatives to JMS Server Migration ± Restart Failed WL Server on the Same Machine ± Migrate WL Server to Another Machine 6/13/2011 WebLogic JMS 77 .

JMS Migration ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Question: What happens to active subscribers/consumers who have open sessions with the JMS server at the point of starting the migration? Are they sessions automatically switched to the new server? Answer: Any JMS clients that were connected to the failed WebLogic Server must have a reconnect logic in place. 6/13/2011 WebLogic JMS 78 . ‡ Question: What about MDBs? I cannot implement any exceptionListeners on an MDB Answer: Don¶t worry its automatic! When a JMS Server migrates. MDBs on its destinations migrate automatically but make sure that MDBs are deployed homogeneously to the cluster.

± ± ± ± ± ± ± ± ± 6/13/2011 Create a cluster of two managed servers.Exercise 8 ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Objective: Create a cluster of two managed servers and migrate a JMS server from first to the second managed server. WebLogic JMS 79 . Migrate the JMS Server to managed2 and check if the sender and receiver recover automatically Send another message after migration is successful. Create a Connection Factory targetted to the cluster Create a JMS server targetted to managed1 with a queue µTestQ¶ Create a sender and producer for µTestQ¶ using cluster url Both the sender and consumer should have Connection ExceptionListener as well as session ExceptionListener Send a dummy message and test it gets received fine Kill the server hosting the JMS Server and check the TYPE OF EXCEPTIONS getting thrown sender and receiver sides.

like a JMS connection factory or destination object ‡ A JNDI name in the JNDI name space for your WLS cluster ± represents a JNDI provider that is outside the WLS 6/13/2011 WebLogic JMS 80 .Foreign JMS Server ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Foreign JMS Server ± sort of ³symbolic link´ between: ‡ A JNDI object in another JNDI directory.

Common JMS problems ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ JMS OOM ‡ JMS lost Message ‡ JMS Message Redelivery ‡ JMS with JDBC/File store hung under load ‡ Pending Messages ‡ Clients unable to recover from a failed JMS Server ‡ Poison Messages 6/13/2011 WebLogic JMS 81 .

JMS OOM ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Several factors that may lead to OOM are: ± Senders outpacing receivers: In this case two corrective approaches may be followed. Throttling the sender as well as tuning the consumers. ± Message paging: Even in case of persistent messages. headers still remain in memory ± Zombie consumers in case of Topics 6/13/2011 WebLogic JMS 82 .

and the message is not sent.JMS OOM ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Throttling addresses the issue of senders outpacing receivers and senders starving the receivers out of their fair share of CPU and other server resources.ResourceAllocationException´. at which point producers are forced to slow down by delaying the time when their calls to produce a message return. WebLogic JMS throws the exception ³javax. This flow control takes effect if a configurable messages or bytes threshold is exceeded. BytesMaximum and MessagesMaximum settings.viz. 6/13/2011 WebLogic JMS 83 . Flow control is configurable via a producer¶s connection factory.0 onwards) to slow down overactive producers.jms. When a producer send exceeds configured quotas. In this case. an application program¶s typical remedial action is to retry the send after a delay. ± Flow control (7. ± Quotas.

JMS OOM ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Bytes/Messages Threshold High The upper threshold value that may triggers the following events : ± Log Messages . then paging is started.A message is logged on the server indicating a high threshold condition.If paging is enabled (and a paging store has been configured). 6/13/2011 WebLogic JMS 84 . ± Bytes/Message Paging . the JMS server becomes armed and instructs producers to begin decreasing their message flow. ± Flow Control .If flow control is enabled.

6/13/2011 WebLogic JMS 85 .If paging is enabled. the JMS server becomes disarmed and instructs producers to begin increasing their message flow.JMS OOM ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Bytes/Messages Threshold Low The lower threshold value that may triggers the following events : ± Log Messages .If flow control is enabled. ± Flow Control . ± Bytes/Message Paging . paging is stopped (if paging is occurring).A message is logged on the server indicating that the threshold condition has cleared.

seg fault of JMS client. What if the client dies abruptly ? Core dump.JMS OOM ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ Note: Make sure to close the connection/session/consumers. Bugs in JMS Consumer client ( any race condition. Network problems that end up closing the JMS connection while live session and producers/consumers not close. thread safety issues that may kill the client to close the connection pre-maturely). What does the spec say about it ? Does RJVM Idletimeout and DGC help in any way ? 6/13/2011 WebLogic JMS 86 .

setRollbackOnly() in MDB¶s onMessage() method. In this case the transaction in which MDB is participated will be rolled back and the message will be redelivered. (CMT only) ± MDB participating in a Transaction failed for some reason.JMS Message Redelivery ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Why does a JMS message get redelivered? ± RuntimeException has been thrown from receiver¶s/MDB¶s onMessage method ± Call to ejbcontext. 6/13/2011 WebLogic JMS 87 . For ex: if the MDB calls another EJB. which makes a JDBC call and the database operation fails.

recover() from a standalone receiver ± Session.JMS Message Redelivery ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ± MDB is transactional but takes a long time to process. JMS will redeliver the message. the transaction monitor will timeout the transaction and rolls it back .consequently. ± User has made a call to Session. But how many times ? What does the spec say about it ? 6/13/2011 WebLogic JMS 88 .acknowledgement () is not called from a standalone receiver with client acknowledgement.

wait(Native Method) at java.transaction.jms.ExecuteThread.internal.lang.ServerTransactionImpl.java:212) at weblogic.commit(ServerResourceInfo.kernel.Object.internal.ejb20.java:210) 6/13/2011 WebLogic JMS 89 .MDListener.internal.java:2350) at weblogic.java:1090) at weblogic.transaction.finishCommit(BEXATranEntryReceive.ServerSCInfo.transaction.transaction.BEXATranEntryReceive.execute(JMSSession.internal.0x47fcfdb8] at java.java:2035) at weblogic.java:2266) at weblogic.jms.run(ExecuteThread.lang.internalCommit(ServerTransactionImpl.MDListener.transaction.commit(BEXAResource. Thread dump shows many threads waiting at StoreRequest.waitForIOComplete(StoreRequest.ServerTransactionImpl.jms.java) at weblogic.JMSSession.internal.commit(ServerTransactionImpl.JMSSession.internal.onMessage(JMSSession.waitForIOComplete() call.ejb20.java:152) at weblogic.startCommit(ServerSCInfo.java:415) at weblogic.internal.globalCommit(ServerTransactionImpl.ServerTransactionImpl.backend.MDListener.java:527) at weblogic.jms.client.transaction.internal.internal.ServerResourceInfo.ExecuteThread.transactionalOnMessage(MDListener.internal.ServerResourceInfo.java:406) at weblogic.StoreRequest.java:1350) at weblogic.Object..internal.wait(Object.java:393) at weblogic.java:311) at weblogic.ejb20.transaction.java:273) at weblogic.java:286) at weblogic.client.localCommit(ServerTransactionImpl.java:246) at weblogic.execute(MDListener.globalRetryCommit(ServerTransactionImpl.JMS with JDBC store hung under load ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ ‡ Consider a scenario where a JMS server with JDBC store gets hung under load.java:234) at weblogic.jms.onMessage(MDListener.ServerTransactionImpl.java:1512) at weblogic.commit(ServerResourceInfo.BEXAResource.execute(ExecuteThread.store. For eg: "ExecuteThread: '14' for queue: 'default'" daemon prio=5 tid=0x46d13e90 nid=0x5ac waiting on monitor [0x47fcf000.backend.transaction.kernel.ServerTransactionImpl.

net.TTC7Protocol.ExecuteThread.execute(JMSStore.write(JDBCIOStream.net..MAREngine.executeUpdate(OraclePreparedStatement.driver.kernel.NetInputStream.net.NetInputStream.ns.jdbc.driver.jdbc.java:234) at weblogic.jdbc.read(SocketInputStream.doOall7(TTC7Protocol.executeNonQuery(OracleStatement.java:85) at oracle.socketRead(Native Method) at java.store.java:326) at weblogic.driver.java:255) at weblogic.read(Unknown Source) at oracle.doTheIO(StoreRequest.kernel.ttc7.ioThreadPool'" daemon prio=5 tid=0x4745c400 nid=0xcf8 runnable [0x48f8f000.jdbc.ttc7.jdbc.JMS with JDBC store hung under load ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ One of the threads looks like: "ExecuteThread: '1' for queue: 'JMSStore<null>.ttc7.executeUpdate(Statement.ns.java:210) ‡ JMS is marked unavailable as an XA Resource 6/13/2011 WebLogic JMS 90 .jms.execute(ExecuteThread.ns.doExecuteOther(OracleStatement.OracleStatement.java:931) at oracle.JDBCIOStream.jdbc.ttc7.java:956) at oracle.ns.unmarshalSB1(MAREngine.java:375) at oracle.unmarshalUB1(MAREngine.NetInputStream.store.java:608) at weblogic.Packet.ns.MAREngine.jdbc.ns.net.OracleStatement.executeFetch(TTC7Protocol.net.JMSStore.OraclePreparedStatement.OracleStatement.store.run(ExecuteThread.java:318) at weblogic.SocketInputStream.net.receive(Unknown Source) at oracle.doExecuteWithTimeout(OracleStatement.Statement.NetInputStream.Oall7.getNextPacket(Unknown Source) at oracle.java:2138) at oracle.read(Unknown Source) at oracle.java:2877) at oracle.ttc7.net.receive(Unknown Source) at oracle.java:1894) at oracle.SocketInputStream.java:2015) at oracle.jdbc.jms.jdbc.read(Unknown Source) at oracle.StoreRequest.TTC7Protocol.DataPacket.net.jdbc.receive(Oall7.ExecuteThread.driver.0x48f8fdb8] at java.pool.java:525) at weblogic.java:893) at oracle.jms.

JMS with JDBC store hung under load ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ How does it work ? ± JMS layer submits an I/O request to the store ± JDBC store queues it up ± I/O thread performs submitted requests in order of submission ± I/O thread sends a signal to the submitted I/O request when it completes ‡ Tuning Parameters ± MaxXACallMillis (default 120 seconds) ± MaxResourceUnavailableMillis (default 30 minutes) 6/13/2011 WebLogic JMS 91 .

received and not committed. ± subject to a delivery time (as of WebLogic JMS 6. ± A rolled back message remains pending until the transaction actually rolls back.1 or later). nor does an exception that set a transaction as rollbackOnly followed by an actual rollback. received and not acknowledged. Rolling it back multiple times does not cause double counting. subject to a redelivery delay (as of WebLogic JMS 6.1 or later). Basically a pending message is an in-flight message 6/13/2011 WebLogic JMS 92 .Pending Message ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Pending means the message could have been: ± ± ± ± sent in a transaction but not committed.

‡ Infected in a Distributed Transaction ‡ Persistent messages with JDBC jms store under heavy load. customer knows that a particular consumer is bound to take a long time in processing a single message. its WAD.Pending Message ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ MessageMaximum attribute for the connectionFactory (Will talk more about it during performance talk) ‡ In many cases. 6/13/2011 WebLogic JMS 93 . For example.

Relying on garbage collection to eventually reclaim these resources may not be timely enough. JMS Specs section 4.3. clients should close these resources when they are not needed. ‡ All care should be taken to cleanup the JMS objects gracefully.5: Since a provider typically allocates significant resources outside the JVM on behalf of a connection. ‡ In case of JMS server migration. However no choice for clients getting killed/disconnected abruptly.Clients unable to recover from a failed JMS Server ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ More important is to understand the expected behavior as per the jms specs. ‡ For eg: ± Application code is supposed to recover a synchronous consumer ± Asynchronous consumer would recover only if an exception listener has been registered with the connection object. 6/13/2011 WebLogic JMS 94 . exception listener should be registered with weblogic proprietary session object.

Poison Messages ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Poison messages are messages that a receiver must reject. and pipelined again. ‡ If they occur on an asynchronous consumer. Typically. a message is rejected due to a problem with the message itself. but a message can also be rejected due to a temporary resource outage. the poison message and the subsequent messages following it in the pipeline may need to be flushed. re-inserted into their originating destination. ‡ Leads to endless loop 6/13/2011 WebLogic JMS 95 .

The message stays out of circulation until the application thinks it is ready to try again. that message is simply deleted. and a message exceeds its redelivery limit. ‡ Redelivery Limits: If a message is rolled back or recovered more times than this limit. then message is removed from the queue and forwarded to its destination¶s error destination. If the error destination is not configured. without preventing other messages behind the delayed message from being delivered.Poison Messages ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Redelivery Delays : It tells JMS to defer redelivering the message for some amount of time. ‡ Error Destination 6/13/2011 WebLogic JMS 96 .

What about MDB ? 6/13/2011 WebLogic JMS 97 .Connection.stop()´. and can later call ³javax.Poison Messages ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Asynchronous JMS applications that have access to their Connection may pause message delivery by calling ³javax.Connection.jms.start()´ to continue processing messages.jms.

verbose=true ± -Dweblogic.debug=true 6/13/2011 WebLogic JMS 98 .connect.jms.jms.connect.ejb.debug=true ± -Dweblogic.poll.ejb20.jms.JMS debug ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ JMS: ± ± ± ± ± ± ± ± ± DebugJMSBackEnd="true" DebugJMSBoot="true" DebugJMSCommon="true" DebugJMSConfig="true" DebugJMSFrontEnd="true" DebugJMSLocking="true" DebugJMSStore="true" DebugJMSXA="true³ DebugMsgpath=³true´ ‡ MDB: ± -Dweblogic.ejb.

No two JMS Servers can share the same persistent store. Templates are needed to create temporary destinations on any JMSServer 6/13/2011 WebLogic JMS 99 .Important points ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ WebLogic JMS does not ³drop´ (silently delete) messages. All the queues on one JMS Server share the same persistent store. A queue exists only on the JMS Server it was configured for. There can be more than one persistent JDBC store in a database using prefixes. JMS asynchronous consumers that share a JMS session must not run currently (session should be single threaded. There can be more than one persistent file store in a directory.jms specs) A JMS Server can be deployed on only one server. except where the designer has explicitly asked for a lower QOS (such as using the multicast option for pub/sub.or message expiration).

‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ Tuning JMS Performance .

‡ Scalability. it should increase as well. Also. or even thousands of connections? How is throughput affected as the number of connections increase? Ideally. 6/13/2011 WebLogic JMS 101 . Can the server handle dozens. sends almost always use fewer resources than receives. as the rate at which messages enter the system is usually not of interest. hundreds. and are consequently less likely to be a bottleneck.Benchmark Tips ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Throughput: Measuring sends-per-second is also often misleading.

This is not true for all vendors 6/13/2011 WebLogic JMS 102 .or message expiration).Benchmark Tips ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Fairness: Ensure that homogenous applications tend to all get served at about the same rate. except where the designer has explicitly asked for a lower QOS (such as using the multicast option for pub/sub. and that all take turns getting served. ‡ Dropped messages: WebLogic JMS does not ³drop´ (silently delete) messages.

JMSFileStore. are synchronous writes used for both sends and receives? -Dweblogic.Benchmark Tips ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Concurrency: JMS asynchronous consumers that share a JMS session must not run currently (session should be single threaded.store-name.SynchronousWritesEnabled=false 6/13/2011 WebLogic JMS 103 .jms specs) ‡ Persistence: JDBC or a file store? If it is a file store.

Performance Tuning ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ Weblogic¶s JMS Performance Tuning can be divided into two broad categories: ‡ Configuration Tuning ‡ Application Design 6/13/2011 WebLogic JMS 104 .

JMSThreadPoolSize=n ± Server-Side Thread Pools eg: <ServerName="server1³ NativeIOEnabled="true³ JMSThreadPoolsSize=´18´ ServerVersion="7.0.0"> <ExecuteQueueName="default³ ThreadCount=³18"/> </Server> 6/13/2011 WebLogic JMS 105 .ThreadPoolSize=´n´ (def = 5) -Dweblogic.0.Configuration Tuning ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Tuning Thread Pools and EJB Pools ± Client-Side Thread Pools -Dweblogic.

dispatch policies 6/13/2011 WebLogic JMS 106 .Configuration Tuning ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ± Server-Side Application Pools max-beans-in-free-pool.

File Stores ± Both have the same transaction semantics and guarantees. ± JDBC stores may make it easier to handle failure recovery 6/13/2011 WebLogic JMS 107 . ± File stores are much better suited to paging non-persistent messages.Configuration Tuning ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Configuring JVM Memory ‡ JDBC Stores vs. JDBC stores will generate network traffic if the database is on a different machine from the JMS server. ± File stores generate no network traffic.

Configuration Tuning ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Persistent Store Tuning ± File Store Tuning ‡ Disabling Synchronous Writes ‡ Enhanced Hardware: consider using high-performance hardware for improved reliability. ± JDBC Store Tuning : Follow that particular DBMS tuning guide 6/13/2011 WebLogic JMS 108 . consider using hardware disk mirroring.

but their stores should typically be on separate databases/disks.Configuration Tuning ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Partitioning Your Application ± Spreading destinations across multiple stores: Multiple JMS servers may still optionally be targeted at the same WebLogic server instance. Why do you think it will help ? ± Clustering JMS ‡ Distributed destinations ‡ JMS Server migration 6/13/2011 WebLogic JMS 109 .

non-server-side clients) obtain their JMS connection using ³CF1´. and each time ³create connection´ is called. the second through ³server2´. For example. then the first client routes JMS requests through ³server1´.Configuration Tuning ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Connection Load Balancing: This ³round-robin´ load balancing occurs each time the connection factory is looked up. if a connection factory. ³server1´ and ³server2´. the third through ³server1´. ³CF1´. and remote JMS clients (e. 6/13/2011 WebLogic JMS 110 . no matter how many sessions and consumers exist between them.g. and so on« ‡ Connection concentration : WebLogic Server clients always use a single. is configured with two targets in a cluster. shared socket between a client and a particular server.

‡ reduces # of involved resources. which reduces the number of involved resources to one.Configuration Tuning ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ± Co-locating XA RMs in a distributed tx ‡ reduces network overhead eg: Consider an EJB invoking another EJB that sends a JMS to a destination sitting on another server. there is a further advantage in configuring both destinations to reside on the same JMS server. In this case. 6/13/2011 WebLogic JMS 111 . and thus allows the transaction to optimize and become one-phase. it helps to make sure that both destinations reside on the same instance of WebLogic Server. For eg: if a transaction typically involves two destinations.

the message bodies are removed from memory since we already have a persistent copy of the message 6/13/2011 WebLogic JMS 112 . messages are paged once the number of bytes and/or number of messages exceeds a configurable threshold. 2*(ack or commit interval)+1 What are pros and cons of increasing this parameter ? ‡ Message Paging ± If enabled. Persistent messages are never paged to the paging store.Configuration Tuning ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Tuning the Asynchronous Pipeline Size (MessageMaximum attribute on ConnecionFactory) Especially if the JMS application defers acknowledges/commits. If paging is enabled.

6/13/2011 WebLogic JMS 113 . ± Durable subscribers require a persistent store to be configured on their JMS server.Application Design ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Topic Vs Queue ‡ Asynchronous vs. ‡ Persistent vs. or there are only nondurable subscribers for a topic. Synchronous Consumers ± A synchronous consumer consumes a thread for the duration of its receive call. especially if the call specifies a blocking timeout. the messages will be downgraded to non-persistent. ± WebLogic JMS automatically forces all messages in a temporary destination to non-persistent. Non-Persistent: ± In WebLogic 7. even if they receive only non-persistent messages.0. a thread can remain idle for long periods. if there are no subscribers. As a result.

but an application programmer can write one. but not transacted. or a user transaction explicitly started by an application. User Transactions ± Transacted sessions ignore JTA user transactions ± A transacted session therefore can not participate in an EJB or MDB container managed transaction. There is no J2EE standard for producer pools. Note: We do provide a sample code on dev2dev ‡ Caching of lookups 6/13/2011 WebLogic JMS 114 . ‡ Producer Pooling ± Just as consumers can be pooled using an MDB pool or a ServerSessionPool. producers can also be pooled. A WebLogic MDB can be user transaction aware. and WebLogic Server currently does not provide one.Application Design ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡ Transacted Session vs.

Q&A ‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ 6/13/2011 WebLogic JMS 115 .

bea.com 6/13/2011 WebLogic JMS 116 .‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ TM How business becomes e-businessŒ www.