Discussion:
Two similar jersey flows behave differently, why?
Alex Thieme
2013-03-12 17:37:13 UTC
Permalink
I'm using Mule 3.3.0 (CE). Thanks in advance.

I have two flows that (by all accounts) are the same (except that they point to different components, to do different things).

Both have an http inbound-endpoint, both have an exchange-pattern equal to one-way, both point to a jersey resource component (a singleton object), both component classes have a class level @Path("/") annotation, both component classes have a public void method with a @Path("/global") annotation and both component class methods have an @PUT annotation.

However, only one of them works properly. The first one, when called, is invoked and returns immediately while the component processing proceeds (in the background). The other seems to not invoke at all. When I use curl to access the URL, if I Ctrl_C curl, only then is the component invoked. Lastly, if I change the second configuration exchange-pattern equal to request-response, then the component is invoked but the caller (curl) must wait until the process completes (as you would expect from request-response).

When accessing the first flow, I use the following command:

curl -X PUT http://0.0.0.0:51516/component/global

For logs, Mule first finds an entirely different flow ["score" is the first one in that configuration file with the same host:port], then it proceeds to try and find the correct flow.

[03-12 13:17:49] DEBUG ConnectNotifier [[sherlock-server].connector.http.mule.default.receiver.04]: Successfully connected to http://0.0.0.0:51516/score
[03-12 13:17:49] DEBUG HttpMessageReceiver [[sherlock-server].connector.http.mule.default.receiver.07]: /component/global
[03-12 13:17:49] DEBUG HttpMessageReceiver [[sherlock-server].connector.http.mule.default.receiver.07]: Secondary lookup of receiver on connector: connector.http.mule.default with URI key: http://0.0.0.0:51516/component/global
[03-12 13:17:49] DEBUG InterceptingChainLifecycleWrapper [[sherlock-server].connector.http.mule.default.receiver.07]: Invoking InterceptingChainLifecycleWrapper 'wrapper for InboundEndpoint 'http://0.0.0.0:51516/component' request chain'

When accessing the second (broken) flow, I use the following command:

curl -X PUT http://0.0.0.0:51515/component/global

From logs, Mule finds the correct flow, although perhaps that's because this configuration file contains only the one flow. Oddly enough, Mule claims to be reading a POST InputStream. This log statement does not exist (above) and again, I'm issuing a PUT call.

[03-12 13:14:14] DEBUG ConnectNotifier [[sherlock-server].connector.http.mule.default.receiver.06]: Successfully connected to http://0.0.0.0:51515/component
[03-12 13:14:14] DEBUG HttpMuleMessageFactory [[sherlock-server].connector.http.mule.default.receiver.07]: Reading HTTP POST InputStream into byte[] for asynchronous messaging.

After Ctrl+C, I see the following:

[03-12 13:26:26] DEBUG HttpMessageReceiver [[sherlock-server].connector.http.mule.default.receiver.08]: /component/global
[03-12 13:26:26] DEBUG HttpMessageReceiver [[sherlock-server].connector.http.mule.default.receiver.08]: Secondary lookup of receiver on connector: connector.http.mule.default with URI key: http://0.0.0.0:51515/component/global
[03-12 13:26:26] DEBUG InterceptingChainLifecycleWrapper [[sherlock-server].connector.http.mule.default.receiver.08]: Invoking InterceptingChainLifecycleWrapper 'wrapper for InboundEndpoint 'http://0.0.0.0:51515/component' request chain'

Here's part of the configuration and code that seems relevant. They differ only in the address (port) and component (class).

This configuration and code works.

<flow name="service.1">
<http:inbound-endpoint
address="http://0.0.0.0:51516/component"
exchange-pattern="one-way"/>
<jersey:resources>
<component>
<singleton-object class="com.ComponentA"/>
</component>
</jersey:resources>
</flow>

@Path("/")
public class ComponentA {
@PUT
@Path("/global")
public void global() throws Exception {
log.error("invoked.");
}
}

This configuration and code does not work properly.

<flow name="service.2">
<http:inbound-endpoint
address="http://0.0.0.0:51515/component"
exchange-pattern="one-way"/>
<jersey:resources>
<component>
<singleton-object class="com.ComponentB"/>
</component>
</jersey:resources>
</flow>

@Path("/")
public class ComponentB {
@PUT
@Path("/global")
public void global() throws Exception {
log.error("invoked.");
}
}
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...