@SupportsBatching @InputRequirement(value=INPUT_FORBIDDEN) @Tags(value={"listen","tcp","tls","ssl"}) @CapabilityDescription(value="Listens for incoming TCP connections and reads data from each connection using a line separator as the message demarcator. The default behavior is for each message to produce a single FlowFile, however this can be controlled by increasing the Batch Size to a larger value for higher throughput. The Receive Buffer Size must be set as large as the largest messages expected to be received, meaning if every 100kb there is a line separator, then the Receive Buffer Size must be greater than 100kb. 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 sending host of the messages.") @WritesAttribute(attribute="tcp.port",description="The sending port the messages were received.") @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 ListenTCP extends AbstractProcessor
| Modifier and Type | Field and Description |
|---|---|
static PropertyDescriptor |
CLIENT_AUTH |
private static String |
CLIENT_CERTIFICATE_ISSUER_DN_ATTRIBUTE |
private static String |
CLIENT_CERTIFICATE_SUBJECT_DN_ATTRIBUTE |
protected List<PropertyDescriptor> |
descriptors |
protected BlockingQueue<ByteArrayMessage> |
errorEvents |
protected EventBatcher<ByteArrayMessage> |
eventBatcher |
protected TrackingLinkedBlockingQueue<ByteArrayMessage> |
events |
private int |
eventsCapacity |
protected EventServer |
eventServer |
protected static PropertyDescriptor |
IDLE_CONNECTION_TIMEOUT |
static PropertyDescriptor |
MAX_RECV_THREAD_POOL_SIZE |
protected byte[] |
messageDemarcatorBytes |
private AtomicLong |
nextTrackingLog |
protected static PropertyDescriptor |
POOL_RECV_BUFFERS |
protected int |
port |
static Relationship |
REL_SUCCESS |
protected Set<Relationship> |
relationships |
static PropertyDescriptor |
SSL_CONTEXT_SERVICE |
private static long |
TRACKING_LOG_INTERVAL |
| Constructor and Description |
|---|
ListenTCP() |
| Modifier and Type | Method and Description |
|---|---|
private void |
addClientCertificateAttributes(Map<String,String> attributes,
ByteArrayMessage event) |
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
protected Map<String,String> |
getAttributes(FlowFileEventBatch<ByteArrayMessage> batch) |
private EventBatcher<ByteArrayMessage> |
getEventBatcher() |
int |
getListeningPort() |
private String |
getMessageDemarcator(ProcessContext context) |
Set<Relationship> |
getRelationships() |
List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected String |
getTransitUri(FlowFileEventBatch<ByteArrayMessage> batch) |
protected void |
init(ProcessorInitializationContext context) |
void |
onScheduled(ProcessContext context) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private void |
processEvents(ProcessSession session,
Map<String,FlowFileEventBatch<ByteArrayMessage>> batches) |
private void |
processTrackingLog() |
void |
stopped() |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, 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
public static final PropertyDescriptor SSL_CONTEXT_SERVICE
public static final PropertyDescriptor CLIENT_AUTH
public static final PropertyDescriptor MAX_RECV_THREAD_POOL_SIZE
protected static final PropertyDescriptor POOL_RECV_BUFFERS
protected static final PropertyDescriptor IDLE_CONNECTION_TIMEOUT
public static final Relationship REL_SUCCESS
private static final long TRACKING_LOG_INTERVAL
private final AtomicLong nextTrackingLog
private int eventsCapacity
protected List<PropertyDescriptor> descriptors
protected Set<Relationship> relationships
protected volatile int port
protected volatile TrackingLinkedBlockingQueue<ByteArrayMessage> events
protected volatile BlockingQueue<ByteArrayMessage> errorEvents
protected volatile EventServer eventServer
protected volatile byte[] messageDemarcatorBytes
protected volatile EventBatcher<ByteArrayMessage> eventBatcher
protected void init(ProcessorInitializationContext context)
init in class AbstractSessionFactoryProcessor@OnScheduled public void onScheduled(ProcessContext context) throws IOException
IOExceptionpublic int getListeningPort()
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprivate void processEvents(ProcessSession session, Map<String,FlowFileEventBatch<ByteArrayMessage>> batches)
@OnStopped public void stopped()
protected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponentprotected Map<String,String> getAttributes(FlowFileEventBatch<ByteArrayMessage> batch)
protected String getTransitUri(FlowFileEventBatch<ByteArrayMessage> batch)
public final Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorpublic List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprivate String getMessageDemarcator(ProcessContext context)
private EventBatcher<ByteArrayMessage> getEventBatcher()
private void addClientCertificateAttributes(Map<String,String> attributes, ByteArrayMessage event)
private void processTrackingLog()
Copyright © 2023 Apache NiFi Project. All rights reserved.