You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Rajiv Jacob Cheriyan <ra...@gmail.com> on 2018/01/15 17:16:38 UTC
Processor not setting headers
Hello,
I am not able to inject/modify headers in a processor using the below
spring dsl config. Could you please help in figuring out what I am doing
wrong?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:camel="
http://camel.apache.org/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:http="
http://cxf.apache.org/transports/http/configuration"
xmlns:de="http://abc.com/de/2012/02" xmlns:sec="
http://cxf.apache.org/configuration/security"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/configuration/security
http://cxf.apache.org/schemas/configuration/security.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<routeContext xmlns="http://camel.apache.org/schema/spring"
id="routes1">
<route id="sdPoll" de:name="Polling"
de:systemName="Polling" streamCache="true">
<from uri="timer://sdPoll?fixedRate=true&period=60000" />
<process ref="*refProcessor*" />
<to uri="http://dummyhost" />
<to uri="log:DEBUG?showBody=true&showHeaders=true" />
</route>
</routeContext>
<bean id="refProcessor"
class="com.abc.de.RefProcessor" />
</beans>
public class RefProcessor implements Processor {
private final Logger log = Logger.getLogger(RefProcessor.class);
@SuppressWarnings("unchecked")
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader("Authorization", "TODO");
exchange.getIn().setHeader("CamelHttpMethod", "POST");
exchange.getIn().setHeader("CamelHttpUri", "http://localhost:8280/api/check
");
exchange.getIn().setHeader("Content-Type", "application/json");
exchange.getIn().setHeader("Accept", "application/json");
exchange.getIn().setBody("TODO");
//exchange.getOut().setHeaders(exchange.getIn().getHeaders());
//exchange.getOut().setHeader("Authorization", "TODO");
//exchange.getOut().setBody("TODO");
}
}
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor
Elapsed (ms)
[sdPoll] [sdPoll] [timer://sdPoll?fixedRate=true&period=60000
] [ 21176]
[null] [onCompletion1 ] [onCompletion
] [ 106]
[sdPoll] [process7 ] [ref:refProcessor
] [ 21067]
[null] [process3 ] [ref:GenericErrorHandle
] [ 21016]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
Id ID-ABC-63143-1516034486954-0-2
ExchangePattern InOnly
*Headers {breadcrumbId=ID-ABC-63143-1516034486954-0-1,
CamelRedelivered=false, CamelRedeliveryCounter=0, firedTime=Mon Jan 15
11:41:31 EST 2018}*
* BodyType null*
* Body [Body is null]*
]
Java DSL seem to work though!
static RouteBuilder createRouteBuilder3() {
return new RouteBuilder() {
public void configure() {
from("timer://timer1?period=60000").process(new Processor() {
public void process(Exchange exchange) throws UnsupportedEncodingException {
exchange.getIn().setHeader("CamelHttpMethod", "POST");
exchange.getIn().setHeader("Content-Type", "application/json");
exchange.getIn().setHeader("Accept", "application/json");
exchange.getIn().setHeader("CamelHttpUri",
"http://localhost:8280/api/check");
exchange.getIn().setHeader("Authorization", "TODO");
exchange.getIn().setBody("TODO");
}
}).to("http://dummyhost").to("log:DEBUG?showBody=true&showHeaders=true");
}
};
}
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor
Elapsed (ms)
[route1 ] [route1 ] [timer://timer1?period=60000
] [ 86]
[route1 ] [process1 ] [RefProcessorCamel$3$1@258e2e41
] [ 6]
[route1 ] [to1 ] [http://dummyhost
] [ 76]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
Id ID-ABC-63940-1516036107063-0-2
ExchangePattern InOnly
Headers * {Accept=application/json, Authorization=TODO,
breadcrumbId=ID-NY-LRM-PC-214-63994-1516036220042-0-1,
CamelHttpMethod=POST, CamelHttpUri=http://localhost:8280/api/check
<http://localhost:8280/api/check>, CamelRedelivered=false,
CamelRedeliveryCounter=0, Content-Type=application/json, firedTime=Mon Jan
15 12:10:21 EST 2018}*
* BodyType String*
* Body TODO*
]
--