Skip to content

Commit 8e9c57b

Browse files
authored
Add a uuid for producer name so several producers can run at the same time (#24)
The goal here is to allow the output plugin to run several producers. While testing with the current build I experienced some issues that it wouldn't handle multiple producers with the same name so this is my solution to solve that issue.
1 parent d391f5b commit 8e9c57b

File tree

1 file changed

+3
-1
lines changed
  • src/main/java/org/apache/pulsar/logstash/outputs

1 file changed

+3
-1
lines changed

src/main/java/org/apache/pulsar/logstash/outputs/Pulsar.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Map;
2828
import java.util.Optional;
2929
import java.util.Set;
30+
import java.util.UUID;
3031
import java.util.concurrent.CountDownLatch;
3132

3233
@LogstashPlugin(name = "pulsar")
@@ -243,7 +244,8 @@ private org.apache.pulsar.client.api.Producer<byte[]> getProducer(String topic)
243244
.blockIfQueueFull(blockIfQueueFull)
244245
.compressionType(getSubscriptionType());
245246
if (producerName != null) {
246-
producerBuilder.producerName(producerName);
247+
String uniqProducerName = producerName + '-' + UUID.randomUUID();
248+
producerBuilder.producerName(uniqProducerName);
247249
}
248250
org.apache.pulsar.client.api.Producer<byte[]> producer = producerBuilder.create();
249251
logger.info("Create producer {} to topic {} , blockIfQueueFull is {},compressionType is {}", producer.getProducerName(),topic, blockIfQueueFull?"true":"false",compressionType);

0 commit comments

Comments
 (0)