Enterprise Integration Zone is brought to you in partnership with:

I'm Singaram Subramanian, and I work with CSC India as a Software Developer. My blog is an attempt to share my learnings with all (mainly, for those who desperately mine google finding ways to solve problems, fix issues, learn about a Java/Open source software, or deciding on tough choices etc. during software development as I do). Singaram is a DZone MVB and is not an employee of DZone and has posted 36 posts at DZone. You can read more from them at their website. View Full User Profile

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

07.03.2012
| 8965 views |
  • submit to reddit

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

Published at DZone with permission of Singaram Subramanian, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Saurabh Chhajed replied on Fri, 2014/05/23 - 9:14am

Thanks for this informative article on how CXF works internally.Very helpful!!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.