[ 
https://issues.apache.org/jira/browse/CAMEL-8904?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ralf Steppacher updated CAMEL-8904:
-----------------------------------
    Description: 
When using the {{netty4-http}} component as a producer, the response from the 
remote server is processed in a different thread ({{... yClientTCPWorker}}) 
than the start of the Camel route and thus the breadcrumb ID changes (because 
the MDC context changes/is lost).

{code}
2015-06-25 09:55:40,887 | INFO  | entExecutorGroup | pep-xds_b-repository       
      | 70 - org.apache.camel.camel-core - 2.14.1 | 
ID-ptl9921-45465-1435218175846-9-29  | Call to repository received.
-- remote call; the next line is logged after the response was received -- 
2015-06-25 09:55:41,155 | INFO  | yClientTCPWorker | AuditLogger                
      | 168 - ch.vivates.ams.pep - 3.0.1.SNAPSHOT | 
ID-ptl9921-45465-1435218175846-9-33  | User id: ...
2015-06-25 09:55:41,171 | INFO  | EVENTS.USER.XDS] | route_xds_b-activity       
      | 70 - org.apache.camel.camel-core - 2.14.1 | 
ID-ptl9921-45465-1435218175846-9-33  | Logging XDS event: ...
{code}

In the example above the breadcrumb changes from 
{{ID-ptl9921-45465-1435218175846-9-29}} to 
{{ID-ptl9921-45465-1435218175846-9-33}}.

If I use http4 as the producer the breadcrumb is the same for all route steps. 
Presumably because the same thread executes all route steps. 

Route that reproduces the issue for me:

{code:xml}
<route>
        <from 
uri="netty4-http:http://{{pep.host}}:{{pep.xds.b.repository.port}}/XDS3/repository?matchOnUriPrefix=true&amp;disableStreamCache=true";
 />
        <log message="Call to repository received." loggingLevel="INFO" 
logName="pep-xds_b-repository" />
        <process ref="repositoryInboundProcessor" />
        <to 
uri="netty4-http:http://{{xds.b.repository.host}}:{{xds.b.repository.port}}/XDS3/repository?bridgeEndpoint=true&amp;throwExceptionOnFailure=false&amp;disableStreamCache=true";
 />
        <process ref="repositoryOutboundProcessor" />
</route>

<onCompletion mode="AfterConsumer" parallelProcessing="false">
        <process ref="forkJoinProcessor" />
        <bean ref="auditLogger" method="localAuditXDS" />
        <bean ref="auditLogger" method="createCommandUserLogXDS" />
        <setExchangePattern pattern="InOnly" />
        <to uri="activemq:queue:{{activemq.queue.events.user.xds}}" />
</onCompletion>{code}

