9 Replies Latest reply on Jun 21, 2012 1:19 AM by afilipchik

    Drools and Camel

    wbailey

      Hi,

       

      I'm evaluating the drools functionality of Fuse ESB enterprise, but I'm having a few problems getting it to work.

       

      I have defined a drools endpoint in a jbi service unit as follows:

       

       

       

      I've tried several variations of the to:uri but camel fails to locate the drools endpoint. I am missing something obvious?

       

      I've tried searching for examples on the web but am struggling to find any substantial documentation related to Fuse, camel and drools. Does anyone know of any?

        • 1. Re: Drools and Camel
          ffang

          Hi,

           

          In this case you need use camel-jbi component to route message in camel router to jbi endpoint, take a look at to get more details

           

          http://camel.apache.org/jbi.html

          Freeman

          • 2. Re: Drools and Camel
            wbailey

            Thanks for that, it's very helpful.  The thing I'm confused about is that I don't have a jbi endpoint, I have a drools endpoint. Therefore do I need to wrap up the drools endpoint as a JBI endpoint using a from tag?

             

            e.g  

             

            • 3. Re: Drools and Camel
              ffang

              Hi,

               

               

              should be fine.

               

              Freeman

              • 4. Re: Drools and Camel
                wbailey

                I've actually tried that but it resulted in the following exception:

                 

                13:51:16,406 | ERROR | l Console Thread | BlueprintContainerImpl           | 9 - org.apache.aries.blueprint - 0.3.1.fuse-7-061 | Unable to start blueprint container for bundle fi-route-camel
                org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to intialize bean blueprintContext
                     at [19:org.apache.karaf.shell.console:2.2.5.fuse-7-061]
                        ...
                     at java.lang.Thread.run(Thread.java:619)[:1.6.0_19]
                Caused by: org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[endpoint:droolsTestService]. Reason: java.lang.NullPointerException
                     at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:381)
                        ...
                org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:638)[9:org.apache.aries.blueprint:0.3.1.fuse-7-061]
                     ... 33 more
                Caused by: java.lang.NullPointerException
                     at org.apache.servicemix.camel.JbiEndpoint$JbiProducer.start(JbiEndpoint.java:95)
                     at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59)
                     at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:379)
                     ... 104 more
                

                 

                • 5. Re: Drools and Camel
                  ffang

                  Hi,

                   

                  Per ,the JBI endpoint URI format should be one of

                  jbi:service:serviceNamespace[sep]serviceName[?options]

                  jbi:endpoint:serviceNamespace[sep]serviceName[sep]endpointName[?options]

                  jbi:name:endpointName[?options]

                   

                  ensure your configuration follow it.

                  http://camel.apache.org/jbi.html

                   

                  Freeman

                  • 6. Re: Drools and Camel
                    wbailey

                    I got this working but I had to invoke the drools endpoint via http using a http jbi service unit.

                     

                    To do this I created a drools endpoint in its own su:

                     

                     

                     

                    This means I can use the service mix drools engine, but I'm a little disappointed having to introduce another http hop. There must be a way to do this without using the jbi http su?

                     

                    Ideally I want to invoke the jbi endpoint directly from the camel context but everything I try doesn't work. Any help would be much appreciated.

                    • 7. Re: Drools and Camel
                      davsclaus

                      What version of Drools are you using?

                       

                      The Drools project has native Camel integration, so you ought to be able to leverage that without using JBI at all.

                      • 8. Re: Drools and Camel
                        ffang

                        Hi,

                         

                        Yeah, if you start a new project, you should use camel component instead but not the JBI component.

                         

                        Btw, I don't think you really need introduce another http hop if you use JBI,try the route like

                         

                         

                        as I mentioned before

                        Per ,the JBI endpoint URI format should be one of

                        jbi:service:serviceNamespacesepserviceName?options

                        jbi:endpoint:serviceNamespacesepserviceNamesependpointName?options

                        jbi:name:endpointName?options

                         

                        Here I just use the third format.

                        http://camel.apache.org/jbi.html

                        Freeman

                        • 9. Re: Drools and Camel
                          afilipchik

                          Just my 2 cents - are you sure Drools is OSGi compatible?

                           

                          I spent some time trying make drools-camel and drools-spring fully OSGi compatible but didn't find enough time to create required for submission unit tests

                           

                          You can find patches at https://github.com/afilipchik

                           

                          Maybe it is obsolete because of FAB, or maybe Jboss folks already pushed fix... Not sure there.