---
description: Creation of a single execution path with multiple nodes
---

# Event pipeline

The goal is to join a set of nodes together to form an execution graph that processes an event in predictable order. The execution graph has a single path a pipline node is invoked after a parent node has processed an event.

The [@OnEvent](https://github.com/v12technology/fluxtion/blob/master/builder/src/main/java/com/fluxtion/api/annotations/OnEvent.java)  annotation marks a method to be included in the execution graph. The method will be invoked when all of its dependent nodes on the execution path have processed the event. Event processing includes @OnEvent and @EventHandler annotated methods of parents.

{% hint style="info" %}
Only methods marked with **@OnEvent** will be included in the execution graph
{% endhint %}

A valid OnEvent method has no arguments with an optional boolean return type. The boolean return indicates whether this node is "dirty" and event notification should continue, change notifications are [discussed later](dirty-node-monitoring).

## Example

This example defines a `PipelineNode` that is  dependent upon a `DataEventHandler`. The DataEventHandler processes DataEvent's as an event handler.

The pipeline example code is located [here](https://github.com/v12technology/fluxtion/tree/master/examples/documentation-examples/src/main/java/com/fluxtion/example/core/events/pipeline).

The update method will be invoked by the SEP in topological order after the DataHandler has processed an incoming event. We define the graph imperatively using a builder class, further discussion on builders is in the [graph building](../graph-building-primitives) section.

### Node class

The PipelineNode class declares a dependency to its parent, DataEventHandler (handler). The [@OnEvent](https://github.com/v12technology/fluxtion/blob/master/builder/src/main/java/com/fluxtion/api/annotations/OnEvent.java) annotation requires this method to be invoked after handler has complete processing the incoming event. See [here](../../../../concepts/static-event-processor/event-processing#topological-order) for discussion on node ordering.

```java
public class PipelineNode {

    private final DataEventHandler handler;

    public PipelineNode(DataEventHandler handler) {
        this.handler = handler;
    }
    
    @OnEvent
    public void update(){}
}
```

### SEPConfig builder

A pipeline is defined with two nodes, the PipelineNode is a child of the DataEventHandler node.&#x20;

```java
public class Builder extends SEPConfig {

    @Override
    public void buildConfig() {
        DataEventHandler handler = new DataEventHandler();
        PipelineNode node = new PipelineNode(handler);
        addNode(handler);
        addNode(node);
    }

}
```

### Generated SEP

The generated SEP, implements a dispatch method invoking the execution path in topological order. As expected dataEventHandler\_1 processes the event before pipelineNode\_3 is notified of the event wave.

```java
public class SampleProcessor implements EventHandler, BatchHandler, Lifecycle {

  //Node declarations
  private final DataEventHandler dataEventHandler_1 = new DataEventHandler();
  private final PipelineNode pipelineNode_3 = new PipelineNode(dataEventHandler_1);
  
  public SampleProcessor() {}

//omitted code for clarity

  public void handleEvent(DataEvent typedEvent) {
    //Default, no filter methods
    dataEventHandler_1.handleEvent(typedEvent);
    pipelineNode_3.update();
    //event stack unwind callbacks
    afterEvent();
  }

}

```

### Generated ong

The graphical representation of this execution graph as generated by Fluxtion ESC:

![execution graph for a simple pipeline system](https://28048783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTCQdxBe4qllLPVvIbZ%2F-LTvMekRLL_FQuLXzbuk%2F-LTvMZaaEHGbYZU6OVMB%2FSampleProcessor.png?alt=media\&token=64408cb2-0c8a-42e7-87a5-51e4c24cece6)

As described in [structured processing](../../../concepts/auditing), the elements in the image are consistent with the generated code. For example the variable name of the PipelineNode is pipelineNode\_3 in both the image and the generated SEP.

An execution is path is formed by the ESC, the nodes are methods on that path. We mark a method for inclusion in the graph using the [@OnEvent ](https://github.com/v12technology/fluxtion/blob/master/builder/src/main/java/com/fluxtion/api/annotations/OnEvent.java)annotation. Any OnEvent method will be invoked when all of its dependent nodes on the execution path have executed their respective event handling methods. Event handling methods include both @OnEvent and @EventHandler methods.

Any method marked with @OnEvent should be a no arg method, with an optional boolean return. The boolean return value indicates if this node has updated after processing the notification.

