• Post Reply Bookmark Topic Watch Topic
  • New Topic

Wrt to JMS

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My MDB which is acting as a Listener to a Queue which is in turn calling a SessionBean for its operations.

So i want my MDB to process only one message at a time .

What I mean is, I should not process the next message till the first one is processed?
I am assuming that onMessage() executes as soon as a message is put in the queue.

So i thought of synchronizing the onMessage() method ?

Is this the best approach??
 
subhash uppalapati
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of synchronizing the whole onMessage method, you can use block synchronization to only that particular code which calls the session bean.
But from the posts below I understand that the synchronization won't help.
So reducing the size of the MDB pool is the only option.
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pavan,

You can set the MDB pool size = 1. That will in effect serialize message reads.

Hope it helps,
Reza
 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Synchronizing the onMessage just wouldn't work as you would be sync-ing one instance of the bean unless you reduced the pool to 1 but in that case the synchronization is pointless.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!