Decisions on events
One shipping-service that reads a carrier's free-text delivery-exception note, has a local model return a reason from a closed set, decides RESHIP or REFUND with a Drools rule unit, records both results, and replays the decisions from the record with no model call.
examples/24-decisions-on-events/ is one service, shipping-service. Two Camel routes carry the events: one calls an AI service on every note and records the analysis, one runs a rule unit on every analysis and records the decision. It accompanies Decisions on events.
It uses Quarkus, Quarkus LangChain4j with Ollama, the Drools rule unit engine, Camel Kafka, Quarkus REST, SmallRye Health, Kafka and OpenTelemetry to the LGTM stack. The model is a local Ollama container with a model volume filled once by scripts/ollama-model.sh pull.
(cd examples/domain-model && mvn -B -q install)
scripts/ollama-model.sh pull
cd examples/24-decisions-on-events
mvn -B verify
./verify.sh
What to observe
- A closed reason. Each analysis on
edp.shipping.exception-analysesholds a reason from the enum, the model digest and the prompt version. - A decision with its rule. Every decision on
edp.shipping.exception-decisionsnames the rule that made it, and equals the rule table applied to the recorded reason and attempt. - The same damage, a different attempt. The first attempt is reshipped and the second is refunded, for the same order.
- A replay with no model.
POST /demo/replayreturns the recorded decisions and the model-call count does not move. - A waiting note. With Ollama stopped the note has no analysis and the consumer group has lag 1, until the model returns.
Infrastructure
Kafka, the LGTM stack and Ollama from examples/_infra, plus shipping-service. The compose project is edp-24.