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.
The moose likes Threads and Synchronization and the fly likes Queue up messages based on a field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Queue up messages based on a field" Watch "Queue up messages based on a field" New topic

Queue up messages based on a field

Hansel Tizer

Joined: Jan 13, 2009
Posts: 2

I have a number of threads delivering messages to my app.

Each message is basically an Object with an id.

I need to create a single queue for messages related to that id.
i.e. each queue will only contain Objects with the same ID.

Any advice/code samples appreciated.

Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

Sounds like you want a Map<ID, Queue>.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Queue up messages based on a field
It's not a secret anymore!