• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Message Queue and Multiple Messages

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or any other MessageConsumer.
 
reply
    Bookmark Topic Watch Topic
  • New Topic