Class JmsIO.Read<T>

All Implemented Interfaces:
Serializable, JmsIO.ConnectionFactoryContainer<JmsIO.Read<T>>, HasDisplayData
Enclosing class:
JmsIO

public abstract static class JmsIO.Read<T> extends PTransform<PBegin,PCollection<T>> implements JmsIO.ConnectionFactoryContainer<JmsIO.Read<T>>
A PTransform to read from a JMS destination. See JmsIO for more information on usage and configuration.
See Also:
  • Constructor Details

    • Read

      public Read()
  • Method Details

    • withConnectionFactory

      public JmsIO.Read<T> withConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
      Specify the JMS connection factory to connect to the JMS broker.

      The ConnectionFactory object has to be serializable, if it is not consider using the withConnectionFactoryProviderFn(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Void, ? extends javax.jms.ConnectionFactory>)

      For instance:

      
       pipeline.apply(JmsIO.read().withConnectionFactory(myConnectionFactory)
      
       
      Specified by:
      withConnectionFactory in interface JmsIO.ConnectionFactoryContainer<T>
      Parameters:
      connectionFactory - The JMS ConnectionFactory.
      Returns:
      The corresponding JmsIO.Read.
    • withConnectionFactoryProviderFn

      public JmsIO.Read<T> withConnectionFactoryProviderFn(SerializableFunction<Void,? extends javax.jms.ConnectionFactory> connectionFactoryProviderFn)
      Specify a JMS connection factory provider function to connect to the JMS broker. Use this method in case your ConnectionFactory objects are themselves not serializable, but you can recreate them as needed with a SerializableFunction provider

      For instance:

       pipeline.apply(JmsIO.read().withConnectionFactoryProviderFn(() -> new MyJmsConnectionFactory());
       
      Specified by:
      withConnectionFactoryProviderFn in interface JmsIO.ConnectionFactoryContainer<T>
      Parameters:
      connectionFactoryProviderFn - a SerializableFunction that creates a ConnectionFactory
      Returns:
      The corresponding JmsIO.Read
    • withQueue

      public JmsIO.Read<T> withQueue(String queue)
      Specify the JMS queue destination name where to read messages from. The JmsIO.Read acts as a consumer on the queue.

      This method is exclusive with withTopic(String). The user has to specify a destination: queue or topic.

      For instance:

      
       pipeline.apply(JmsIO.read().withQueue("my-queue")
      
       
      Parameters:
      queue - The JMS queue name where to read messages from.
      Returns:
      The corresponding JmsIO.Read.
    • withTopic

      public JmsIO.Read<T> withTopic(String topic)
      Specify the JMS topic destination name where to receive messages from. The JmsIO.Read acts as a subscriber on the topic.

      This method is exclusive with withQueue(String). The user has to specify a destination: queue or topic.

      For instance:

      
       pipeline.apply(JmsIO.read().withTopic("my-topic")
      
       
      Parameters:
      topic - The JMS topic name.
      Returns:
      The corresponding JmsIO.Read.
    • withUsername

      public JmsIO.Read<T> withUsername(String username)
      Define the username to connect to the JMS broker (authenticated).
    • withPassword

      public JmsIO.Read<T> withPassword(String password)
      Define the password to connect to the JMS broker (authenticated).
    • withMaxNumRecords

      public JmsIO.Read<T> withMaxNumRecords(long maxNumRecords)
      Define the max number of records that the source will read. Using a max number of records different from Long.MAX_VALUE means the source will be Bounded, and will stop once the max number of records read is reached.

      For instance:

      
       pipeline.apply(JmsIO.read().withNumRecords(1000)
      
       
      Parameters:
      maxNumRecords - The max number of records to read from the JMS destination.
      Returns:
      The corresponding JmsIO.Read.
    • withMaxReadTime

      public JmsIO.Read<T> withMaxReadTime(Duration maxReadTime)
      Define the max read time that the source will read. Using a non null max read time duration means the source will be Bounded, and will stop once the max read time is reached.

      For instance:

      
       pipeline.apply(JmsIO.read().withMaxReadTime(Duration.minutes(10))
      
       
      Parameters:
      maxReadTime - The max read time duration.
      Returns:
      The corresponding JmsIO.Read.
    • withMessageMapper

      public JmsIO.Read<T> withMessageMapper(JmsIO.MessageMapper<T> messageMapper)
    • withCoder

      public JmsIO.Read<T> withCoder(Coder<T> coder)
    • withAutoScaler

      public JmsIO.Read<T> withAutoScaler(AutoScaler autoScaler)
      Sets the AutoScaler to use for reporting backlog during the execution of this source.
    • withCloseTimeout

      public JmsIO.Read<T> withCloseTimeout(Duration closeTimeout)
      Sets the amount of time to wait for callbacks from the runner stating that the output has been durably persisted before closing the connection to the JMS broker. Any callbacks that do not occur will cause unacknowledged messages to be returned to the JMS broker and redelivered to other clients.
    • withReceiveTimeout

      public JmsIO.Read<T> withReceiveTimeout(Duration receiveTimeout)
      If set, block for the Duration of timeout for each poll to new JMS record if the previous poll returns no new record.

      Use this option if the requirement for read latency is not a concern or excess client polling has resulted network issues.

    • withRequiresDeduping

      public JmsIO.Read<T> withRequiresDeduping()
      If set, requires runner deduplication for the messages. Each message is identified by its JMSMessageID.
    • expand

      public PCollection<T> expand(PBegin input)
      Description copied from class: PTransform
      Override this method to specify how this PTransform should be expanded on the given InputT.

      NOTE: This method should not be called directly. Instead apply the PTransform should be applied to the InputT using the apply method.

      Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).

      Specified by:
      expand in class PTransform<PBegin,PCollection<T>>
    • populateDisplayData

      public void populateDisplayData(DisplayData.Builder builder)
      Description copied from class: PTransform
      Register display data for the given transform or component.

      populateDisplayData(DisplayData.Builder) is invoked by Pipeline runners to collect display data via DisplayData.from(HasDisplayData). Implementations may call super.populateDisplayData(builder) in order to register display data in the current namespace, but should otherwise use subcomponent.populateDisplayData(builder) to use the namespace of the subcomponent.

      By default, does not register any display data. Implementors may override this method to provide their own display data.

      Specified by:
      populateDisplayData in interface HasDisplayData
      Overrides:
      populateDisplayData in class PTransform<PBegin,PCollection<T>>
      Parameters:
      builder - The builder to populate with display data.
      See Also: