aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Message Queue and Multiple Messages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Message Queue and Multiple Messages" Watch "Message Queue and Multiple Messages" New topic
Author

Message Queue and Multiple Messages

glennn smith
Greenhorn

Joined: Dec 12, 2013
Posts: 2
I completed a practice exercise where a servlet sends a message and receives it, now I'm just trying to make it do multiple messages.

Here's the servlet in question. Whenever it prints a message, it just prints the first message I've ever sent it. I'm not sure how to pull the rest out of the queue, or tell if they're even reaching the queue.















And the sender:




Any help/explanations be greatly appreciated.





And the receiver:

E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
You are browsing the messages and in the loop you have


So the loop will always start at the first message in the queue and return after seeing the first message. If you want to see all the message in the queue then do not return in the while loop but add the messages to a List and then return that list to see all the messages.
glennn smith
Greenhorn

Joined: Dec 12, 2013
Posts: 2
Thanks, I've basically got it now. But is there a way I can clear the list of messages? I'm having a hard time understanding exactly where they're stored.
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
glennn smith wrote:Thanks, I've basically got it now. But is there a way I can clear the list of messages? I'm having a hard time understanding exactly where they're stored.


You are currently just browsing the queue not getting the messages off the queue. To remove them you need to read them with an MDB.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Or any other MessageConsumer.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Message Queue and Multiple Messages