[ 
https://issues.apache.org/jira/browse/KAFKA-1838?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tom Lee updated KAFKA-1838:
---------------------------
    Labels: patch  (was: )
    Status: Patch Available  (was: Open)

The attached patch modifies the Producer.send(...) internals for sync & async 
producers alike such that we try to throw a ProducerInterruptedException 
runtime exception instead of QueueFullException/UndeclaredThrowableException. 
It includes a test that seems to indicate that the async path works as expected 
(the sync path is kind of trivial in comparison.)

> Better interrupt handling in producers
> --------------------------------------
>
>                 Key: KAFKA-1838
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1838
>             Project: Kafka
>          Issue Type: Improvement
>          Components: producer 
>    Affects Versions: 0.8.1.1
>            Reporter: Tom Lee
>            Assignee: Jun Rao
>              Labels: patch
>         Attachments: interruptable-producers-v1.patch
>
>
> Interrupting a thread where a Producer is in use can cause unexpected 
> behavior. In the case of an async type producer, interrupting the producer 
> thread will like lead to a QueueFullException with the default configuration 
> (see 
> https://github.com/apache/kafka/blob/0.8.1.1/core/src/main/scala/kafka/producer/Producer.scala#L105-L112
>  )
> This obviously can't be safely be used in client code to determine if the 
> thread was interrupted because the async producer's message queue may simply 
> be backed up. It's important to be able to distinguish between interrupts vs 
> full queues so client thread pools can be shutdown properly etc.
> In the case of a sync producer, there's the possibility an 
> InterruptedException will bubble up out of Producer.send. This will likely 
> result in an UndeclaredThrowableException in Java code -- this is more 
> helpful than a QueueFullException, but it's still somewhat awkward.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to