Java Reference
In-Depth Information
The good news is that many MOMs and EJB containers provide mechanisms that deal with
poisoned messages, including redelivery counts and dead-message queues. If you set up the
redelivery count and dead-message queue for the shipping request destination, the message
delivery will be attempted for the specified number of times. After the redelivery count is
exceeded, the message will be moved to a specifically designated queue for poisoned mes-
sages called the dead-message queue. The bad news is that these mechanisms aren't stand-
ardized and are vendor-specific.
Configure MDB pool size . Most EJB containers let you specify the maximum number of
instances of a particular MDB the container can create. In effect, this controls the level of
concurrency. If there are five concurrent messages to process and the pool size is set to
three, the container will wait until the first three messages are processed before assigning
any more instances. This is a double-edged sword and requires careful handling. If you set
your MDB pool size too small, messages will be processed slowly. At the same time, it's
desirable to place reasonable limits on MDB pool size so that many concurrent MDB in-
stances don't choke the machine. Unfortunately, at the time of this writing, setting MDB
pool sizes isn't standardized and is provider-specific.
Consider nonpersistent messages, duplicate-OK acknowledgment, and nontransactional
MDBs . If you want, you can specify a JMS message to be nonpersistent. This means that
the message server doesn't back up the message to the disk. As a result, if the message
server crashes, the message is lost forever. The benefit to using nonpersistent messages is
that they're much faster to process, but at the cost of reliability. Similarly, specifying the
message acknowledgment mode to DUPS_OK_ACKNOWLEDGE can also reduce overhead
and increase performance, as does using nontransactional MDBs. You should be very care-
ful when using these optimization techniques and make sure the business case can tolerate
the relative lack of reliability.
4.5. Summary
In this chapter, we covered basic messaging concepts, JMS, and MDBs. Messaging is an
extremely powerful technology for the enterprise, and it helps build loosely integrated re-
liable systems. JMS allows you to use MOM from Enterprise Java applications without
being bound to vendor-specific APIs. Using the JMS API to build a message consumer ap-
plication can be time consuming, and MDBs make using MOM in a standardized manner
through Java EE extremely easy and robust.
Search WWH ::

Custom Search