use of org.apache.nifi.processor.util.listen.response.ChannelResponder in project nifi by apache.
the class ListenBeats method respond.
protected void respond(final BeatsEvent event, final BeatsResponse beatsResponse) {
final ChannelResponse response = new BeatsChannelResponse(beatsEncoder, beatsResponse);
final ChannelResponder responder = event.getResponder();
responder.addResponse(response);
try {
responder.respond();
} catch (IOException e) {
getLogger().error("Error sending response for transaction {} due to {}", new Object[] { event.getSeqNumber(), e.getMessage() }, e);
}
}
use of org.apache.nifi.processor.util.listen.response.ChannelResponder in project nifi by apache.
the class ListenRELP method respond.
protected void respond(final RELPEvent event, final RELPResponse relpResponse) {
final ChannelResponse response = new RELPChannelResponse(relpEncoder, relpResponse);
final ChannelResponder responder = event.getResponder();
responder.addResponse(response);
try {
responder.respond();
} catch (IOException e) {
getLogger().error("Error sending response for transaction {} due to {}", new Object[] { event.getTxnr(), e.getMessage() }, e);
}
}
use of org.apache.nifi.processor.util.listen.response.ChannelResponder in project nifi by apache.
the class ListenLumberjack method respond.
protected void respond(final LumberjackEvent event, final LumberjackResponse lumberjackResponse) {
final ChannelResponse response = new LumberjackChannelResponse(lumberjackEncoder, lumberjackResponse);
final ChannelResponder responder = event.getResponder();
responder.addResponse(response);
try {
responder.respond();
} catch (IOException e) {
getLogger().error("Error sending response for transaction {} due to {}", new Object[] { event.getSeqNumber(), e.getMessage() }, e);
}
}
use of org.apache.nifi.processor.util.listen.response.ChannelResponder in project nifi by apache.
the class TestLumberjackEventFactory method testCreateLumberJackEvent.
@Test
public void testCreateLumberJackEvent() {
final String sender = "testsender1";
final byte[] data = "this is a test line".getBytes();
final long seqNumber = 1;
final String fields = "{\"file\":\"test\"}";
final Map<String, String> metadata = new HashMap<>();
metadata.put(EventFactory.SENDER_KEY, sender);
metadata.put(LumberjackMetadata.SEQNUMBER_KEY, String.valueOf(seqNumber));
metadata.put(LumberjackMetadata.FIELDS_KEY, String.valueOf(fields));
final ChannelResponder responder = new SocketChannelResponder(null);
final EventFactory<LumberjackEvent> factory = new LumberjackEventFactory();
final LumberjackEvent event = factory.create(data, metadata, responder);
Assert.assertEquals(sender, event.getSender());
Assert.assertEquals(seqNumber, event.getSeqNumber());
Assert.assertEquals(fields, event.getFields());
Assert.assertEquals(data, event.getData());
}
use of org.apache.nifi.processor.util.listen.response.ChannelResponder in project nifi by apache.
the class TestRELPEventFactory method testCreateRELPEvent.
@Test
public void testCreateRELPEvent() {
final byte[] data = "this is an event".getBytes(StandardCharsets.UTF_8);
final String sender = "sender1";
final long txnr = 1;
final String command = "syslog";
final Map<String, String> metadata = new HashMap<>();
metadata.put(EventFactory.SENDER_KEY, sender);
metadata.put(RELPMetadata.TXNR_KEY, String.valueOf(txnr));
metadata.put(RELPMetadata.COMMAND_KEY, command);
final ChannelResponder responder = new SocketChannelResponder(null);
final EventFactory<RELPEvent> factory = new RELPEventFactory();
final RELPEvent event = factory.create(data, metadata, responder);
Assert.assertEquals(data, event.getData());
Assert.assertEquals(sender, event.getSender());
Assert.assertEquals(txnr, event.getTxnr());
Assert.assertEquals(command, event.getCommand());
Assert.assertEquals(responder, event.getResponder());
}
Aggregations