Over a million developers have joined DZone.

Apache CXF: How Message Processing Happens and What’s the Role of Interceptor?

Is iPaaS solving the right problems? Not knowing the fundamental difference between iPaaS and dPaaS could cost you down the road. Brought to you in partnership with Liaison Technologies.

When a Apache CXF developed consumer invokes a remote service the following message processing sequence is started:

1. The Apache CXF runtime creates an outbound interceptor chain to process the request.

2. If the invocation starts a two-way message exchange, the runtime creates an inbound interceptor chain and a fault processing interceptor chain.

3. The request message is passed sequentially through the outbound interceptor chain. Each interceptor in the chain performs some processing on the message. For example, the Apache CXF supplied SOAP interceptors package the message in a SOAP envelope.

4. If any of the interceptors on the outbound chain create an error condition the chain is unwound and control is returned to the application level code. An interceptor chain is unwound by calling the fault processing method on all of the previously invoked interceptors. 5. The request is dispatched to the appropriate service provider.

6. When the response is received, it is passed sequentially through the inbound interceptor chain.
Note: If the response is an error message, it is passed into the fault processing interceptor chain.

7. If any of the interceptors on the inbound chain create an error condition, the chain is unwound.

8. When the message reaches the end of the inbound interceptor chain, it is passed back to the application code.

 


When a Apache CXF developed service provider receives a request from a consumer, a similar process takes place:

1. The Apache CXF runtime creates an inbound interceptor chain to process the request message.

2. If the request is part of a two-way message exchange, the runtime also creates an outbound interceptor chain and a fault processing interceptor chain.

3. The request is passed sequentially through the inbound interceptor chain.

4. If any of the interceptors on the inbound chain create an error condition, the chain is unwound and a fault is dispatched to the consumer. An interceptor chain is unwound by calling the fault processing method on all of the previously invoked interceptors.

5. When the request reaches the end of the inbound interceptor chain, it is passed to the service implementation.

6. When the response is ready it is passed sequentially through the outbound interceptor chain.
Note: If the response is an exception, it is passed through the fault processing interceptor chain.

7. If any of the interceptors on the outbound chain create an error condition, the chain is unwound and a fault message is dispatched.

8. Once the request reaches the end of the outbound chain, it is dispatched to the consumer.

 

Message Flow On Server Side

 

Message Flow On Client Side

Discover the unprecedented possibilities and challenges, created by today’s fast paced data climate and why your current integration solution is not enough, brought to you in partnership with Liaison Technologies.

Topics:
java,enterprise-integration,theory,apache,apache cxf

Published at DZone with permission of Singaram Subramanian, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}