I have the following blockingQueue;
final BlockingQueue<Message> blockingQueue = new LinkedBlockingQueue<Message>();
where
public class Message {
private String author;
private String text;
.......
//setters and getters
.....
}
I have a producers which put messages to queue.
now my goal is to create consumers which will be able to fetch from queue only messages for specific with specific author? Is it possible?
If not what could be alternative to BlockingQueue?
You can use a
ConcurrentMap<String,BlockingQueue<Message>>where the string is theauthorThis will require a unique BlockingQueue for each author.