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

Wrong polling camel-spring-rabbitmq consumer onexception behavior

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Information Provided
    • 3.11.3
    • None
    • camel-spring
    • None
    • Java 11, Karaf 4.2.9

    • Unknown

    Description

      Hello,

      I am checking 2 simple routes. First one is:

      <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 blueprint-1.0.0.xsd ">
          <bean id="rabbitConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
            <property name="uri" value="amqp://localhost:5672"/>
            <property name="username" value="guest"/>
            <property name="password" value="guest"/>
          </bean>    <camelContext
              xmlns="http://camel.apache.org/schema/blueprint"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://camel.apache.org/schema/blueprint camel-blueprint-3.4.5.xsd">        <route id="consume">            <from uri="spring-rabbitmq:ex1?queues=bar&prefetchCount=1" />
                  <onException>
                      <exception>java.lang.Exception</exception>
                      <redeliveryPolicy maximumRedeliveries="2" redeliveryDelay="10000" retryAttemptedLogLevel="WARN"/>
                      <handled><constant>true</constant></handled>
                      <to uri="direct:error" />
                  </onException>            <log message=">>>Consumer start"/>            <throwException exceptionType="java.lang.NullPointerException"
                                      message="Not supported, sorjan"/>            <log message=">>>Body:  ${body}"/>
                  <log message=">>>Headers:  ${headers}"/>
                  <when>
                      <simple>${body} == null</simple>
                      <log message=">>>@@@@@@@@@@@@@@@@@@@@@@ Body is null!!!!"/>
                  </when>
                  
              </route>        <route>
                  <from uri="direct:error" />
                  <log message=">>>Error happens body:  ${body}"/>
              </route>    </camelContext>
      </blueprint>

      In this case a message from a queue is marked unacknowledged until the very end - after all redelivery attempts have fired. By the other hand, if I use polling consumer - like this:

      <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 blueprint-1.0.0.xsd ">
          <bean id="rabbitConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
            <property name="uri" value="amqp://localhost:5672"/>
            <property name="username" value="guest"/>
            <property name="password" value="guest"/>
          </bean>    <camelContext
              xmlns="http://camel.apache.org/schema/blueprint"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://camel.apache.org/schema/blueprint camel-blueprint-3.4.5.xsd">        <route id="consume">
                  <from uri="timer:consume?period=60000" />
                  <onException>
                      <exception>java.lang.Exception</exception>
                      <redeliveryPolicy maximumRedeliveries="2" redeliveryDelay="10000" retryAttemptedLogLevel="WARN"/>
                      <handled><constant>true</constant></handled>
                      <to uri="direct:error" />
                  </onException>
                  <log message=">>>Consumer start"/>            <pollEnrich>
                      <constant>spring-rabbitmq:ex1?queues=bar&prefetchCount=1&acknowledgeMode=MANUAL</constant>
                  </pollEnrich>            <throwException exceptionType="java.lang.NullPointerException"
                                      message="Not supported, sorjan"/>
                  <log message=">>>Body:  ${body}"/>
                  <log message=">>>Headers:  ${headers}"/>
                  <when>
                      <simple>${body} == null</simple>
                      <log message=">>>@@@@@@@@@@@@@@@@@@@@@@ Body is null!!!!"/>
                  </when>
                  
              </route>        <route>
                  <from uri="direct:error" />
                  <log message=">>>Error happens body:  ${body}"/>
              </route>    </camelContext>
      </blueprint>

      In this case a message is disappeared from a queue immediately after pollEnrich without intermediate unacknowledged mark. 

      I think this behavior is not 100% correct. 

      P.s. Sorry - I used a wrong component in this ticket description cause camel-spring-rabbitmq is not in the list.

      Attachments

        Activity

          People

            Unassigned Unassigned
            afilippov Andrey Filippov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: