activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: [camel] How to use consumers producers
Date Thu, 19 Apr 2007 18:36:09 GMT
On 4/19/07, dr.jeff <> wrote:
> I have a SOAP client component that I am hooking up like this:
> from("queue:requests").to("soap.client:http://a.b.c:80/soap-service");
> from("soap.client:http://a.b.c:80/soap-service").to("queue.responses");
> (This is part of a bigger flow that is pulling in messages from a socket and
> putting them in the request queue, then looking at the responses and making
> decisions about eg. getting more messages.)
> The way I have gotten this to work is to make something that implements
> Consumer<Exchange>, Producer<Exchange>, saves the processor from
> createConsumer(), and does this:
>         public void process(Exchange exchange) {
>                 Message in = exchange.getIn();
>                 Object request = in.getBody();
>                 Object response = clientPort.someOperation(request); //call the SOAP
> service here
>                 Exchange exchange2 = endpoint.createExchange();
>                         Message out = exchange2.getIn();
>                         out.setBody(response);
>                         processor.process(exchange2);
>         }
> This all works, but it can't be right. What happened to getOut() for the
> first exchange? I't just ignored here.
> Surely I'm missing the intended way to use these components.

So first off; we've not got that many examples yet of request/response
style processing; so we might need to tidy a few things up in that
area - apologies; we should have that sorted soon.

Am thinking the processor of the clientPort, should put the output in
the exchange.getOut() like this...

public void process(Exchange exchange) {
               Message in = exchange.getIn();
               Object request = in.getBody();
               //call the SOAP service here
               Object response = clientPort.someOperation(request);

then thats the soap endpoint being processed.

then you could for example do


or whatever - basically passing the output of the soap client to some
external destination such as a file or jms queue or whatever.

If you use the direct: component (which Hiram just added if you're
watching the commit log)

then you could process the pipeline synchronously from the start.

e.g. if you had


and you then invoked things like this...

        CamelClient client = ...;
        Exchange exchange = client.send("direct:requests", new
Processor<Exchange>() {
            public void process(Exchange exchange) {
                // now lets fire in a message
                Message in = exchange.getIn();
				System.out.println("Received output: " + exchange.getOut().getBody());

i.e. with one exchange invoke an endpoint and extract the out body.

Does that help at all?


View raw message