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

Stream Enrich: use Kafka callback based API to detect failures to send messages #2974

Closed
simplesteph opened this issue Dec 1, 2016 · 1 comment

Comments

@simplesteph
Copy link

simplesteph commented Dec 1, 2016

KafkaProducer.send is asynchronous and I don't know if that will fail directly. It seems you need to provide a callback to catch exceptions:

https://kafka.apache.org/0100/javadoc/index.html?org/apache/kafka/clients/producer/KafkaProducer.html
(send method)

Fully non-blocking usage can make use of the Callback parameter to provide a callback that will be invoked when the request is complete.

 ProducerRecord<byte[],byte[]> record = new ProducerRecord<byte[],byte[]>("the-topic", key, value);
 producer.send(myRecord,
               new Callback() {
                   public void onCompletion(RecordMetadata metadata, Exception e) {
                       if(e != null)
                           e.printStackTrace();
                       System.out.println("The offset of the record we just sent is: " + metadata.offset());
                   }
               });

vs

@alexanderdean alexanderdean changed the title Kafka exception on send are not catched correctly Kafka exception on send are not caught correctly Dec 1, 2016
@alexanderdean alexanderdean added this to the Kafka #2 milestone Dec 1, 2016
@alexanderdean
Copy link
Member

Good catch!

@BenFradet BenFradet modified the milestones: R92 Virunum (Stream refresh), Kafka #2 Aug 10, 2017
@BenFradet BenFradet self-assigned this Aug 10, 2017
@BenFradet BenFradet changed the title Kafka exception on send are not caught correctly Stream Enrich: Kafka exception on send are not caught correctly Aug 10, 2017
@BenFradet BenFradet changed the title Stream Enrich: Kafka exception on send are not caught correctly Stream Enrich: use Kafka callback based API to detect failures to send messages Aug 10, 2017
BenFradet added a commit that referenced this issue Aug 25, 2017
BenFradet added a commit that referenced this issue Aug 25, 2017
BenFradet added a commit that referenced this issue Sep 8, 2017
BenFradet added a commit that referenced this issue Sep 15, 2017
BenFradet added a commit that referenced this issue Sep 15, 2017
BenFradet added a commit that referenced this issue Sep 15, 2017
BenFradet added a commit that referenced this issue Sep 18, 2017
BenFradet added a commit that referenced this issue Sep 19, 2017
BenFradet added a commit that referenced this issue Sep 19, 2017
BenFradet added a commit that referenced this issue Sep 19, 2017
BenFradet added a commit that referenced this issue Sep 22, 2017
BenFradet added a commit that referenced this issue Sep 22, 2017
BenFradet added a commit that referenced this issue Sep 26, 2017
BenFradet added a commit that referenced this issue Sep 26, 2017
BenFradet added a commit that referenced this issue Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants