驼峰 2.X 到 3.X REST 迁移

huangapple go评论58阅读模式
英文:

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。此更改已在升级指南中记录:

https://camel.apache.org/manual/camel-3x-upgrade-guide-3_16.html#_removed_support_for_embedded_routes

有关此更改的一些简要背景信息可以在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:

https://camel.apache.org/manual/camel-3x-upgrade-guide-3_16.html#_removed_support_for_embedded_routes

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}");

huangapple
  • 本文由 发表于 2023年3月4日 00:37:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75629686.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定