2

Has anyone tried integrating Apache Camel with Drools Fusion or just Drools.

Following is my use case.

  • Get data from an external service using REST.
  • Filter the data (using rules defined in Drools.)
  • The data from the external service could also be a stream of information (e.g., Tweeter feed, real-time location of a user)

Any help or pointers would be appreciated.

Thanks.

Mat
  • 202,337
  • 40
  • 393
  • 406
Soumya Simanta
  • 11,523
  • 24
  • 106
  • 161

1 Answers1

6

Drools has a camel component. Using it is not much different than using any camel component.

source: https://github.com/droolsjbpm/droolsjbpm-integration/tree/master/drools-camel

binary (in the droolsjbpm-integration bundle): http://www.jboss.org/drools/downloads.html

The only thing to be "aware" of is that Drools can treat camel messages as:

  1. commands
  2. regular facts
  3. as-is objects and re-route then

Some articles:

http://blog.athico.com/search?q=camel

Documentation unfortunately only describes the "command" (1) use case:

http://docs.jboss.org/drools/release/5.4.0.Beta2/droolsjbpm-integration-docs/html/ch01.html

Some test cases you can use as examples for the use cases (2) and (3) above:

https://github.com/droolsjbpm/droolsjbpm-integration/tree/master/drools-camel/src/test/java/org/drools/camel/component

Hope this helps.

Edson Tirelli
  • 3,891
  • 20
  • 23
  • Thanks. For my use case I want drools to treat the camel messages as "facts" and apply my filtering rules (similar to the Twitter CBR example) Is this possible without major changes ? – Soumya Simanta Mar 07 '12 at 17:32
  • Is JsonQueryTest.java the correct implementation for use case # 2 ? – Soumya Simanta Mar 07 '12 at 17:38
  • This is probably the example you want: https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointActionInsertTest.java . Basically, you want to reference the drools end point with the action insertBody and optionally the entry point name you want to use for your stream. E.g.: drools://node/ksession1?action=insertBody&entryPoint=ep1 – Edson Tirelli Mar 07 '12 at 19:36
  • Github examples refer to version 5. https://github.com/kiegroup/droolsjbpm-integration/blob/5.6.x/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointActionInsertTest.java. Master branch (7.x) is significantly different https://github.com/kiegroup/droolsjbpm-integration/tree/master/kie-camel/src/test/java/org/kie/camel – Jeremy Gosling Apr 10 '17 at 09:37