Grails RabbitMQ plugin and the possibility to set the reply timeout?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails RabbitMQ plugin and the possibility to set the reply timeout?

marcopas
Hi there,

we have a need to set the reply timeout for using the Grails RabbitMQ
plugin, any clue how this can be done? We are using the RabbitTemplate
directly.

/Marco

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: Grails RabbitMQ plugin and the possibility to set the reply timeout?

Michael Rice
Have a look at this

https://github.com/budjb/grails-rabbitmq/tree/2.1.1

Lots of extras have been added to this, including timeouts.

https://github.com/budjb/grails-rabbitmq/commit/4ec5fa52281f5b893160230155ce92da00b11173

-mike

________________________________________
From: Marco Pas [[hidden email]]
Sent: Wednesday, February 20, 2013 8:48 AM
To: Grails Userlist!
Subject: [SUSPECTED SPAM] [grails-user] Grails RabbitMQ plugin and the possibility to set the reply timeout?

Hi there,

we have a need to set the reply timeout for using the Grails RabbitMQ
plugin, any clue how this can be done? We are using the RabbitTemplate
directly.

/Marco

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: Grails RabbitMQ plugin and the possibility to set the reply timeout?

citron
Perhaps you could also use java's Future / ExecutorService



It would look something like this:
import java.util.concurrent.ExecutorService
import java.util.concurrent.Future
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

private ExecutorService executor = Executors.newFixedThreadPool(1);
	
public void doWorkWithTimeout(long timeoutSecs) {

        //set the executor thread working
        final Future<?> future = executor.submit(new Runnable() {
            public void run() {
                try {
                    doWork()
                } catch (Exception e) {
					//
                }
            }
        });

        //check the outcome of the executor thread and limit the time allowed for it to complete
        try {
            future.get(timeoutSecs, TimeUnit.SECONDS);
        } catch (Exception e) {
            //ExecutionException: deliverer threw exception
            //TimeoutException: didn't complete within downloadTimeoutSecs
            //InterruptedException: the executor thread was interrupted

            //interrupts the worker thread if necessary
            future.cancel(true);
            println ("encountered problem while doing some work"+ e.toString());
        }finally {
			executor.shutdown();
	}
}