All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.camunda.zeebe.spring.client.event.ZeebeLifecycleEventProducer Maven / Gradle / Ivy

There is a newer version: 8.5.10
Show newest version
package io.camunda.zeebe.spring.client.event;

import io.camunda.zeebe.client.ZeebeClient;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.SmartLifecycle;

public class ZeebeLifecycleEventProducer implements SmartLifecycle {

  protected boolean running = false;

  private final ApplicationEventPublisher publisher;

  private final ZeebeClient client;

  public ZeebeLifecycleEventProducer(final ZeebeClient client, final ApplicationEventPublisher publisher) {
    this.client = client;
    this.publisher = publisher;
  }

  @Override
  public void start() {
    publisher.publishEvent(new ClientStartedEvent()); // keep old deprecated event for a bit before delting it
    publisher.publishEvent(new ZeebeClientCreatedEvent(this, client));

    this.running = true;
  }

  @Override
  public void stop() {
    publisher.publishEvent(new ClientStoppedEvent()); // keep old deprecated event for a bit before delting it
    publisher.publishEvent(new ZeebeClientClosingEvent(this, client));

    this.running = false;
  }

  @Override
  public boolean isRunning() {
    return running;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy