Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puplicate producing message in the most inconvenient way possible #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/Producer/KafkaProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,38 @@ public function produce(KafkaProducerMessageInterface $message, bool $autoPoll =

$topicProducer = $this->getProducerTopicForTopic($message->getTopicName());

$topicProducer->producev($message->getPartition(), RD_KAFKA_MSG_F_BLOCK,
$topicProducer->producev(
$message->getPartition(),
RD_KAFKA_MSG_F_BLOCK,
$message->getBody(),
$message->getKey(),
$message->getHeaders()
);

// This is a test comment
if (true === $autoPoll) {
$this->producer->poll($pollTimeoutMs);
}
}

/**
* Produces a message to the topic and partition defined in the message
* If a schema name was given, the message body will be avro serialized.
*
* @param KafkaProducerMessageInterface $message
* @param boolean $autoPoll
* @param integer $pollTimeoutMs
* @return void
*/
public function produceSameSame(KafkaProducerMessageInterface $message, bool $autoPoll = true, int $pollTimeoutMs = 0): void
{
$message = $this->encoder->encode($message);

$topicProducer = $this->getProducerTopicForTopic($message->getTopicName());

$topicProducer->producev(
$message->getPartition(),
RD_KAFKA_MSG_F_BLOCK,
$message->getBody(),
$message->getKey(),
$message->getHeaders()
Expand All @@ -97,6 +128,7 @@ public function produce(KafkaProducerMessageInterface $message, bool $autoPoll =
public function syncProduce(KafkaProducerMessageInterface $message): void
{
$this->produce($message, true, -1);
$this->produceSameSame($message, true, -1);
}

/**
Expand Down