---
description: Creation of multiple event paths
---

# Event graph

## Introduction

The goal is to create many unique execution paths where a node is invoked only if it is on the active execution path.

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 as per the [event pipeline](event-pipeline) description. In this case we want to create a graph containing multiple execution paths. The uniqueness of an execution path is defined as the compound value of event type and filter value.

For Fluxtion ESC there is no difference between a graph and a pipeline, the use of [processing inference](../../../../concepts/child-1/graph-building#processing-inference) determines what the structure is. Similarly for the programmer there is no change in the annotations used, only the creation of a rich object model in the builder is required. Once an object graph is provided to Fluxtion it will generate a SEP with multiple execution paths.

{% hint style="info" %}
Graphs and pipelines use the same annotations.
{% endhint %}

## Example

This example creates a processing graph using the builder below. The Combiner node has multiple parents and is on a separate path to the pipeline/child nodes for incoming events of type MyEvent. This described network has multiple execution paths in the execution graph.

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

### SEPConfig builder class

```java
public class Builder extends SEPConfig {

    @Override
    public void buildConfig() {
        DataEventHandler sharedHandler = addNode(new DataEventHandler());
        PipelineNode node = addNode(new PipelineNode(sharedHandler));
        ChildNode childNode = addNode(new ChildNode(node));
        MyEventHandler myHandler = addNode(new MyEventHandler());
        CombinerNode combiner = addNode(new CombinerNode(myHandler, sharedHandler));
    }

}
```

### Generated SEP

The generated SEP creates a dispatch method for each incoming event, each with its own unique execution path.

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

  //Node declarations
  private final DataEventHandler dataEventHandler_1 = new DataEventHandler();
  private final MyEventHandler myEventHandler_7 = new MyEventHandler();
  private final CombinerNode combinerNode_9 =
      new CombinerNode(myEventHandler_7, dataEventHandler_1);
  private final PipelineNode pipelineNode_3 = new PipelineNode(dataEventHandler_1);
  private final ChildNode childNode_5 = new ChildNode(pipelineNode_3);

  //code omitted for clarity

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

  public void handleEvent(MyEvent typedEvent) {
    //Default, no filter methods
    myEventHandler_7.handleEvent(typedEvent);
    combinerNode_9.update();
    //event stack unwind callbacks
    afterEvent();
  }
  
}

```

### Generated png

&#x20;The graphical representation of this execution graph as generated by Fluxtion ESC:

![a diagram show multiple execution paths in a SEP](https://28048783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTCQdxBe4qllLPVvIbZ%2F-LTxN2V1FcJnNpDCy9fc%2F-LTxMh8AR-SlHlJILTri%2FSampleProcessor.png?alt=media\&token=c90020f3-79cb-402e-9e78-73be961c684e)
