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

CamelBeanPostProcessor fails if @Producer is used in EventNotifier

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      If you use a @Produce annotation in an EventNotifier Camel fails at startup.

      Reproducable with: Custom EventNotifier in a plain Camel + Springboot Routebuilder.
      I have reproduced it with the spring boot example: https://github.com/apache/camel-spring-boot-examples/tree/main/spring-boot and added the EventNotifier below.
       
      Fails since Camel > 3.11
       
      Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error post processing bean: testEventNotifier; nested exception is java.lang.NullPointerException
      ....
      Caused by: org.springframework.beans.factory.BeanCreationException: Error post processing bean: testEventNotifier; nested exception is java.lang.NullPointerException
      at org.apache.camel.spring.spi.CamelBeanPostProcessor.postProcessBeforeInitialization(CamelBeanPostProcessor.java:160) ~[camel-spring-3.14.0.jar:3.14.0]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[spring-beans-5.3.14.jar:5.3.14]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.3.14.jar:5.3.14]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.14.jar:5.3.14]
      ... 122 common frames omitted

       

       

      Example

      https://github.com/apache/camel-spring-boot-examples/tree/main/spring-boot and added the EventNotifier below.

      TestEventNotifier.java

       

      @Component
      public class TestEventNotifier extends EventNotifierSupport {

         @Produce("stream:out")
         TestProducer producer;

         @Override
         public void notify(CamelEvent event) throws Exception {
            System.err.println(event);
            //producer.publish("some notification");
         }
      }

      ---------------------------------------------------

      TestProducer.java:

      import org.apache.camel.InOnly;

      @InOnly
      public interface TestProducer {
         void publish(String event);
      }

       

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            rambichler Michael Rambichler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: