I am using Glassfish 3.1.1 with an EJB 3.1 architecture combined with the smack library to process incoming XMPP packets.
For this i have a thread started from a Singleton which processes my incoming packets.
Packet packet = collector.nextResult();
if (packet != null)
processPacket(packet); // here i lookup my processing EJB and start working
What i need is a queue which queues up the packets to process one packet per sender at a time. At the moment i process every received packet in parallel which can makes it impossible for me to keep the order of the packets.
Any ideas how i could solve this as elegantly as possible?
greetings m
PS: The first approach is to store which client is processing packets at the moment and i iterate over the collected packets and look for a sender which is not processing anything. But i am afraid this costs a lot of iterations if none of the packets in the buffer are allowed to be processed.