Add interface ExtendedBrokerApi to consume messages with groupId
The intention of this change is to extend the current API allowing
consumers read meesages with the use of a groupId, which enables
multiple consumers to independently read messages from the same source,
facilitating parallelism, fault tolerance, and efficient processing.
It allows for workload distribution and ordered processing within
consumer groups.
Change-Id: I3404d930592cd62377181062e7eb474ddd3e5dc7
diff --git a/pom.xml b/pom.xml
index daf7043..5e29be5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<groupId>com.gerritforge</groupId>
<artifactId>events-broker</artifactId>
- <version>3.4.0.4</version>
+ <version>3.4.0.5</version>
<packaging>jar</packaging>
<name>events-broker</name>
diff --git a/src/main/java/com/gerritforge/gerrit/eventbroker/ExtendedBrokerApi.java b/src/main/java/com/gerritforge/gerrit/eventbroker/ExtendedBrokerApi.java
new file mode 100644
index 0000000..956f530
--- /dev/null
+++ b/src/main/java/com/gerritforge/gerrit/eventbroker/ExtendedBrokerApi.java
@@ -0,0 +1,30 @@
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.gerritforge.gerrit.eventbroker;
+
+import com.google.gerrit.server.events.Event;
+import java.util.function.Consumer;
+
+public interface ExtendedBrokerApi extends BrokerApi {
+
+ /**
+ * Receive asynchronously a message from a topic using a consumer's group id.
+ *
+ * @param topic topic name
+ * @param groupId the group identifier that consumer belongs to for that topic
+ * @param consumer an operation that accepts and process a single message
+ */
+ void receiveAsync(String topic, String groupId, Consumer<Event> consumer);
+}