I am migrating from Camel 2.X to 3.x. Before, I used to do the following in Java DSL:
rest().post().route().log().convertBodyTo().process().endRest();
Essentially I can do anything I would normally do in a from, in a rest. In Camel 3, I have to split the above into two configs: one rest and one from:
rest().post().to(“fromRoute”);
from(“fromRoute”).log().convertBodyTo().process();
I was having trouble finding documentation on this change and the migration page camel gives does not mention this to my knowledge.
Is the former REST route definition done in Camel 2 just not a best practice? Is splitting the routes like I did the way forward in Camel 3? Any insight on best practices here or just the correct way to define REST endpoints in camel 3 would be greatly appreciated
Since Camel 3.16.0, you cannot embed routes into the REST DSL. The change was documented in the upgrade guide here:
There's some brief background to the change in a Jira ticket:
https://issues.apache.org/jira/browse/CAMEL-17675
The correct way to configure things is as per your code example where you link the REST DSL to a route via direct
etc. E.g.
rest().post().to("direct:start");
from("direct:start").log("Got body: ${body}");