Just started looking at Spring Integration and it looks really excellent. It strikes me that it could be quite complementary to use the Drools rules engine in a Spring Integration application. Lots of ESB type tools have built in rules engines and BPEL or BPMN engines, and Drools can provide this.
I had a go at writing an endpoint adapter which I've attached to this post. It provides two alternative service activators:
- addFact. This asserts the incoming message as a fact in the rules engine, as defined in Drools Expert. I wondered whether to add the payload (allowing efficient class-based constraints) or the message (giving access to headers) and ended up adding both (they can be joined in a rule). This could for example allow much more complex aggregation rules.
- signalEvent. This fires the message as a signal into the rules engine, which can be configured to start a business process (e.g. BPMN), as defined in Drools Flow. The business processes in turn trigger rules as they progress.
Drools has a new concept of "channels" to get facts or other information out of the rules engine, and it's easy to map these onto Spring Integration channels. Drools also provides a schema for configuring the rules engine within a Spring configuration file, which should be used with this adapter (URL is in the attached file). For example, you can configure the rules engine as an event-cloud (Drools Fusion), which could be particularly useful with Spring Integration, as it can manage message expiry, and calculate averages or totals extracted from messages over a time range.