[jboss-user] [Messaging, JMS & JBossMQ] - Joining messages (queues)
obfuscator
do-not-reply at jboss.com
Sun Jan 28 21:14:25 EST 2007
Hi!
I have the following use case:
*Wait for a free resource
*When resource is free, wait for next job, then use resource to process job.
So, i need to wait until there is BOTH a resource and a job available. All resources are equal, so I can use any resource with any job.
What's the best way of accomplishing this?
My current (flawed?) implementation is as follows:
I'm putting the resources in one queue as they become available, and then I have an MDB registered for that queue (P2P).
The job queue is a separate queue, and jobs are added to the queue as soon as a request arrives (might be days or months between jobs, then suddenly I could get a large amount at once).
When a resource is ready, the onMessage()-method of my MDB is called.
In this method, I then create a MessageConsumer for the job-queue, and call receive() with infinite timeout. This seems to be a sub-optimal solution, since i'm blocking the MDB thread and Jboss AS seems to dislike my approach (refuses to shutdown while thread is blocked) ;)
I've also tried another solution, where I have a n second timeout on the receive method, and call ctx.setRollbackOnly() if no job is available when a resource is free.
This makes JBoss assume that the operation failed non-intentionally and puts all my messages in the dead-letter-queue after 10 retries. I could increase the max amount of retries, but it feels like I'm going down the wrong road here... Is there a nicer way of joining messages?
I basically have free hands when it comes to this, so any suggestion is more than welcomed!
Best regards
Alex
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4007629#4007629
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4007629
More information about the jboss-user
mailing list