@SupportsBatching @InputRequirement(value=INPUT_FORBIDDEN) @Tags(value={"listen","tcp","record","tls","ssl"}) @CapabilityDescription(value="Listens for incoming TCP connections and reads data from each connection using a configured record reader, and writes the records to a flow file using a configured record writer. The type of record reader selected will determine how clients are expected to send data. For example, when using a Grok reader to read logs, a client can keep an open connection and continuously stream data, but when using an JSON reader, the client cannot send an array of JSON documents and then send another array on the same connection, as the reader would be in a bad state at that point. Records will be read from the connection in blocking mode, and will timeout according to the Read Timeout specified in the processor. If the read times out, or if any other error is encountered when reading, the connection will be closed, and any records read up to that point will be handled according to the configured Read Error Strategy (Discard or Transfer). In cases where clients are keeping a connection open, the concurrent tasks for the processor should be adjusted to match the Max Number of TCP Connections allowed, so that there is a task processing each connection. The processor can be configured to use an SSL Context Service to only allow secure connections. When connected clients present certificates for mutual TLS authentication, the Distinguished Names of the client certificate\'s issuer and subject are added to the outgoing FlowFiles as attributes. The processor does not perform authorization based on Distinguished Name values, but since these values are attached to the outgoing FlowFiles, authorization can be implemented based on these attributes.") @WritesAttribute(attribute="tcp.sender",description="The host that sent the data.") @WritesAttribute(attribute="tcp.port",description="The port that the processor accepted the connection on.") @WritesAttribute(attribute="record.count",description="The number of records written to the flow file.") @WritesAttribute(attribute="mime.type",description="The mime-type of the writer used to write the records to the flow file.") @WritesAttribute(attribute="client.certificate.issuer.dn",description="For connections using mutual TLS, the Distinguished Name of the Certificate Authority that issued the client\'s certificate is attached to the FlowFile.") @WritesAttribute(attribute="client.certificate.subject.dn",description="For connections using mutual TLS, the Distinguished Name of the client certificate\'s owner (subject) is attached to the FlowFile.") public class ListenTCPRecord extends AbstractProcessor
| Modifier and Type | Field and Description |
|---|---|
(package private) static PropertyDescriptor |
CLIENT_AUTH |
private static String |
CLIENT_CERTIFICATE_ISSUER_DN_ATTRIBUTE |
private static String |
CLIENT_CERTIFICATE_SUBJECT_DN_ATTRIBUTE |
private org.apache.nifi.record.listen.SocketChannelRecordReaderDispatcher |
dispatcher |
(package private) static AllowableValue |
ERROR_HANDLING_DISCARD |
(package private) static AllowableValue |
ERROR_HANDLING_TRANSFER |
(package private) static PropertyDescriptor |
MAX_CONNECTIONS |
(package private) static PropertyDescriptor |
MAX_SOCKET_BUFFER_SIZE |
(package private) static int |
POLL_TIMEOUT_MS |
private int |
port |
(package private) static PropertyDescriptor |
PORT |
(package private) static List<PropertyDescriptor> |
PROPERTIES |
(package private) static PropertyDescriptor |
READ_TIMEOUT |
(package private) static PropertyDescriptor |
READER_ERROR_HANDLING_STRATEGY |
(package private) static PropertyDescriptor |
RECORD_BATCH_SIZE |
(package private) static PropertyDescriptor |
RECORD_READER |
(package private) static PropertyDescriptor |
RECORD_WRITER |
(package private) static Relationship |
REL_SUCCESS |
(package private) static Set<Relationship> |
RELATIONSHIPS |
private BlockingQueue<org.apache.nifi.record.listen.SocketChannelRecordReader> |
socketReaders |
(package private) static PropertyDescriptor |
SSL_CONTEXT_SERVICE |
| Constructor and Description |
|---|
ListenTCPRecord() |
| Modifier and Type | Method and Description |
|---|---|
private void |
addClientCertificateAttributes(Map<String,String> attributes,
org.apache.nifi.record.listen.SocketChannelRecordReader socketRecordReader) |
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
int |
getListeningPort() |
Set<Relationship> |
getRelationships() |
private String |
getRemoteAddress(org.apache.nifi.record.listen.SocketChannelRecordReader socketChannelRecordReader) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
void |
onScheduled(ProcessContext context) |
void |
onStopped() |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private org.apache.nifi.record.listen.SocketChannelRecordReader |
pollForSocketRecordReader() |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateprivate static final String CLIENT_CERTIFICATE_SUBJECT_DN_ATTRIBUTE
private static final String CLIENT_CERTIFICATE_ISSUER_DN_ATTRIBUTE
static final PropertyDescriptor PORT
static final PropertyDescriptor READ_TIMEOUT
static final PropertyDescriptor MAX_SOCKET_BUFFER_SIZE
static final PropertyDescriptor MAX_CONNECTIONS
static final PropertyDescriptor RECORD_READER
static final PropertyDescriptor RECORD_WRITER
static final AllowableValue ERROR_HANDLING_DISCARD
static final AllowableValue ERROR_HANDLING_TRANSFER
static final PropertyDescriptor READER_ERROR_HANDLING_STRATEGY
static final PropertyDescriptor RECORD_BATCH_SIZE
static final PropertyDescriptor SSL_CONTEXT_SERVICE
static final PropertyDescriptor CLIENT_AUTH
static final Relationship REL_SUCCESS
static final List<PropertyDescriptor> PROPERTIES
static final Set<Relationship> RELATIONSHIPS
static final int POLL_TIMEOUT_MS
private volatile int port
private volatile org.apache.nifi.record.listen.SocketChannelRecordReaderDispatcher dispatcher
private final BlockingQueue<org.apache.nifi.record.listen.SocketChannelRecordReader> socketReaders
public Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponent@OnScheduled public void onScheduled(ProcessContext context) throws IOException
IOExceptionpublic int getListeningPort()
@OnStopped public void onStopped()
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprivate org.apache.nifi.record.listen.SocketChannelRecordReader pollForSocketRecordReader()
private String getRemoteAddress(org.apache.nifi.record.listen.SocketChannelRecordReader socketChannelRecordReader)
private void addClientCertificateAttributes(Map<String,String> attributes, org.apache.nifi.record.listen.SocketChannelRecordReader socketRecordReader) throws SSLPeerUnverifiedException
SSLPeerUnverifiedExceptionCopyright © 2023 Apache NiFi Project. All rights reserved.