• Post Reply Bookmark Topic Watch Topic
  • New Topic

How does onMessage() work ?

 
Naveen Sampra
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I don't return from the onMessage() method until I complete a task, say for example repeatedly using Thread.sleep() until the task is completed successfully, what will happen when another message arrives in the queue ? Will another instance of the message consumer be created and it's onMessage() method called or will the call be blocked ?
Note:- I am not using MDB as consumer. Just a plain class that's registered as a listener.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35743
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naveen,
The message queue can store the incoming messages until you are ready to process them. I think you can setup how many messages you want processed simultaneously. I'm not sure why would you need Thread.sleep() though.
 
Naveen Sampra
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason I want to use Thread.sleep() is because I am doing a FTP operation on reading a message from the queue. I want to handle FTP failure. If I can't connect to the the FTP server I don't want to read next message from the queue because it's going to have the same problem. So I will retry FTP operation after 10 mts until "max" no of times and then give up to read the next message.
Do you know which parameter I need to change to process one message at a time ?
 
Dana Hanna
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the deeper question is why MDB's for this? It's really not the right technology if you ask me.
However, if you must (for some reason), you could do this using an appserver specific setting (MDB pool size = 1), or synchronizing on a class.
Either way, you are not playing nice if you decide to cluster the EJB servers later (unless one server could connect and the other couldn't).
What is an MDB doing FTP for?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!