# Spring Boot Application with Event Registry

**URL:** <https://forum.flowable.org/t/spring-boot-application-with-event-registry/5919>\
**Category:** Flowable Engine\
**Created:** [April 28, 2020, 6:38pm UTC](https://forum.flowable.org/t/spring-boot-application-with-event-registry/5919 "2020-04-28T18:38:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sukalpo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sukalpo/32/1143_2.png) [@sukalpo](https://forum.flowable.org/u/sukalpo)\
**Post date:** [April 28, 2020, 6:38pm UTC](https://forum.flowable.org/t/spring-boot-application-with-event-registry/5919/1 "2020-04-28T18:38:56Z")

</div>

Hi All,

I am using Spring Boot 2.2.6.RELEASE with flowable version 6.5.0. My main objective for using this version is to use Kafka as we have an event driven architecture.

This is the process that I am using to understand how I can work with event registry.

```
  <?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2020 nexiles GmbH. All rights reserved.
  -->

<definitions
        xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
        xmlns:flowable="http://flowable.org/bpmn"
        targetNamespace="Examples">

    <process id="eventTest" name="Process to test events">
        <startEvent id="theStart" >
            <extensionElements>
                <flowable:eventType xmlns:flowable="http://flowable.org/bpmn">carparkEnter</flowable:eventType>
                <flowable:eventOutParameter xmlns:flowable="http://flowable.org/bpmn"
                                            source="vehicleNumber"
                                            sourceType="string"
                                            target="vehicleNumber"/>
                <flowable:eventOutParameter xmlns:flowable="http://flowable.org/bpmn"
                                            source="carpark"
                                            sourceType="string"
                                            target="carpark"/>
            </extensionElements>
        </startEvent>
        <sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" />
        <serviceTask id="theTask" name="event test task" flowable:delegateExpression="${testTask}" flowable:async="true"
        />
        <sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd" />
        <endEvent id="theEnd" />
    </process>

</definitions>

```

The xml has been placed under resources/processes.

This is my .event file

```
{
  "key": "carparkEnter",
  "name": "Carpark Enter",
  "inboundChannelKeys": [
    "carparkenterChannel"
  ],
  "correlationParameters": [],
  "payload": [
    {
      "name": "vehicleNumber",
      "type": "string"
    },
    {
      "name": "carpark",
      "type": "string"
    }
  ]
}

```

And this is my .channel file

```
{
  "key": "carparkenterChannel",
  "name": "Carpark Enter channel",
  "description": "Carpark Enter Channel",
  "channelType": "inbound",
  "type": "kafka",
  "deserializerType": "json",
  "channelEventKeyDetection": {
    "fixedValue": "carparkEnterEvent"
  },
  "topics": ["LPRS_CARPARK_ENTER_JSON"]
}

```

The event and channel file are placed under resources/eventregistry folder

My application.properties file has the following entries

# Enable and configure Kafka

```
flowable.task.app.kafka-enabled=true
spring.kafka.consumer.group-id=marvel-heimdall-carpark-enter
spring.kafka.consumer.auto-offset-reset=earliest
spring.kafka.listener.missing-topics-fatal=false
spring.kafka.bootstrap-servers=${BOOTSTRAP_SERVER}

```

When I start my spring boot application and produce a json in the topic, I dont see my process getting started. Do I need to write any other configuration?

I have the following dependency in pom.xml

```
<dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-process</artifactId>
            <version>${flowable.version}</version>
        </dependency>

```

Please help and thanks in advance!

---

<div class="post-metadata">

**Author:** ![sukalpo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sukalpo/32/1143_2.png) [@sukalpo](https://forum.flowable.org/u/sukalpo)\
**Post date:** [April 29, 2020, 4:48am UTC](https://forum.flowable.org/t/spring-boot-application-with-event-registry/5919/2 "2020-04-29T04:48:41Z")

</div>

Hi All,  
I have crossed this initial hurdle. I forgot to add the kafka dependency

```
<dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency>

```

So now I can see the application is detecting event registry changes.

But now I have a different ptoblem.

When the application starts up I can see the below error

`Failed to start bean 'eventEngineConfiguration'; nested exception is java.lang.AbstractMethodError: org.flowable.eventregistry.spring.kafka.SimpleKafkaListenerEndpoint.getTopicPartitions()`

And later I can see this

`Caused by: java.lang.IllegalStateException: EntityManagerFactory is closed`

And when an event comes I see this exception

`org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.IllegalStateException: EntityManagerFactory is closed`

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [April 29, 2020, 7:39am UTC](https://forum.flowable.org/t/spring-boot-application-with-event-registry/5919/3 "2020-04-29T07:39:43Z")

</div>

Hey @sukalpo,

Have you looked at the [flowable-kafka](https://github.com/flowable/flowable-examples/tree/master/flowable-kafka) example?

When you are creating your own application then you need to add the appropriate dependencies to activate Kafka.

The exception you are seeing seems like you have some JPA dependency on the classpath, but it is not properly configured. Can you please share your entire pom?

For the `AbstractMethodError` can you please share the entire stacktrace. Can you verify which `spring-kafka` version you have on your classpath? Is it `2.3.x` or is it newer?

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![sukalpo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sukalpo/32/1143_2.png) [@sukalpo](https://forum.flowable.org/u/sukalpo)\
**Post date:** [April 29, 2020, 8:41am UTC](https://forum.flowable.org/t/spring-boot-application-with-event-registry/5919/4 "2020-04-29T08:41:16Z")

</div>

Hi @filiphr,

Thanks for the response. My spring boot starter dependency was 2.1.1. After upgrading it to 2.2.6 Release now the Entitymanager exception is solved.

Now I am getting the following when i push message in kafka:-

`2020-04-29 08:32:54 [org.flowable.eventregistry.kafka.ChannelKafkaListenerEndpointContainer#carparkenterChannel-0-C-1] ERROR o.s.k.listener.LoggingErrorHandler - Error while processing: ConsumerRecord(topic = LPRS_CARPARK_ENTER_JSON, partition = 0, leaderEpoch = 0, offset = 0, CreateTime = 1588149174831, serialized key size = -1, serialized value size = 38, headers = RecordHeaders(headers = [], isReadOnly = false), key = null, value = {"vehicleNumber":"123","carpark":"3A"})`

`org.springframework.kafka.listener.ListenerExecutionFailedException: Listener failed; nested exception is org.flowable.common.engine.api.FlowableObjectNotFoundException: no event definitions deployed with key 'carparkEnterEvent'`

I am using this in the channel file

```
"channelEventKeyDetection": {
    "fixedValue": "carparkEnterEvent"
  },
```

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [April 29, 2020, 8:45am UTC](https://forum.flowable.org/t/spring-boot-application-with-event-registry/5919/5 "2020-04-29T08:45:51Z")

</div>

The problem is that the event you are deploying has the following:

```auto
  "key": "carparkEnter",

```

and your channel has `carparkEnterEvent` align those and it should work.

---

<div class="post-metadata">

**Author:** ![sukalpo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sukalpo/32/1143_2.png) [@sukalpo](https://forum.flowable.org/u/sukalpo)\
**Post date:** [April 29, 2020, 9:48am UTC](https://forum.flowable.org/t/spring-boot-application-with-event-registry/5919/6 "2020-04-29T09:48:26Z")

</div>

And indeed it works like a charm. Thanks @filiphr

---

<div class="post-metadata">

**Author:** ![harish](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@harish](https://forum.flowable.org/u/harish)\
**Post date:** [August 10, 2021, 10:53am UTC](https://forum.flowable.org/t/spring-boot-application-with-event-registry/5919/7 "2021-08-10T10:53:31Z")

</div>

Hi @filiphr , I am trying the same as above but not in spring framework. I am trying to implement same in Micronaut and its not not working. I do not get any error but the control is not coming to my delegates. Although , I am able to do the same with spring boot. Below are the configurations I have added:

```auto
 implementation 'io.micronaut.kafka:micronaut-kafka:3.3.3'
    implementation "org.flowable:flowable-engine:6.6.0"

```

My Bean:

```auto
@Bean
    @Singleton
    public ProcessEngine processEngine() {

        ProcessEngineConfiguration cfg = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
                .setJdbcUrl("dbUrl")
                .setJdbcUsername("username")
                .setJdbcPassword("password")
                .setJdbcDriver("driver class name")
                .setAsyncExecutorActivate(true) .setDatabaseSchemaUpdate(AbstractEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);

        List<VariableType> customTypes = new ArrayList<>();
        ((StandaloneProcessEngineConfiguration) cfg).setCustomPreVariableTypes(customTypes);

        ProcessEngine processEngine = cfg.buildProcessEngine();

         processEngine.getRepositoryService().createDeployment()
                    .addClasspathResource("test.bpmn20.xml")
                    .addClasspathResource("eventregistry/event-idvCompleteEvent.event")
                    .addClasspathResource("eventregistry/channel-idvCompleteChannel.channel")
                    .deploy();

        return processEngine;
    }

```

My delegate:

```auto
public class MyDelegate implements JavaDelegate {

    @Override
    public void execute(DelegateExecution execution) {

        String field = execution.getVariable("fieldNamePassingFromKafkaTopicMessage", String.class);
    }
}

```

Could you please suggest me what’s wrong in my implementation?

Thanks  
Harish
