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

CamelContext is not been set in VMConsumer when used with POJO @Consume



    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.17.4, 2.17.5, 2.18.1
    • 2.17.6, 2.18.3, 2.19.0
    • camel-core
    • None
    • Ubuntu 16.04, OpenJDK 1.7, OpenJDK 1.8, Spring 4.2.6.RELEASE

    • Unknown


      In Spring environment, DefaultCamelBeanPostProcessor relies on CamelPostProcessorHelper to inject consumer , when CamelPostProcessorHelper creates a VMConsumer from the endpoint based on the use of @Consume annotation, it then tries to start the consumer as a service.

      Because the consumer endpoint of @Consume was created using the camel context from CamelPostProcessorHelper, it puts the VMConsumer service in to deferred start until the camel context is finished starting. The service is ultimately been added to the DeferServiceStartupListener. Then the DeferServiceStartupListener tries to start the VMConsumer at a later stage. 2.17.3 and 2.18.0 does not suffer this problem.

      The problem is non of the process above has considered the fact that the VMConsumer is an instance of CamelContextAware and injects the correct camel context to it. This then leads to the VMConsumer tries to prepare the exchange with a null pointer reference as its camel context.

      Because the exchange now has null as camel context, a NPE is thrown at https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java#L519 when it tries to create the exchange id.

      This problem only happened after issue CAMEL-10406 is merged in


        1. CamelBeanPostProcessor_patchfile.diff
          4 kB
          Christopher Harris

        Issue Links



              davsclaus Claus Ibsen
              chrisjheap Christopher Harris
              1 Vote for this issue
              3 Start watching this issue