You need to handle the exchange carefully, as the file will be moved when the exchange done is called. If you create a new exchange which is based on the old one, you need to call the below method to handover Completions.
       // Need to hand over the completion for async invocation
exchange.handoverCompletions(newExchange);
I didn't find the same code in your traceExchange method.
BTW, you don't need to create a new CamelContext in the traceExchange method, you can get a CamelContext for the exchange.

On Tue Dec 20 21:24:08 2011, ebinsingh wrote:
Hi Raul / William, Thanks for your help.

Actually sending the intercept to seda queue also did not do the trick. It
still messes up the original exchange.
I tried creating a new ProducerTemplate, but that also did not work.

If I just do a Stream:out (DSL) or System.out.print in (Java DSL) the
original Exchange does not change.

I tried doing the following.

1. Send the intercept to Seda Queue
2. Call the bean out from the above queue
3. Create an POJO bean from the information got from Exchange Headers
4. Create a ProducerTemplate out of the Exchange Context
5. Send the bean on this Producer to another seda Queue
6. Use JPA to persist the bean.

But doing all this still changes the Original Exchange (Code snippets
below).

                <interceptSendToEndpoint uri="jms:queue:test_request_1">
                <to uri="seda:traceQueue"/>
                </interceptSendToEndpoint>
                
                <route>
                        <from uri="seda:traceQueue"/>
                        <bean ref="marsTraceProcessor" method="traceExchange" />
                </route>

public void traceExchange(Exchange exchange) throws Exception {
                          CamelContext context = new DefaultCamelContext();
                ProducerTemplate prod = context.createProducerTemplate();
                
                prod.sendBody("seda:trace", entity);
}

                <route>
                        <from uri="seda:trace"/>
                        <log message="Persisting to Trace to Database" />
                        <to uri="jpa://com.vzw.fp.mars.entities.TracerEntity" />
                </route>


The only way I could do stuff without changing the original Exchange was by
using wireTap.
But the pitfall with this approach is that we duplicate the Exchange which
would lead to a memory issue.

Note: It was a silly mistaske which kept the file from being moved. I'd
fixed it.


--
View this message in context: 
http://camel.465427.n5.nabble.com/Intercept-issue-need-help-tp5080816p5088854.html
Sent from the Camel - Users mailing list archive at Nabble.com.




--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
        http://jnn.javaeye.com (Chinese)
Twitter: willemjiang Weibo: willemjiang

Reply via email to