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)

Kenster
  • 23,465
  • 21
  • 80
  • 106

1 Answers1

3

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" />
mindcrime
  • 657
  • 8
  • 23
  • seems fine, I guess. Only on sychronous routing the system can know anything about the exchanges having passed through before. Asynchronous routing should be stateless. At least I can make sense of that. I would love to find something in the documentation to link it here. – Stefan Maler Mar 25 '16 at 12:58