The {{repositoryOutboundProcessor}} and the {{onCompletion}} parts log a 
different breadcrumb (and thread name) than the beginning of the route before 
the {{<to uri="netty4-http:http:// ...}} step.

  was:
When using the {{netty4-http}} component as a producer, the response from the 
remote server is processed in a different thread ({{... yClientTCPWorker}}) 
than the start of the Camel route and thus the breadcrumb ID changes (because 
the MDC context changes/is lost).

{code}
2015-06-25 09:55:40,887 | INFO  | entExecutorGroup | pep-xds_b-repository       
      | 70 - org.apache.camel.camel-core - 2.14.1 | 
ID-ptl9921-45465-1435218175846-9-29  | Call to repository received.
-- remote call; the next line is logged after the response was received -- 
2015-06-25 09:55:41,155 | INFO  | yClientTCPWorker | AuditLogger                
      | 168 - ch.vivates.ams.pep - 3.0.1.SNAPSHOT | 
ID-ptl9921-45465-1435218175846-9-33  | User id: ...
2015-06-25 09:55:41,171 | INFO  | EVENTS.USER.XDS] | route_xds_b-activity       
      | 70 - org.apache.camel.camel-core - 2.14.1 | 
ID-ptl9921-45465-1435218175846-9-33  | Logging XDS event: ...
{code}

In the example above the breadcrumb changes from 
{{ID-ptl9921-45465-1435218175846-9-29}} to 
{{ID-ptl9921-45465-1435218175846-9-33}}.

If I use http4 as the producer the breadcrumb is the same for all route steps. 
Presumably because the same thread executes all route steps. 

Route that reproduces the issue for me:

{code:xml}
<route>
        <from 
uri="netty4-http:http://{{pep.host}}:{{pep.xds.b.repository.port}}/XDS3/repository?matchOnUriPrefix=true&amp;disableStreamCache=true";
 />
        <log message="Call to repository received." loggingLevel="INFO" 
logName="pep-xds_b-repository" />
        <process ref="repositoryInboundProcessor" />
        <to 
uri="netty4-http:http://{{xds.b.repository.host}}:{{xds.b.repository.port}}/XDS3/repository?bridgeEndpoint=true&amp;throwExceptionOnFailure=false&amp;disableStreamCache=true";
 />
        <process ref="repositoryOutboundProcessor" />
</route>

<onCompletion mode="AfterConsumer" parallelProcessing="false">
        <process ref="forkJoinProcessor" />
        <bean ref="auditLogger" method="localAuditXDS" />
        <bean ref="auditLogger" method="createCommandUserLogXDS" />
        <setExchangePattern pattern="InOnly" />
        <to uri="activemq:queue:{{activemq.queue.events.user.xds}}" />
</onCompletion>{code}

The {{repositoryOutboundProcessor}} and the {{onCompletion}} parts log a 
different breadcrumb (and thread name) than the beginning of the route before 
the {{<to uri="netty4-http:http:// ...}}.


> Breadcrumb ID changes when using netty4-http as a producer
> ----------------------------------------------------------
>
>                 Key: CAMEL-8904
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8904
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-netty4-http
>    Affects Versions: 2.14.1
>            Reporter: Ralf Steppacher
>            Assignee: Claus Ibsen
>
> When using the {{netty4-http}} component as a producer, the response from the 
> remote server is processed in a different thread ({{... yClientTCPWorker}}) 
> than the start of the Camel route and thus the breadcrumb ID changes (because 
> the MDC context changes/is lost).
> {code}
> 2015-06-25 09:55:40,887 | INFO  | entExecutorGroup | pep-xds_b-repository     
>         | 70 - org.apache.camel.camel-core - 2.14.1 | 
> ID-ptl9921-45465-1435218175846-9-29  | Call to repository received.
> -- remote call; the next line is logged after the response was received -- 
> 2015-06-25 09:55:41,155 | INFO  | yClientTCPWorker | AuditLogger              
>         | 168 - ch.vivates.ams.pep - 3.0.1.SNAPSHOT | 
> ID-ptl9921-45465-1435218175846-9-33  | User id: ...
> 2015-06-25 09:55:41,171 | INFO  | EVENTS.USER.XDS] | route_xds_b-activity     
>         | 70 - org.apache.camel.camel-core - 2.14.1 | 
> ID-ptl9921-45465-1435218175846-9-33  | Logging XDS event: ...
> {code}
> In the example above the breadcrumb changes from 
> {{ID-ptl9921-45465-1435218175846-9-29}} to 
> {{ID-ptl9921-45465-1435218175846-9-33}}.
> If I use http4 as the producer the breadcrumb is the same for all route 
> steps. Presumably because the same thread executes all route steps. 
> Route that reproduces the issue for me:
> {code:xml}
> <route>
>       <from 
> uri="netty4-http:http://{{pep.host}}:{{pep.xds.b.repository.port}}/XDS3/repository?matchOnUriPrefix=true&amp;disableStreamCache=true";
>  />
>       <log message="Call to repository received." loggingLevel="INFO" 
> logName="pep-xds_b-repository" />
>       <process ref="repositoryInboundProcessor" />
>       <to 
> uri="netty4-http:http://{{xds.b.repository.host}}:{{xds.b.repository.port}}/XDS3/repository?bridgeEndpoint=true&amp;throwExceptionOnFailure=false&amp;disableStreamCache=true";
>  />
>       <process ref="repositoryOutboundProcessor" />
> </route>
> <onCompletion mode="AfterConsumer" parallelProcessing="false">
>       <process ref="forkJoinProcessor" />
>       <bean ref="auditLogger" method="localAuditXDS" />
>       <bean ref="auditLogger" method="createCommandUserLogXDS" />
>       <setExchangePattern pattern="InOnly" />
>       <to uri="activemq:queue:{{activemq.queue.events.user.xds}}" />
> </onCompletion>{code}
> The {{repositoryOutboundProcessor}} and the {{onCompletion}} parts log a 
> different breadcrumb (and thread name) than the beginning of the route before 
> the {{<to uri="netty4-http:http:// ...}} step.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to