Hello,
There is something i don't understand around conversion and loosing
modifications on my exchange (Camel 2.25.4)
NOTE : At the end of this mail, i put a simplified version of my code
and the traces.
My route basically does this :
1) from email with copyTo=outFolder&delete=true
2) process(myProcessor) : Inside this, i do some work, including some
modifications, eventually an override of copyTo, and finish with a call
of a RestWS (return (String)response).
3) .unmarshal(new JacksonDataFormat(Reply.class))
4) remaining steps (not important)
All the process is OK except 1 thing : in the traces, i see the
modifications on the exchange before the unmarshal, and the original
values are back after the unmarshall.
I want to keep the modified properties in the following steps of my
route.
Do you know how i can to it ?
Joël
---------------------------------------
from(imap://server?username=xxx&password=xxx©To=ACC/out&delete=true&unseen=false&folderName=ACC/in&mapMailMessage=false)
.routeId("mail-Reply")
.process(myProcessor)
.unmarshal(new JacksonDataFormat(Reply.class))
.choice()
.when(simple("${body.status} != 'OK'"))
.throwException(new MyException("Error"))
.end()
.transform(simple("${body.file.content}"))
.unmarshal().base64()
...
public class MyProcessor implements Processor {
@Override
public void process(Exchange exchange) {
IMAPMessage mainMessage =
exchange.getIn().getBody(IMAPMessage.class);
String htmlCode = extractHTML(mainMessage.getContent());
Map<String, String> extractedData = extractData(htmlCode);
exchange.getIn().setHeader("copyTo", "ACC/toCheck");
exchange.getIn().setHeader("subject", "body");
exchange.getProperties().putAll(extractedData);
String subject = (String) exchange.getIn().getHeader("subject");
String jsResponse = callOfA_REST_WebService()
exchange.getIn().setBody(jsResponse);
}
}
logs
You can see subject and copyTo in the 1st line, they disapears in the
next line.
12:17:21.768 [Camel (camel-1) thread #3 - imap://mail.nuvem.intra] INFO
org.apache.camel.processor.interceptor.Tracer -
ID-PCP48141-1664187007789-0-6 >>> (mail-Reply) Processor@0x432f2970 -->
unmarshal[org.apache.camel.component.jackson.JacksonDataFormat@207dd1b7]
<<< Pattern:InOnly, Headers:{Accept-Language=en-US, en-AU,
breadcrumbId=ID-PCP48141-1664187007789-0-6, Content-Language=en-US,
Content-Type=multipart/alternative;
boundary="...", copyTo=ACC/toCheck, Date=Fri, 26 Aug 2022 09:51:32
+0200, From="no-re...@xxx.be" <no-re...@xxx.be>, Message-ID=<6be3>,
MIME-Version=1.0, Received=[...], Subject=body,
Thread-Index=AdjRh0ZWl+D/M9njSGaY14JVfSU0xA==, Thread-Topic=mail
25/08/2022 14:05:03
, To="y...@yyy.be" <y...@yyy.be>, BodyType:String,
Body:{"id":"Corresp_Rest:064c","status":"OK","taskStatus":null,"messages":[""],"data":{"request_id":"Corresp_Rest:2","file":{"content":"JVBER...
[Body clipped after 1000 chars, total length is 109290]
12:17:21.786 [Camel (camel-1) thread #3 - imap://mail.nuvem.intra] INFO
org.apache.camel.processor.interceptor.Tracer -
ID-PCP48141-1664187007789-0-6 >>> (mail-Reply)
unmarshal[org.apache.camel.component.jackson.JacksonDataFormat@207dd1b7]
--> choice <<< Pattern:InOnly, Headers:{Accept-Language=en-US, en-AU,
Content-Language=en-US, Content-Type=multipart/alternative;
boundary="...", Date=Fri, 26 Aug 2022 09:51:32 +0200,
From="no-re...@xxx.be" <no-re...@xxx.be>, Message-ID=<6be3>,
MIME-Version=1.0, Received=[...
...], Subject=mail 25/08/2022 14:05:03,
Thread-Index=AdjRh0ZWl+D/M9njSGaY14JVfSU0xA==, Thread-Topic=mail
25/08/2022 14:05:03
, To="y...@yyy.be" <y...@yyy.be>, BodyType:be.myws.Reply,
Body:be.myws.Reply@6e6f51d7