-
Notifications
You must be signed in to change notification settings - Fork 55
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
Provide produceMessageSync operation #90
Comments
It can be trickier than it seems in
You can model it much simpler if you call Typically you use Would this way be sufficient? P.S. |
I see. The problem with that solution is that as a producer, I cannot pinpoint my data without doing some reconciling logic. I guess Maybe I can restate it like this - as a client, I'd like to be able to produce a message and receive its delivery report as the returned value: produceMessage ::
MonadIO m
=> KafkaProducer
-> ProducerRecord
-> m (Either KafkaError DeliveryReport) I think the pointer |
Ah, I see, they update message's I guess we can do that, currently in If we do that for all messages, then it can be transparent for all the existing code, and we can implement |
🎉 |
Hello @AlexeyRaga and @felixmulder, I have an issue that I believe is very much related to what you have been working on here. Please let me elaborate.
I was able to prototype 1), but didn’t see how I could do 2) given that the Do you have any insight to share? |
Hi @tscholak! I see the pain and I may have a way to deal with it. How So the "problem" is that the offsets are "stored" at the time the message is consumed, not at the time when it is "handled". But that can be switched off! When we set noAutoOffsetStore property while creating a consumer Now we can use storeOffsets or storeOffsetMessage functions to tell the consumer the offsets of the messages that we have actually handled at the times when we are sure that it is safe for them to be committed. And with this we can keep auto commit on. Does this approach help with your issue? |
Hi @AlexeyRaga, However, the main problem I was hinting at remains unsolved: How do I know that the message went out to the output topic successfully? Right now I have to flush (either for each message which is slow or in chunks or time intervals as described by option 1) above). Is there a way to call Edit: Earlier @AlexeyRaga said,
This would suggest that
where the type variable
and
|
No, I apologise for not explaining it clear.
Or you can flush the producer periodically. |
Thanks again @AlexeyRaga for clarification!
I’m not sure I understand how this is possible. How can the I think, at present, it would require to manually enrich the outgoing |
@tscholak I see how it is not convenient, but we could correlate by For example:
Granted, it isn't particularly nice :( We could think of doing better with allowing Here is my braindump: We could store some data ProducerRecord = ProducerRecord
{ prTopic :: !TopicName
, prPartition :: !ProducePartition
, prKey :: Maybe ByteString
, prValue :: Maybe ByteString
, provenance :: [(TopicName, PartitionId, Offset)]
} deriving (Eq, Show, Typeable, Generic) Therefore we could immediately know "source" messages offsets in a delivery report. Or we could go completely generic and have something similar to:
But now, when I get a delivery report, how do I know which type I should decode that I don't know what the solution would be, in general :( Maybe the solution with the list of "source offsets" is good enough? |
Hey folks - I created this a while back to solve our needs: http://hackage.haskell.org/package/kafka-client-sync-0.1.1.0/docs/Kafka-Producer-Sync.html Could probably be solved in a better way using opaque, but we're pretty happy with it and have been using it flawlessly in prod for about a month. |
Hi, we just had the exact same requirement of sync producing messages, and found this issue. What do you guys think about integrating/merging this lib back into Thank you @AlexeyRaga @felixmulder ! |
I am sorry, I will find time to look at PRs for the repos that I maintain sometimes soon. |
No worries Alexey, good luck on the job search! |
I think we can close this now that the individual callback function has been set. There's an example in the tests now for how to do this, potentially we could add some docs showing this pattern as well: |
Done in #124 |
Currently, we have a portion of our application where we need to know if the message was successfully sent to the broker.
hw-kafka-client
currently provides this by allowing callbacks on deliveries.Fortunately, there's quite an easy way to support this using the librdkafka bindings: https://github.com/edenhill/librdkafka/wiki/Sync-producer
If it'd be of use to others - we can contribute this.
The text was updated successfully, but these errors were encountered: