Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Message Driven Beans Syn/Async ?

 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello !
Can anyone tell me if message driven beans are used for synchornous or asynchonous messaging ? How do they differ if it is possible to use them in either ways ?
Thanks and Regards,
Leena
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
you can consume messages both, snyc and async.
as far as i know, please correct me if im wrong:
for asnyc processing you set a MessageListener (implement the onMessage method) and just wait for incomming messages.
p
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JMS is asynchronous, meaning the producer does not have to wait for the consumer. The consumer can block if they want but it is of no concern to the producer of the message.
 
Gurumurthy Ramamurthy
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A client may either synchronously receive a message consumer's messages or have the consumer asynchronously deliver them as they arrive.

For synchronous receipt, a client can request the next message from a message consumer using one of its receive methods. There are several variations of receive that allow a client to poll or wait for the next message.

For asynchronous delivery, a client can register a MessageListener object with a message consumer. As messages arrive at the message consumer, it delivers them by calling the MessageListener's onMessage method.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leena,


Can anyone tell me if message driven beans are used for synchornous or asynchonous messaging ?

MDBs don�t have any way to interact directly with the clients; this is why they have no home or remote interfaces. Therefore it makes no sense for MDBs to process messages synchronously. Even more, this is actually the reason why EJB 2.0 introduced the MDBs in the first place: prior the developers were forced to use all kind of "tricks", like startup classes in order to register an asynchronous listener to a JMS destination.
Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic