开发者

Camel CXF consumer, webservice method has no response

I'm trying to consume a webservice from camel using the cxf component, like this:

<cxf:cxfEndpoint id="webservice"
                 address="http://webservice.url.com/webservice"
                 serviceClass="com.url.webservice.MyWebService"/>

<camel:camelContext>
    <camel:route>
        <camel:from uri="direct:a"/>
      开发者_运维技巧  <camel:inOnly uri="cxf:bean:webservice?defaultOperationName=sendMessage"/>
    </camel:route>
</camel:camelContext>

The sendMessage method has no response, hence the inOnly rather than to (although I have the same problem when I try to instead). The problem is that apparently camel still expects a response, and the route hangs while waiting for one. I suppose if I let it try long enough, it would eventually time out.

To be clear, I'm running a test method:

/* ... */

@Produce(uri = "direct:a")
protected ProducerTemplate directA;

@Test
public void sendMessage() throws Exception {
    directA.sendBody(new String[] {"client id", "message"});
    directB.sendBody(new String[] {"client id", "message 2"});
}

And I'm seeing the effect of the first call (that is, the message arrives at the server), but not the second, and the method doesn't finish running (again, I'm assuming it'll timeout at some point... if so, the timeout's pretty long: I ran the test as I started writing this, and it's still running).

Am I missing something? Is it a bug? Is it just bad practice to have webservice methods with no response?

By the way, when testing methods which have a response, it works fine.


I think Willem Jiang recently fixed some issue with one-way CXF in Camel recently. Maybe try Camel 2.6-SNAPSHOT from trunk.

I personally prefer two-way with web services, just returning some ACK back in case there is no data to return back. The client most often want some confirmation the server has received and acknowledged the data.


camel-cxf producer decides if it will handle the response message by checking if the operation is oneway. Even the sendMessage operation is oneway invocation, your server should send Http states 202 message to the client according the HTTP protocol, otherwise camel-cxf producer will still wait for the response.

BTW, I think the issue[1] that Claus said was related to async invocation of camel-cxf producer with one way message, not sure if it's the same issue as you mentioned(I didn't know which version of camel are you using).

[1]https://issues.apache.org/jira/browse/CAMEL-3426

Willem

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