'Cannot get out messsage in Apache camel after using template.send()
There is a task that need to send parameters to third-part URL and get response from this URL . This Url using json header and the code is below:
public void processHandler(Exchange exchange) throws Exception {
logger.info("1111111");
ProducerTemplate template =exchange.getContext().createProducerTemplate();
template.getCamelContext().getGlobalOptions().put("http.proxyHost", "proxy.dst.com");
template.getCamelContext().getGlobalOptions().put("http.proxyPort", "8080");
Exchange exchange1 =template.send("http://uat.alphoa.dst.com/alphoa/app/ws/getCellpost",new Processor() {
public void process(Exchange exchange2) throws Exception {
exchange2.getIn().setHeader(Exchange.HTTP_QUERY, "{\"fsa\":\"60124285\"}");
exchange2.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
exchange2.getIn().setHeader(Exchange.CONTENT_TYPE,"application/json");
exchange2.getIn().setHeader(Exchange.CONTENT_ENCODING,"utf-8");
exchange2.getIn().setBody(exchange.getIn().getBody());
logger.info("out body:"+exchange.getOut().getBody());
}
});
logger.info("object:"+exchange1.getOut().getBody());
}
but, there is no out message
12:15:41.170 \[qtp752576078-53\] INFO com.alphoa.processor.TestProcessor - out body:null 12:15:41.171 \[qtp752576078-53\] INFO com.alphoa.processor.TestProcessor - object:null
And when I debug it, I found a message on it:
No body available of type: java.io.InputStream but has value:
FreeMthlyGiftAlertMsgIMSCriteria [fsa=111111] of type:
com.alphoa.api.criteria.FreeMthlyGiftAlertMsgIMSCriteria on: Message[].
Caused by: No type converter available to convert from type:
com.alphoa.api.criteria.FreeMthlyGiftAlertMsgIMSCriteria to the required type:
java.io.InputStream with value FreeMthlyGiftAlertMsgIMSCriteria [fsa=111111].
Exchange[ID-PCCWSCHN14D0006-1648528340913-4-4].
Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type
converter available to convert from type:
com.alphoa.api.criteria.FreeMthlyGiftAlertMsgIMSCriteria to the required type:
java.io.InputStream with value FreeMthlyGiftAlertMsgIMSCriteria [fsa=111111]]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
