Apache CXF: How message processing happens and what’s the role of interceptor?


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

About these ads

3 comments

  1. [...] Apache CXF: How message processing happens and what’s the role of interceptor? (singztechmusings.wordpress.com) [...]

  2. [...] Apache CXF: How message processing happens and what’s the role of interceptor? (singztechmusings.wordpress.com) Share this:EmailPrintDiggStumbleUponFacebookTwitterRedditLinkedInLike this:LikeBe the first to like this post. [...]

  3. [...] Apache CXF: How message processing happens and what’s the role of interceptor? (singztechmusings.wordpress.com) [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 26 other followers

%d bloggers like this: