commit | 689ea2854612ebcf0599084276d1d28e40253127 | [log] [tgz] |
---|---|---|
author | Marcin Czech <maczech@gmail.com> | Wed Aug 04 15:00:42 2021 +0200 |
committer | Marcin Czech <maczech@gmail.com> | Mon Aug 09 11:45:38 2021 +0200 |
tree | 8caaf833b37a0d096217b1e359f4c1dfab04c1b9 | |
parent | 2128ad19f6b027d8cc78733cf50198d1ed8116e5 [diff] |
Do not publish forwarded stream events StreamEventPublisher uses gerrit.instanceId and Event.instanceId to decide if the event is generated locally or forwarded from other node. All events forwarded from other nodes or events without instanceId are not published. This allows to avoid message duplication. Bug: Issue 14852 Change-Id: I3cc8053a546f3f95c2f47b658a36b7dd91fb8e85
API of a generic events broker for use with Gerrit Code Review.
Enables the de-coupling between Gerrit, plugins and the different implementations of a generic events broker.
It is a quite common use case for consumers of this library to listen for Gerrit events and to stream them on a specific topic.
Since the implementation of such logic is always the same, this library provides a generic stream events publisher which will perform the relevant operations.
In order to listen and stream gerrit events, consumers of this API just need to provide a named annotation with the name of the stream events topic and then explicitly bind the Stream Events Publisher, as such:
import com.gerritforge.gerrit.eventbroker.StreamEventPublisher; import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.server.events.EventListener; import com.google.inject.AbstractModule; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; public class SomeModule extends AbstractModule { @Override protected void configure() { bind(new TypeLiteral<String>() { }) .annotatedWith(Names.named(StreamEventPublisher.STREAM_EVENTS_TOPIC)) .toInstance("name_of_the_stream_events_topic"); DynamicSet.bind(binder(), EventListener.class).to(StreamEventPublisher.class); } }
Note: To avoid message duplication Stream Events Publisher uses gerrit.instanceId and Event.instanceId to filter out forwarded events.