[I tried searching for "mongodb" in the archives and didn't see this.
Apologies if
I missed something.]
The insert option of the example at
https://github.com/apache/camel-examples/tree/main/examples/mongodb fails
as is. The problem appears to be that the log() call consumes the body from
the input stream, leaving an empty body for the to().
The problem is fixed if you move the log() call in
MongoDBInsertRouteBuilder.java to after the to() so the code looks like:
public class MongoDBInsertRouteBuilder extends RouteBuilder {
    @Override
    public void configure() {
        from("jetty:http://0.0.0.0:8081/hello";)

.to("mongodb:myDb?database=test&collection=test&operation=insert")
                .log("${body}")
                .setBody(simple("${body}"))
                ;
    }
}

David Yang
Computer Science

Reply via email to