This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.
Joined: Dec 12, 2013
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.
Joined: Mar 17, 2012
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.