英文:
Camel 2.X to 3.X REST Migration
问题
我正在从Camel 2.X迁移到3.x。在以前的版本中,我通常在Java DSL中执行以下操作:
rest().post().route().log().convertBodyTo().process().endRest();
基本上,我可以在rest()
中执行任何我通常会在from()
中执行的操作。但在Camel 3中,我必须将上述代码分为两个配置:一个是rest()
,另一个是from()
:
rest().post().to("fromRoute");
from("fromRoute").log().convertBodyTo().process();
我很难找到关于这个变化的文档,而Camel提供的迁移页面似乎没有提到这一点,据我所知。
在Camel 2中的前一个REST路由定义是否不是最佳实践?在Camel 3中是否像我所做的那样分割路由是前进的方式?关于最佳实践或在Camel 3中定义REST端点的正确方式的任何见解将不胜感激。
英文:
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
答案1
得分: 3
自Camel 3.16.0版本开始,不再支持将路由嵌入REST DSL。此更改已在升级指南中记录:
有关此更改的一些简要背景信息可以在Jira工单中找到:
https://issues.apache.org/jira/browse/CAMEL-17675
正确的配置方法如下,与您的示例代码一致,通过direct
等方式将REST DSL连接到路由。例如:
rest().post().to("direct:start");
from("direct:start").log("Got body: ${body}");
英文:
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}");
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论