Hello!

I wrote an log4j logging interceptor (in and out) because I need a unique message id push in the ThreadContext at the very begin, and pop this after the response sent back.

(if there any, please note me)

I started from the org.apache.cxf.ext.logging.LoggingInInterceptor, (to get the message direction: Request_in, Response_in, etc) In the inputInInterceptor i check this "direction", to see need to set the ThreadContext.

After the message processing, i noticed the interceptor runs again:
- in interceptor (logging) (LoggingInInterceptor)
- message processing
- in interceptor (again)
- out interceptor

From the log:
2020-07-03 22:40:24,663 [MsgID: a325ea47-a1a6-43bd-bcdc-248d0ede2e8a] [http-nio-8080-exec-3] [INFO ] <message processing> – finally
Chain org.apache.cxf.phase.PhaseInterceptorChain@202efe4. Current flow:
  receive [WireTapIn, LoggingInFaultInterceptor, PolicyInInterceptor, AttachmentInInterceptor]
  pre-stream [CertConstraintsInterceptor]
  post-stream [LoggingInInterceptor, StaxInInterceptor, PolicyBasedWSS4JStaxInInterceptor]   read [WSDLGetInterceptor, ReadHeadersInterceptor, SoapActionInInterceptor, StartBodyInterceptor, JavascriptGetInterceptor]   pre-protocol [MAPCodec, MEXInInterceptor, MustUnderstandInterceptor, PolicyBasedWSS4JInInterceptor]
  post-protocol [CheckFaultInterceptor]
  unmarshal [DocLiteralInInterceptor, SoapHeaderInterceptor]
  pre-logical [MAPAggregatorImpl, OneWayProcessorInterceptor]
  pre-invoke [SwAInInterceptor, PolicyVerificationInInterceptor]
  invoke [ServiceInvokerInterceptor, UltimateReceiverMustUnderstandInterceptor]
  post-invoke [OutgoingChainInterceptor, StaxInEndingInterceptor]

2020-07-03 22:40:24,664 [MsgID: a325ea47-a1a6-43bd-bcdc-248d0ede2e8a, MsgID: a325ea47-a1a6-43bd-bcdc-248d0ede2e8a] [http-nio-8080-exec-3] [INFO ] message.in.handleMessage()

I checked the config twice:
    <cxf:bus>
        <cxf:inInterceptors>
            <ref bean="loggingInInterceptor"/>
        </cxf:inInterceptors>
        <cxf:outInterceptors>
            <ref bean="loggingOutInterceptor"/>
        </cxf:outInterceptors>
        <cxf:outFaultInterceptors>
            <ref bean="loggingOutInterceptor"/>
        </cxf:outFaultInterceptors>
        <cxf:inFaultInterceptors>
            <ref bean="loggingInInterceptor"/>
        </cxf:inFaultInterceptors>
    </cxf:bus>


So: this LoggingInInterceptor must run twice? or i did some error?


Thanx

Csaba


Reply via email to