Apache Camel CxfRsEndpoint performInvocation设置触发两次调用(Apache Camel CxfRsEndpoint performInvocation setting triggers invocation twice)

我有一个带有cxf端点的最小camel路由(在RouteBuilder #configure方法中):

CxfRsComponent cxfComponent = new CxfRsComponent(context); CxfRsEndpoint serviceEndpoint = new CxfRsEndpoint("http:/localhost/rest", cxfComponent); serviceEndpoint.addResourceClass(PersonService.class); serviceEndpoint.setPerformInvocation(true); from(serviceEndpoint).log("this is irrelevant");

问题是资源类的方法被调用两次:

假设有一个“PersonService#post”方法:

public Person post(Person p){ p.setId(p.getId() + "_PersonService#post"); return p; }

它被调用两次:断点被击中两次,对有效负载的响应

{ "id" : "id_from_client" }

{ "id": "id_from_client_PersonService#post_PersonService#post" }

这是预期的行为吗? 如果是,是否有设置只执行一次方法? 这对我来说似乎是个错误。

Camel版本是2.16.2(maven:org.apache.camel:camel-cxf-transport:2.16.2)CXF版本是3.1.4(org.apache.cxf:cxf-rt-transports-http-jetty:3.1。 4)

I have a minimal camel route with a cxf endpoint (in a RouteBuilder#configure method):

CxfRsComponent cxfComponent = new CxfRsComponent(context); CxfRsEndpoint serviceEndpoint = new CxfRsEndpoint("http:/localhost/rest", cxfComponent); serviceEndpoint.addResourceClass(PersonService.class); serviceEndpoint.setPerformInvocation(true); from(serviceEndpoint).log("this is irrelevant");

The issue is that the methods of the resource class are called twice:

Let's say there is a "PersonService#post" method:

public Person post(Person p){ p.setId(p.getId() + "_PersonService#post"); return p; }

It gets invoced twice: breakpoints get hit twice, response for payload

{ "id" : "id_from_client" }

is

{ "id": "id_from_client_PersonService#post_PersonService#post" }

Is this expected behaviour? If yes, is there a setting to only execute the method once? This seems like a bug to me.

Camel version is 2.16.2 (maven: org.apache.camel:camel-cxf-transport:2.16.2) CXF version is 3.1.4 (org.apache.cxf:cxf-rt-transports-http-jetty:3.1.4)

最满意答案

FWIW,我更改了我的配置以添加“synchronous = true”选项以及“performInvocation = true”并且双重调用消失了。 我不确定这是不是应该如何表现,但是现在看起来好像这样。

<camel:from uri="cxfrs:bean:rsServer performInvocation=true&amp;synchronous=true" />

FWIW, I changed my configuration to add the "synchronous=true" option along with "performInvocation=true" and the double calls went away. I'm not sure if this is how it's supposed to behave or not, but for now it seems to work OK this way.

<camel:from uri="cxfrs:bean:rsServer performInvocation=true&amp;synchronous=true" />Apache Camel CxfRsEndpoint performInvocation设置触发两次调用(Apache Camel CxfRsEndpoint performInvocation setting triggers invocation twice)

我有一个带有cxf端点的最小camel路由(在RouteBuilder #configure方法中):

CxfRsComponent cxfComponent = new CxfRsComponent(context); CxfRsEndpoint serviceEndpoint = new CxfRsEndpoint("http:/localhost/rest", cxfComponent); serviceEndpoint.addResourceClass(PersonService.class); serviceEndpoint.setPerformInvocation(true); from(serviceEndpoint).log("this is irrelevant");

问题是资源类的方法被调用两次:

假设有一个“PersonService#post”方法:

public Person post(Person p){ p.setId(p.getId() + "_PersonService#post"); return p; }

它被调用两次:断点被击中两次,对有效负载的响应

{ "id" : "id_from_client" }

{ "id": "id_from_client_PersonService#post_PersonService#post" }

这是预期的行为吗? 如果是,是否有设置只执行一次方法? 这对我来说似乎是个错误。

Camel版本是2.16.2(maven:org.apache.camel:camel-cxf-transport:2.16.2)CXF版本是3.1.4(org.apache.cxf:cxf-rt-transports-http-jetty:3.1。 4)

I have a minimal camel route with a cxf endpoint (in a RouteBuilder#configure method):

CxfRsComponent cxfComponent = new CxfRsComponent(context); CxfRsEndpoint serviceEndpoint = new CxfRsEndpoint("http:/localhost/rest", cxfComponent); serviceEndpoint.addResourceClass(PersonService.class); serviceEndpoint.setPerformInvocation(true); from(serviceEndpoint).log("this is irrelevant");

The issue is that the methods of the resource class are called twice:

Let's say there is a "PersonService#post" method:

public Person post(Person p){ p.setId(p.getId() + "_PersonService#post"); return p; }

It gets invoced twice: breakpoints get hit twice, response for payload

{ "id" : "id_from_client" }

is

{ "id": "id_from_client_PersonService#post_PersonService#post" }

Is this expected behaviour? If yes, is there a setting to only execute the method once? This seems like a bug to me.

Camel version is 2.16.2 (maven: org.apache.camel:camel-cxf-transport:2.16.2) CXF version is 3.1.4 (org.apache.cxf:cxf-rt-transports-http-jetty:3.1.4)

最满意答案

FWIW,我更改了我的配置以添加“synchronous = true”选项以及“performInvocation = true”并且双重调用消失了。 我不确定这是不是应该如何表现,但是现在看起来好像这样。

<camel:from uri="cxfrs:bean:rsServer performInvocation=true&amp;synchronous=true" />

FWIW, I changed my configuration to add the "synchronous=true" option along with "performInvocation=true" and the double calls went away. I'm not sure if this is how it's supposed to behave or not, but for now it seems to work OK this way.

<camel:from uri="cxfrs:bean:rsServer performInvocation=true&amp;synchronous=true" />