From aa764a81c0b335553b86f79cfb6efd205ee747c9 Mon Sep 17 00:00:00 2001 From: Jean-Bernard van Zuylen Date: Thu, 13 Dec 2018 15:56:53 +0100 Subject: [PATCH] Implemented change to make sure producer and consumer names are unique --- .../org/primeoservices/cfgateway/pulsar/PulsarConsumer.java | 3 ++- .../org/primeoservices/cfgateway/pulsar/PulsarProducer.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/primeoservices/cfgateway/pulsar/PulsarConsumer.java b/src/main/java/org/primeoservices/cfgateway/pulsar/PulsarConsumer.java index 4d8e83e..e183463 100644 --- a/src/main/java/org/primeoservices/cfgateway/pulsar/PulsarConsumer.java +++ b/src/main/java/org/primeoservices/cfgateway/pulsar/PulsarConsumer.java @@ -17,6 +17,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.UUID; import java.util.concurrent.TimeUnit; import org.apache.pulsar.client.api.Consumer; @@ -63,7 +64,7 @@ public void init(final ConsumerBuilder builder) { final PulsarConfiguration config = this.getGateway().getConfiguration(); builder.topic(config.getTopic()); - builder.consumerName(this.getGateway().getId()); + builder.consumerName(this.getGateway().getId() + "$" + UUID.randomUUID().toString().substring(0, 5)); builder.subscriptionName(config.getSubscriptionName()); builder.subscriptionType(config.getSubscriptionType()); builder.ackTimeout(config.getAckTimeout(), TimeUnit.SECONDS); diff --git a/src/main/java/org/primeoservices/cfgateway/pulsar/PulsarProducer.java b/src/main/java/org/primeoservices/cfgateway/pulsar/PulsarProducer.java index d8e92c1..70f1f37 100644 --- a/src/main/java/org/primeoservices/cfgateway/pulsar/PulsarProducer.java +++ b/src/main/java/org/primeoservices/cfgateway/pulsar/PulsarProducer.java @@ -16,6 +16,7 @@ package org.primeoservices.cfgateway.pulsar; import java.util.Map; +import java.util.UUID; import java.util.concurrent.TimeUnit; import org.apache.pulsar.client.api.Producer; @@ -63,7 +64,7 @@ public void init(final ProducerBuilder builder) { final PulsarConfiguration config = this.getGateway().getConfiguration(); builder.topic(config.getTopic()); - builder.producerName(this.getGateway().getId()); + builder.producerName(this.getGateway().getId() + "$" + UUID.randomUUID().toString().substring(0, 5)); builder.sendTimeout(config.getSendTimeout(), TimeUnit.SECONDS); builder.enableBatching(false); }