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

EventNotifierSupport does not receive ExchangeSentEvents anymore

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Not A Problem
    • Affects Version/s: 2.20.1
    • Fix Version/s: 2.20.3, 2.21.0
    • Component/s: camel-core
    • Labels:
    • Estimated Complexity:
      Unknown

      Description

      I'm using an EventNotifier with Camel Spring, which is basically a copy of https://github.com/apache/camel/blob/f6ac3d81420d3f53b029a0f0c31dd4610810e2c2/camel-core/src/test/java/org/apache/camel/processor/MyLoggingSentEventNotifer.java

      After upgrading to Camel 2.20.1 from 2.19.1 it does not receive ExchangeSentEvents anymore. It is still picked up by Camel according to the log: org.apache.camel.core.xml.AbstractCamelContextFactoryBean - Using custom EventNotifier with id: myLoggingEventNotifier and implementation: test.MyLoggingSentEventNotifer@5f7b97da and ExchangeCreatedEvents, ExchangeSendingEvents, ExchangeCompletedEvents are received as before. Only ExchangeSentEvents are missing.

      Complete example to reproduce this issue:

      MyLoggingSentEventNotifer.java
      public class MyLoggingSentEventNotifer extends EventNotifierSupport {
      
          public void notify(EventObject event) throws Exception {
              if (event instanceof ExchangeSentEvent) {
                  ExchangeSentEvent sent = (ExchangeSentEvent) event;
                  log.info("Took {} millis to send to: {}", sent.getTimeTaken(), sent.getEndpoint());
              }
          }
      
          public boolean isEnabled(EventObject event) {
              return event instanceof ExchangeSentEvent;
          }
      
          protected void doStart() throws Exception {
          }
      
          protected void doStop() throws Exception {
          }
      }
      
      test-beans.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> 
          <bean id="myLoggingEventNotifier" class="test.MyLoggingSentEventNotifer" />
          <camelContext xmlns="http://camel.apache.org/schema/spring">
              <route>
                  <from uri="direct:start" />
                  <to uri="direct:bar" />
                  <to uri="mock:result" />
              </route>
              <route>
                  <from uri="direct:bar" />
                  <delay>
                      <constant>1000</constant>
                  </delay>
              </route>
          </camelContext>
      </beans>
      
      EventNotifierExchangeSentExampleTest.java
      @RunWith(CamelSpringRunner.class)
      @BootstrapWith(CamelTestContextBootstrapper.class)
      @ContextConfiguration(locations = {"classpath:/test-beans.xml"})
      public class EventNotifierExchangeSentExampleTest {
      
          @EndpointInject(uri = "direct:start")
          ProducerTemplate producer;
          @EndpointInject(uri = "mock:result")
          MockEndpoint out;
      
          @Test
          public void testExchangeSent() throws Exception {
              out.expectedMessageCount(1);
      
              producer.sendBody("Hello World");
      
              out.assertIsSatisfied();
          }
      }
      
      pom.xml
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <groupId>com.test</groupId>
          <artifactId>CamelSpringEventNotifierExchangeSentEventsBug</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <properties>
              <camel.version>2.20.1</camel.version>
              <!--  camel.version>2.19.1</camel.version -->
          </properties>
          <dependencies>
              <dependency>
                  <groupId>org.apache.camel</groupId>
                  <artifactId>camel-spring</artifactId>
                  <version>${camel.version}</version>
              </dependency>
              <dependency>
                  <groupId>org.apache.camel</groupId>
                  <artifactId>camel-test-spring</artifactId>
                  <version>${camel.version}</version>
              </dependency>
              <dependency>
                  <groupId>ch.qos.logback</groupId>
                  <artifactId>logback-classic</artifactId>
                  <version>1.2.2</version>
              </dependency>
          </dependencies>
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <version>3.7.0</version>
                      <configuration>
                          <source>1.8</source>
                          <target>1.8</target>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      </project>
      

      Complete code on github: https://github.com/PascalSchumacher/CamelSpringEventNotifierExchangeSentEventsBug
       
       

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              pascalschumacher Pascal Schumacher
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: