home / infca / was / mdb / (navigation links) otherwise you are going to run into more trouble than your bargained for

mdb tuning Links | End

MDB's at WAS


Amunt! Top Amunt!
mdb concepts

Message Driven Beans are business objects whose execution is triggered by messages instead of by method calls. They were added in EJB to allow event-driven processing.

Read here and wiki {very good}

Writing an MDB involves the following tasks:

  • implement the javax.ejb.MessageDrivenBean and javax.jms.MessageListener interfaces in the MDB class
  • provide an implementation of the business logic inside the onMessage()
  • provide a setMessageDrivenContext() method that associates the bean with its environment
  • provide an ejbCreate() method that returns void and takes no arguments. This method may be blank
  • provide an ejbRemove() method implementation. This method may be blank, unless certain resources need to be acquired before the bean goes out of scope

url

MDB
ASF / non-ASF mode

One of the custom properties that users can set on the message listener service in WebSphere Application Server Versions 5.1.x, 6.0.x, and 6.1.x is NON.ASF.RECEIVE.TIMEOUT. Setting this property disables the Application Server Facilities (ASF) mode, and means that the message-driven beans (MDBs) that use listener ports will use a "synchronous receive" mechanism to get messages.

ASF mode

By default, MDBs that are bound to listener ports will use ASF mode to monitor JMS destinations and to process messages
In ASF mode, when a listener port starts, this is what happens:

  1. A queue agent is created that polls the destination looking for messages.
  2. When a message is detected, the queue agent checks if the message is suitable for the MDB using the listener port. If it is, the application server will get a server session from the application's server session pool, and then run this server session on a thread taken from the message listener service thread pool.
  3. The queue agent passes the ID of the message to the server session, and then resumes its browse of the destination.
  4. Once the server session has the ID of the message to process, it will get the message from the destination, and start processing it by calling the MDB's onMessage() method.
  5. When the message has been processed, the server session exits and is returned to the server session pool. The thread that the server session was running on is also returned to the thread pool.
non-ASF mode

When the message listener service custom property NON.ASF.RECEIVE.TIMEOUT is set, non-ASF mode is activated, which means that listener ports will use a synchronous model to process messages.
When the listener port starts up, this is what occurs:

  1. The listener port gets a thread from the message listener service thread pool, and on that thread, creates a JMS message consumer for the destination the listener port is configured to listen to.
  2. The consumer uses the receive() method to detect incoming messages. This method will take the message off the destination, and the thread then invokes the MDB's onMessage().
  3. When the message has been processed, the thread calls receive() again, and the cycle starts over.
  4. If the receive() method does not detect a message in the time specified by the NON.ASF.RECEIVE.TIMEOUT property, the thread performs a small bit of processing before calling receive() again.

url

Activation specifications versus message listener ports

The updated MQ messaging provider support in WebSphere Application Server V7 is based on a J2EE Connector Architecture (JCA) 1.5 compliant resource adapter. Part of the JCA 1.5 specification defines a vendor-neutral way of enabling inbound messages to be delivered to message-driven beans (MDBs) running inside a Java EE compliant application server, such as WebSphere Application Server. The construct that is used to configure and setup inbound message delivery is known as an activation specification.

url


Amunt! Top Amunt!
let's make it run : mdb create & install & cfg

Try this sample (developerWorks) { \\mq\java\mdb } to configure MQ at WAS : make WebSphere MQ v5.3 the JMS provider for applications deployed in WebSphere Application Server v6

ADP_ECO_WAS ?

mdb client

Configure JMS connection factories and destinations - create index.jsp as message sender

MessageBean.java - a Message-Driven Bean example

SimpleMessageBean.java - the Message-Driven Bean class, from "the Java EE 5 Tutorial"

SendRcvClient - a Point-To-Point with MDB example

mdb code

Use google "mdb onmessage example"

Copy-paste the following code into onMessage method:

try { if ( msg instanceof javax.jms.MapMessage ) { javax.jms.MapMessage inMessage = (javax.jms.MapMessage) msg ; String name = inMessage.getString( "name" ) ; // get input param System.out.println( "Sample MDB says : 'Hello, " + name + " !'" ) ; } else { System.out.println( "Sample MDB says: Wrong message type !" ) ; } } catch ( javax.jms.JMSException e ) { e.printStackTrace() ; fMessageDrivenCtx.setRollbackOnly() ; } catch ( Throwable te ) { te.printStackTrace() ; }

Excelent url

Other descriptions :


Amunt! Top Amunt!
WAS/mdb tuning

El Check Point frequency del WAS se define en la propiedades de los Listener Ports, en concreto con el parmetro Maximum Messages.
Application Servers -> select server -> Message Listener Service -> Listener Ports -> select port

Bajar o no el Maximum Messages y dejarlo a 1 - documento técnico aclaratorio
Referencia en el infocenter

MQ top 10 problems, number 4 says : intermittent poor performance when MDB gets messages from WMQ queues
3 solutions :

Case study: tuning WAS v7 and v8 for performance


Amunt! Top Amunt!
mdb links

Best example, second

Oracle Java EE 5 tutorial -> mdb example.

mdb tutorial

{***} My MDB doc {***}

Apache & Geronimo similar sample

Message processing in ASF and non ASF mode (infocenter)

Jordi : aqui hi ha algunes referncies i molts exemples
v.8.5 repo, jms mdb
(internal) v.8 was 8, STE pdf


Ep ! Valid HTML 4.01!   Valid CSS! Site under construction. Escriu-me !
Updated 20150427 (a)  
Uf !