Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the asciidoc in the repository:

We got some classloader issue about the camel processor which after the JBI endpoint recently, so I add this entry for some explanation about it.

Here is a good code example to demo the thread context classloader in different processor after the jbi endpoint.

  .process(new ProcessA())
  // The thread context classloader is servicemix-camel component classloader
  .process(new ProcessB())
  // The thread context classloader is the myProviderService's servicemix component classloader

servicemix-camel component works as an adapter for camel and servicemix, so camel Jbi endpoint can talk with servicemix endpoint. As you know camel uses pipeline pattern to chain the processors and endpoints (which can act as consumer and producer) to together. In this way you can chain the different servicemix endpoint by using camel EIP routes.

Now back to the classloader issue, for the jbi endpoint in the routing rule, it acts as a camel producer which delegate the camel exchange to servicemix jms endpoint, and then calling the processor which is after the jbi endpoint like pipeline. Since servicemix component has its onw thread pool, and these thread pools' context classloader are set to be their component's classlaoder, you will find out the ProcessorA and ProcessorB are run with different thread, so it is not hard to explain why these processors have different thread context classloader.

But for you route application, you may need to use set the thread context loader to your own application classloader, so you may set the thread context classloader yourself in the ProcessA or ProcessB to get the everything work again. Please keep it in mind, you need set the thread context loader back when you finish your work, since you wouldn't want pollute the servicemix components thread pools' context classloader.

© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram