I have three camel routes running fine individually, I am trying to call second route once first route is complete, but some how it is not being initiated how event third route is running once I call second route using URL jetty:http://localhost:8181/mongoSelect
, I have no error on the console as well. I have already tried changing from("jetty:http://localhost:8181/mongoSelect")
with direct:
component, Please help me on this.
Constants
private static final String SOURCE = "file:\\workspace\\EmailResponseAutomationSTS\\response\\?noop=true";
private static final String DESTINATION = "mongodb:myDb?database=email_response&collection=emailResponse&operation=save";
private static final String QUERY_MONGO_DB = "mongodb:myDb?database=email_response&collection=emailResponse&operation=findAll";
First Route
from(SOURCE)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
final EmailResponseModel erm = new EmailResponseModel();
erm.setBody(exchange.getIn().getBody(String.class));
exchange.getIn().setBody(erm, DBObject.class);
}
})
.to(DESTINATION)
.end();
Second Route
from("jetty:http://localhost:8181/mongoSelect")
.to(QUERY_MONGO_DB)
.marshal(new JacksonDataFormat())
.to("direct:redis")
.end();
Third Route
from("direct:redis").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
final String name = exchange.getIn().getBody(String.class);
@SuppressWarnings({ "deprecation", "unchecked" })
List<BasicDBObject> obj = (List<BasicDBObject>) JSON.parse(name);
for(BasicDBObject model : obj) {
String s = model.getString("body");
jedis.set("mongoData", s);
}
jedis.close();
}
})
.end();
I have already tried this approach:
First Route
from(SOURCE)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
final EmailResponseModel erm = new EmailResponseModel();
erm.setBody(exchange.getIn().getBody(String.class));
exchange.getIn().setBody(erm, DBObject.class);
}
})
.to(DESTINATION)
.to("direct:mongoSelect")
.end();
Second Route
from("direct:mongoSelect")
.to(QUERY_MONGO_DB)
.marshal(new JacksonDataFormat())
.to("direct:redis")
.end();
UPDATE : Something strange is happening with my code, when I am calling second route from first route using direct:mongoSelect
component, control is moving in but there is no data in response from .to(QUERY_MONGO_DB)
, however if I am using from("jetty:http://localhost:8181/mongoSelect")
instead of from("direct:mongoSelect")
in second route, I am getting data in response.
First Route
from(SOURCE)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
final EmailResponseModel erm = new EmailResponseModel();
erm.setEmailBody(exchange.getIn().getBody(String.class));
exchange.getIn().setBody(erm, DBObject.class);
}
})
.to(DESTINATION)
.to("direct:mongoSelect");
Second Route
from("direct:mongoSelect")
.to(QUERY_MONGO_DB)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String srt = exchange.getIn().getBody(String.class);
exchange.getIn().setBody(srt, DBObject.class);
}
})
.to("direct:redis")
.end();