Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-18791

MDC logging not work after JMS Consumer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Not A Bug
    • 3.18.3
    • None
    • camel-jms
    • None
    • Unknown

    Description

      The MDC logging in connection with the JMS component does not work properly. Although MDC logging is switched on in the CamelContext and MDC logging has been configured, the log file is not filled. During further tests I found out that logging only works if the first JMS message is sent from the same CamelContext.  Unfortunately, it is out of the question for us to change the JMS component to synchronous operation.  I hope my hint helps you to fix the component.

      blueprint.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                                     http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint-3.18.2.xsd">    <reference id="artemisCF" interface="javax.jms.ConnectionFactory" filter="(osgi.jndi.service.name=artemis)" />    <bean id="jmsTxManager" class="org.springframework.jms.connection.JmsTransactionManager">
              <property name="connectionFactory" ref="artemisCF" />
          </bean>    <bean id="PROPAGATION_REQUIRED" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
              <property name="transactionManager" ref="jmsTxManager" />
          </bean>    <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
              <property name="connectionFactory" ref="artemisCF" />
              <property name="transactionManager" ref="jmsTxManager" />
              <property name="transacted" value="false" />
          </bean>
              <camelContext id="testCamelContext" useMDCLogging="true" autoStartup="true" xmlns="http://camel.apache.org/schema/blueprint">        <!-- mdc logging works only if the send route in the same camel context! -->
              <route id="send-to-queue">
                  <from uri="timer:TestTimer?repeatCount=1" />
                  <setBody>
                      <constant>my message</constant>
                  </setBody>
                  <to uri="jms:queue:myqueue?connectionFactory=artemisCF" />
              </route>
              
              <route id="read-from-queue">
                  <from uri="jms:queue:myqueue?concurrentConsumers=3" />            <transacted />            <to uri="mock:end" />
              </route>
          
      </blueprint> 

       
       
       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            delphisual Alexander Domke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: