• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Message Queue and Multiple Messages

 
glennn smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or any other MessageConsumer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic