Class ListenTCP

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.ListenTCP
All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.processor.Processor

@SupportsBatching @InputRequirement(INPUT_FORBIDDEN) @Tags({"listen","tcp","tls","ssl"}) @CapabilityDescription("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 org.apache.nifi.processor.AbstractProcessor
  • Field Details

    • CLIENT_CERTIFICATE_SUBJECT_DN_ATTRIBUTE

      private static final String CLIENT_CERTIFICATE_SUBJECT_DN_ATTRIBUTE
      See Also:
    • CLIENT_CERTIFICATE_ISSUER_DN_ATTRIBUTE

      private static final String CLIENT_CERTIFICATE_ISSUER_DN_ATTRIBUTE
      See Also:
    • SSL_CONTEXT_SERVICE

      public static final org.apache.nifi.components.PropertyDescriptor SSL_CONTEXT_SERVICE
    • CLIENT_AUTH

      public static final org.apache.nifi.components.PropertyDescriptor CLIENT_AUTH
    • POOL_RECV_BUFFERS

      protected static final org.apache.nifi.components.PropertyDescriptor POOL_RECV_BUFFERS
    • IDLE_CONNECTION_TIMEOUT

      protected static final org.apache.nifi.components.PropertyDescriptor IDLE_CONNECTION_TIMEOUT
    • PROPERTY_DESCRIPTORS

      private static final List<org.apache.nifi.components.PropertyDescriptor> PROPERTY_DESCRIPTORS
    • REL_SUCCESS

      public static final org.apache.nifi.processor.Relationship REL_SUCCESS
    • RELATIONSHIPS

      private static final Set<org.apache.nifi.processor.Relationship> RELATIONSHIPS
    • TRACKING_LOG_INTERVAL

      private static final long TRACKING_LOG_INTERVAL
      See Also:
    • nextTrackingLog

      private final AtomicLong nextTrackingLog
    • eventsCapacity

      private int eventsCapacity
    • port

      protected volatile int port
    • events

      protected volatile TrackingLinkedBlockingQueue<ByteArrayMessage> events
    • errorEvents

      protected volatile BlockingQueue<ByteArrayMessage> errorEvents
    • eventServer

      protected volatile EventServer eventServer
    • messageDemarcatorBytes

      protected volatile byte[] messageDemarcatorBytes
    • eventBatcher

      protected volatile EventBatcher<ByteArrayMessage> eventBatcher
  • Constructor Details

    • ListenTCP

      public ListenTCP()
  • Method Details

    • migrateProperties

      public void migrateProperties(PropertyConfiguration config)
    • onScheduled

      @OnScheduled public void onScheduled(org.apache.nifi.processor.ProcessContext context) throws IOException
      Throws:
      IOException
    • getListeningPort

      public int getListeningPort()
    • onTrigger

      public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException
      Specified by:
      onTrigger in class org.apache.nifi.processor.AbstractProcessor
      Throws:
      org.apache.nifi.processor.exception.ProcessException
    • processEvents

      private void processEvents(org.apache.nifi.processor.ProcessSession session, Map<String,FlowFileEventBatch<ByteArrayMessage>> batches)
    • stopped

      @OnStopped public void stopped()
    • getAttributes

      protected Map<String,String> getAttributes(FlowFileEventBatch<ByteArrayMessage> batch)
    • getTransitUri

      protected String getTransitUri(FlowFileEventBatch<ByteArrayMessage> batch)
    • getRelationships

      public final Set<org.apache.nifi.processor.Relationship> getRelationships()
      Specified by:
      getRelationships in interface org.apache.nifi.processor.Processor
      Overrides:
      getRelationships in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • getSupportedPropertyDescriptors

      public List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • getMessageDemarcator

      private String getMessageDemarcator(org.apache.nifi.processor.ProcessContext context)
    • getEventBatcher

      private EventBatcher<ByteArrayMessage> getEventBatcher()
    • addClientCertificateAttributes

      private void addClientCertificateAttributes(Map<String,String> attributes, ByteArrayMessage event)
    • processTrackingLog

      private void processTrackingLog()