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

io.camunda.zeebe.broker.jobstream.RemoteJobStreamer Maven / Gradle / Ivy

There is a newer version: 8.7.0-alpha1
Show newest version
/*
 * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
 * one or more contributor license agreements. See the NOTICE file distributed
 * with this work for additional information regarding copyright ownership.
 * Licensed under the Camunda License 1.0. You may not use this file
 * except in compliance with the Camunda License 1.0.
 */
package io.camunda.zeebe.broker.jobstream;

import io.atomix.cluster.messaging.ClusterEventService;
import io.camunda.zeebe.engine.processing.streamprocessor.JobStreamer;
import io.camunda.zeebe.protocol.impl.stream.job.ActivatedJob;
import io.camunda.zeebe.protocol.impl.stream.job.JobActivationProperties;
import io.camunda.zeebe.transport.stream.api.RemoteStreamer;
import java.util.Optional;
import java.util.function.Predicate;
import org.agrona.DirectBuffer;

public final class RemoteJobStreamer implements JobStreamer {
  private static final String JOBS_AVAILABLE_TOPIC = "jobsAvailable";

  private final RemoteStreamer delegate;
  private final ClusterEventService eventService;

  public RemoteJobStreamer(
      final RemoteStreamer delegate,
      final ClusterEventService eventService) {
    this.delegate = delegate;
    this.eventService = eventService;
  }

  @Override
  public void notifyWorkAvailable(final String jobType) {
    eventService.broadcast(JOBS_AVAILABLE_TOPIC, jobType);
  }

  @Override
  public Optional streamFor(
      final DirectBuffer jobType, final Predicate filter) {
    return delegate.streamFor(jobType, filter).map(RemoteJobStream::new);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy