mirror of https://github.com/apache/nifi.git
NIFI-220: Added error handling that was missing for one instance of calling producer.send, also indicated how many messages were sent per FlowFile in log message and provenance event
This commit is contained in:
parent
95b22a0aee
commit
a77fb50116
|
@ -366,7 +366,11 @@ public class PutKafka extends AbstractProcessor {
|
|||
|
||||
// If there are messages left, send them
|
||||
if ( !messages.isEmpty() ) {
|
||||
try {
|
||||
producer.send(messages);
|
||||
} catch (final Exception e) {
|
||||
throw new ProcessException("Failed to send messages to Kafka", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -374,9 +378,9 @@ public class PutKafka extends AbstractProcessor {
|
|||
|
||||
final long nanos = System.nanoTime() - start;
|
||||
|
||||
session.getProvenanceReporter().send(flowFile, "kafka://" + topic);
|
||||
session.getProvenanceReporter().send(flowFile, "kafka://" + topic, "Sent " + messagesSent.get() + " messages");
|
||||
session.transfer(flowFile, REL_SUCCESS);
|
||||
getLogger().info("Successfully sent {} to Kafka in {} millis", new Object[] {flowFile, TimeUnit.NANOSECONDS.toMillis(nanos)});
|
||||
getLogger().info("Successfully sent {} messages to Kafka for {} in {} millis", new Object[] {messagesSent.get(), flowFile, TimeUnit.NANOSECONDS.toMillis(nanos)});
|
||||
} catch (final ProcessException pe) {
|
||||
error = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue