Drools uses sessions to store runtime data. For this purpose there are two kinds of sessions: stateless and stateful. In contrast to stateless sessions, stateful sessions allow iterative invocation and seem to have all advantages over stateless sessions.
So why are there even stateless sessions? What is the purpose they serve? And what are their advantage over stateful sessions?
Thank you.
As for many other general stateless scenarios, a Drools stateless session could be helpful for filtering or data-preprocessing, or data validation.
I have experienced the need of both Stateful and Stateless sessions in Drools, for different use-cases; for stateless use case some examples:
In these example you notice how the session doesn't need to hold any state after the object have been evaluated against the rule. In these examples is better to just discard the session and create a new one for the next message/object, because they can be evaluated complete separately. Technically if the rule are well defined the behavior would be idempotent, meaning if you (inadvertently?) cycle the same object/message again, the result would be the same. Finally, when I say object/message it doesn't necessarily mean a single Pojo, it could be a Collection of objects.