Pascal Schumacher created CAMEL-12184:
-----------------------------------------
Summary: Camel-Spring: EventNotifierSupport does not receive
ExchangeSentEvents anymore
Key: CAMEL-12184
URL: https://issues.apache.org/jira/browse/CAMEL-12184
Project: Camel
Issue Type: Bug
Components: camel-spring
Affects Versions: 2.20.1
Reporter: Pascal Schumacher
I'm using an EventNotifier with Camel Spring, which is basically a copy of
[{color:#0000FF}+https://github.com/apache/camel/blob/f6ac3d81420d3f53b029a0f0c31dd4610810e2c2/camel-core/src/test/java/org/apache/camel/processor/MyLoggingSentEventNotifer.java+{color}]
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 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:
{code:title=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 {
}
}
{code:title=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>
{code}
{code}
{code:title=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();
}
}
{code}
{code:title=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>
{code}
Complete Code on github:
https://github.com/PascalSchumacher/CamelSpringEventNotifierExchangeSentEventsBug
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)