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

Support sync interface #32

Closed
xiaojun789 opened this issue Dec 4, 2013 · 6 comments
Closed

Support sync interface #32

xiaojun789 opened this issue Dec 4, 2013 · 6 comments

Comments

@xiaojun789
Copy link

Hi,
currently the librdkafka only support async, but in my case, we prefer use sync interface.
Do you have plan to support this, Thanks~!

@edenhill
Copy link
Contributor

edenhill commented Dec 4, 2013

Can you tell me about your use case for this?
Do you want to send one or multiple messages in each blocking synchronic produce_sync() call?

@xiaojun789
Copy link
Author

Hi,
we want to do the fail-tolerant operation, when the kafka cluster is not available. Currently there is message deliver callback. but some case the fail-tolerant will process twice. so we ask for sync interface.

I think you can give choice for log count sending per call.

Thanks~!

@edenhill
Copy link
Contributor

edenhill commented Dec 5, 2013

What do you mean by "fail-toerant will process twice"?
Do you mean the message send retry that librdkafka performs if the broker connection goes down?
The retry count is configurable through message.send.max.retries which defaults to 2.

@xiaojun789
Copy link
Author

fail-tolerant is implement in our program. if send the log to kafka failed, we should process it in our environment. and when the kafka is recover, we will send failed log to kafka again.
if we use async interface it is not good for this. we must wait the deliver callback method is callback, and do such fail-tolerant things. yesterday , I already find a way to avoid duplicated process failed logs message. use the last parameter of rd_kafka_produce().

but I think sync interface is easy for user to deal with this situation.

Thanks~!

@edenhill
Copy link
Contributor

edenhill commented Dec 6, 2013

I understand.
The drawbacks of a sync interface is that only a small number of messages may be produced at a given time and the application must queue messages for producing. The throughput is also minimal, at best, and is adversely affected by the application <-> broker latency.
Having said that I will look in to making a sync producer interface.

The current async produce interface provides full message tracking and reliability.
For each message produced the application may provide a pointer (that typically points to some application per-message object) called msg_opaque.
This msg_opaque value is provided to the application in the delivery report (dr) callback, along with an error code (to indicate success or specific failures), thus allowing the application to take actions if delivery of a message fails.

Read this for more information:
https://github.com/edenhill/librdkafka/blob/master/INTRODUCTION.md#producer-api

The async produce interface also offers high performance and is not particularily affected by a high latency between application and broker.

@edenhill
Copy link
Contributor

See this wiki page for how to implement a sync producer in your application:
https://github.com/edenhill/librdkafka/wiki/Sync-producer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants