Hi Vishvesh,

You could implement the desired use case using Correlation Id, which could be 
propagated along
with request to Kafka topic (using headers fe). Using this Correlation Id, the 
responses could be 
published to Kafka topic, and later matched to the request.

For JAR-RS, it is even simpler, since you have ContainerResponseFilter [1] and 
ContainerRequestFilter [2], 
which include Request and Response contexts. I think the CXF does not bundle 
the illustrative example 
for your case (guys please correct me if I am wrong), but the idea is pretty 
simple: associate the 
Correlation Id with request context and than match it with response. So you 
basically have a single 
class to manage that (as you initially intended I believe). Hope it helps, 
thank you.

[1] 
https://docs.oracle.com/javaee/7/api/javax/ws/rs/container/ContainerResponseFilter.html
[2] 
https://docs.oracle.com/javaee/7/api/javax/ws/rs/container/ContainerRequestFilter.html

Best Regards,
    Andriy Redko


VY> Hi Redko ,


VY>  Thanks a ton for the quick reply .
VY>  Actually I already have gone through that link before writing to the 
community, but as  I am very new to the cxf Interceptor so not exactly sure how 
it can help me.


VY>  Here is my full scenario.


VY>  "I have an application consisting of  bunch of services written in JAX-RS 
which in return gives the output in
VY> JSON. Now I have to run two different instances of this application each 
connecting to a different vendor of
VY> database , one is connecting with SQL  Server and the other instance with 
IBM DB2. Now the initial ask was to
VY> capture all the http requests with all its details whatsoever was made on 
the instance with  SQL Server and replay
VY> the captured http requests on to the other instance i.e. the one running  
with IBM DB2 . I achieved this by writing
VY> a custom Interceptor extended from AbstractPhaseInterceptor and inside my 
custom interceptor I captured all the
VY> required details created a POJO out of it and pushed that POJO to a Kakfa 
Topic, on the other instance  the same
VY> kafka topic was been listened and the same http  requests were made, the 
journey so far was easier.


VY>  Now along with the existing details I also have to capture the http 
responses of those http requests so that the
VY> behavior can be tested that both of the instances are in sync and 
responding in the same manner. So basically in my
VY> POJO to kafka queue along with  the existing details I also have to add 
their corresponding http responses , and
VY> that's the thing where I am stuck and seeking assistance for."




VY>  Cheers
VY>  Vishvesh




VY> From: Andriy Redko <[email protected]>
VY> Sent: Saturday, August 24, 2019 9:24 PM
VY> To: Vishvesh Yadav <[email protected]>; [email protected] 
<[email protected]>; [email protected] <[email protected]>
VY> Subject: Re: Need help to capture both HTTP Request and its Corresponding 
HTTP Response inside same Interceptor
VY>  
VY> Hi Vishvesh,

VY>  I assume you are asking about JAX-WS/SOAP, you may find this mail thread 
relevant [1], thank you.

VY>  [1]  
http://cxf.547215.n5.nabble.com/Log-incoming-message-with-the-corresponding-response-td5763314.html

VY>  Best Regards,
VY>      Andriy Redko

 VY>> Hi Team,

 VY>> I have a use case in which I have been asked to capture all  HTTP 
Requests and their corresponding HTTP Responses inside an interceptor.
 VY>> I referred various online links but of no use.
 VY>> If possible can you please help me with how it can be achieved using a 
single apache cxf interceptor.

 VY>> Please let me know if I am not clear with the requirement.

 VY>> Cheers,
 VY>> Vishvesh


Reply via email to