Hi
If you are using ProducerTemplate, you should use the request* method
instead of send method.
The ProducerTemplate will set the ExchangePattern to be InOut in that
kind of method.
On 10/27/11 6:05 AM, Calvert, Zach (Zach)** CTR ** wrote:
Just in case anyone cares, the problem was not the route, or the way I was
sending, but the configuration of the exchange.
I didn't realize the route didn't define the InOut protocol, but you must set
exchange.setPattern(ExchangePattern.InOut);
Zach Calvert
-----Original Message-----
From: Calvert, Zach (Zach)** CTR ** [mailto:[email protected]]
Sent: Wednesday, October 26, 2011 2:09 PM
To: [email protected]
Subject: Synchronous Message
I'm using ServiceMix version 4.3.0 and simply trying to send a synchronous
message where I can get access to the MessageOut at the end.
I have tried using the ProducerTemplate as well as the
camelContext.getEndpoint("myendpoint").createProducer().process(exchange);
And nothing seems to fully fit my needs.
Making the assumption I have a properly constructed exchange, endpoint,
camelContext, producerTemplate, I have the following examples and why they
don't work the way I need them to:
Example 1:
producer.send(exchange); // doesn't work because it doesn't block. The
MessageOut doesn't contain the true message out body
Example 2:
endpoint.createProducer().process(exchange); // doesn't block
Example 3:
producer.sendBodyAndHeaders(endpoint, "body", headersMap); // blocks, but
I can't get a handle to the MessageOut from the exchange, just the body - and yes I have
confirmed the body is correct so the endpoints really are behaving the way I expect
Example 4:
Future<Exchange> result = producer.asyncSend(endpoint, exchange);
Exchange idealResult = result.get(); // doesn't actually block and my
code is instant, Exchange isn't populated with MessageOut
When I say these things aren't blocking, I'm reviewing the logs and making sure
that it really is not blocking. Ideally, I have a producer.send message which
actually blocks and then I can get the various messages after the processing is
complete. What am I missing?
Thanks,
Zach Calvert
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang