I'm a little lost on Asynchronous Processors.

My goal is to not use threads needlessly, so that's why I'm zeroed in
on Asynchronous Processors.

First off, is it fair to assume that JMS can be fully asynchronous
when using a request-reply schema?  Assuming so, here' is my problem:

I don't really understand how to set up a route such that my client
code, and my server code, both use no threads. Most examples I see are
inherently synchronous.  For instance, I can't use a bean callback on
the consumer side, I think, because that's naturally going to tie up a
thread, right?

So let me put down some routes I've been playing with (and yes, my
inline processor is synchronously coded at the moment, but obviously
it could be made asynchronous easily with that as a starting point)

from("seda:test").to("jms:queue:a.test");

        from("jms:queue:a.test")

                .process(new AsyncProcessor() {
                    @Override public boolean process(final Exchange
exchange, final AsyncCallback callback) {
                        String body = exchange.getIn().getBody(String.class);
                        exchange.getOut().setBody("echo: " + body);

                        bool sync = true;
                        callback.done(sync);
                        return sync;
                    }

                    @Override public void process(final Exchange
exchange) throws Exception {

                    }
                });


I am thinking it's incorrect to use SEDA as a client endpoint, though,
because I find it only works if it's blocking synchronously on the
client side. (or am I wrong?)

I have no specific interest in using SEDA, I just want to use an
interface on the client side that allows me to fire off an exchange,
and get a callback later.  I thought SEDA was generally 'asynchronous'
so I started there.

Any suggestions for sending the message off?

Reply via email to