Java Reference
In-Depth Information
processing, the CDI event bus isn't fault-tolerant and is also not asynchronous. Note that
you can combine the @Asynchronous annotation with CDI events if you need to.
When you do need asynchronous processing, loose coupling, and reliability, MDBs are one
of the best solutions around, which is why they're so popular for system integration. Let's
take a closer look at why this is the case.
4.3.2. Why use MDBs?
Most Enterprise applications require some form of messaging, whether they know it or not.
In this section we're going to look at some of the reasons you may need messaging in your
application. You may discover that you've already fulfilled this need in another way, but
now that you're learning about MDBs, you'll see that they're a much more elegant solu-
tion.
Multithreading
Your business application may require multithreaded message consumers that can process
messages concurrently and maximize message throughput. MDBs help you avoid complex-
ity because they handle multithreading right out of the box, without any additional code.
They manage incoming messages among multiple instances of beans (in a pool) that have
no special multithreading code themselves. As soon as a new message reaches the destina-
tion, an MDB instance is retrieved from the pool to handle the message, as shown in figure
4.7 . This is popularly known as MDB pooling , which you'll learn about when we discuss
the MDB lifecycle later in this chapter.
Figure 4.7. As soon as a message arrives at its destination, the container retrieves it and assigns a servicing MDB
instance from the pool.
 
Search WWH ::




Custom Search