Getting Started Cameras & Video Detection & Recording Automation & Events Actions Integration & Connectivity Network & Discovery AI & Remote Control MQTT Modbus ZeroMQ System & Administration Use Cases Troubleshooting About & Legal
Home / Documentation / Java Event Manager
Knowledge base

Java Event Manager

Java Event Manager routes events through trusted Java code compiled at runtime, and forwards an event to child tasks only when the snippet returns true.

Route events with code-level logic

Use Java Event Manager when event routing needs custom Java logic that is difficult to express with ordinary Event Manager rules. The component subscribes to the agent event bus, compiles configured Java code on startup, and calls it for every received event.

The generated method receives engine and event. Return true when the event should be forwarded to child tasks; return false when it should be ignored.

01

Name the routing component

Set Title to the routing purpose, for example advanced alarm filter, vendor event normalizer, or Java event debounce.

02

Keep imports minimal

Use Imports only for event classes, task classes, or utility types not covered by the default imports.

03

Write a fast event predicate

Java code runs on the event delivery path. It should inspect the event, make a quick routing decision, and return a boolean.

Configuration parameters

ParameterRequiredDescriptionDefault
Title
YesDisplay name of the event routing component.None
Imports
OptionalAdditional Java import statements appended to the generated class.Empty
Class properties
OptionalAdditional class-level fields or helper methods compiled into the event consumer. Keep state thread-safe and bounded.Empty
Java code
YesBody of the boolean event consumer method. It receives engine and event, and returns whether child tasks should receive the event.Print event and return true

Events are filtered before child tasks run

For every received event, the compiled Java method decides whether to forward it. When true is returned, Banalytics creates an execution context, puts the current event into it, and calls child tasks in order. If a child task returns false, remaining child tasks are skipped.

Use Class properties for helper methods, constants, compiled patterns, or small caches. Avoid growing collections of events because the generated class can stay cached and long-lived.

EVT

Event predicate

Inspect event type and fields, then return true only for events that should continue downstream.

CTX

Forwarded context

Accepted events are placed into a new execution context for subscribed child tasks.

JAVA

Runtime compilation

Compilation happens when the component starts; compile errors prevent it from starting.

Use Java for advanced event routing

01

Complex event filter

Check the concrete event class and several fields in Java, then return true only for the combination that should reach child tasks.

02

Event enrichment gateway

Normalize vendor-specific event metadata before forwarding the event to downstream tasks that expect a consistent shape.

03

Prototype advanced automation

Implement a custom condition quickly in Java, then move stable business rules to Event Manager when they can be maintained through the UI.

04

Stateful debounce or rate limit

Keep a small timestamp map in Class properties and suppress repeated events within a short interval. Bound the map by source or event type to avoid unbounded memory growth.

05

Development and troubleshooting

Start with a simple print and return false, verify the event shape, then replace logging with precise checks and enable forwarding.

Operational notes

01

Compilation controls startup

The code is compiled when the component starts. Compilation errors prevent startup until the snippet is fixed.

02

Stop on failure is intentional

The default restart-on-failure mode is stop-on-failure, which is appropriate for custom code because repeated automatic restarts can hide a broken snippet.

03

Handle unexpected event shapes

Exceptions thrown by the snippet are logged and handled as processing errors. Prefer explicit type checks and safe fallbacks instead of assuming every event has the same fields.

04

Use ordinary rules first

Use Event Manager for ordinary operator-managed rules. Use Java Event Manager only when code-level logic is genuinely needed and the maintainer is comfortable owning Java snippets.

05

Keep code non-blocking

Long I/O, sleeps, network calls, or heavy calculations can delay delivery of later events. Keep routing code fast and predictable.

Related Core pages

Related components and pages