2016-03-12 34 views
3

我有一个CXF端点的最小骆驼路线(在RouteBuilder#配置方法):Apache的骆驼CxfRsEndpoint performInvocation设置触发调用两次

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#邮报” 的方法:

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

它得到invoced两次:断点被击中两次,响应有效载荷

{ 
    "id" : "id_from_client" 
} 

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

这是预期的行为?如果是,是否有设置只执行一次该方法?这对我来说似乎是一个错误。驼峰版本是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)

+0

FWIW,我有完全相同的问题。如果我找到任何类型的解决方案,将在这里更新。 – mindcrime

回答

2

FWIW,我改变了我的配置与“performInvocation =真”和双电话就走了一起添加了“同步=真正的”选项。我不知道这是它应该如何表现与否,但现在它似乎工作确定这种方式。

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

似乎罚款,我猜。只有在同步路由中,系统才能知道以前通过的交换机的任何信息。异步路由应该是无状态的。至少我能理解这一点。我很想在文档中找到一些链接。 –