Reasons for choosing Java agents
Rule agents are the default choice of agent, but there might be good reasons for you to choose a different type of agent.
In most cases, a rule agent is likely to be your first choice of agent. In a rule agent, you can express what you want to do more compactly than by using a Java™ agent. A major difference between rule agents and Java agents is that Java agents by default are stateless. Rule agents store the state of processed events and values of related entities in the working memory, and this data is available in a stateful way to rule conditions. To maintain state in a Java agent, you must add attributes to the bound entity.
The following examples give some valid reasons to use a Java agent rather than a rule agent:
- You might want to access the system in some way that is not possible
in rules. For example, if you want to call a web service. Important: Introducing latency in this way might have severe performance impacts on high-throughput systems.
- You might want to calculate some complex computation (complicated loops, data handling, Java library calls), which is difficult to implement in rules.
- You might want to do something simple, and you are more comfortable writing Java code.
- You might want to write some logic that does not change often and this logic exists in Java.
- You might need to convert an inbound event that has some kind of mismatch between the real world and your model by implementing Java code.
The following general guideline can also be used to make your choice of agent:
- Use a rule agent if you need event aggregation in your solution because the business model language makes these operations much simpler.
- Use a predictive agent, which is a kind of Java agent when you integrate with an external service.