Package org.apache.beam.sdk.io.jms
Class JmsIO.Read<T>
- java.lang.Object
-
- org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PBegin,org.apache.beam.sdk.values.PCollection<T>>
-
- org.apache.beam.sdk.io.jms.JmsIO.Read<T>
-
- All Implemented Interfaces:
java.io.Serializable,JmsIO.ConnectionFactoryContainer<JmsIO.Read<T>>,org.apache.beam.sdk.transforms.display.HasDisplayData
- Enclosing class:
- JmsIO
public abstract static class JmsIO.Read<T> extends org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PBegin,org.apache.beam.sdk.values.PCollection<T>> implements JmsIO.ConnectionFactoryContainer<JmsIO.Read<T>>
APTransformto read from a JMS destination. SeeJmsIOfor more information on usage and configuration.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Read()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.beam.sdk.values.PCollection<T>expand(org.apache.beam.sdk.values.PBegin input)voidpopulateDisplayData(org.apache.beam.sdk.transforms.display.DisplayData.Builder builder)JmsIO.Read<T>withAutoScaler(AutoScaler autoScaler)Sets theAutoScalerto use for reporting backlog during the execution of this source.JmsIO.Read<T>withCloseTimeout(org.joda.time.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.JmsIO.Read<T>withCoder(org.apache.beam.sdk.coders.Coder<T> coder)JmsIO.Read<T>withConnectionFactory(javax.jms.ConnectionFactory connectionFactory)Specify the JMS connection factory to connect to the JMS broker.JmsIO.Read<T>withConnectionFactoryProviderFn(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Void,? extends javax.jms.ConnectionFactory> connectionFactoryProviderFn)Specify a JMS connection factory provider function to connect to the JMS broker.JmsIO.Read<T>withMaxNumRecords(long maxNumRecords)Define the max number of records that the source will read.JmsIO.Read<T>withMaxReadTime(org.joda.time.Duration maxReadTime)Define the max read time that the source will read.JmsIO.Read<T>withMessageMapper(JmsIO.MessageMapper<T> messageMapper)JmsIO.Read<T>withPassword(java.lang.String password)Define the password to connect to the JMS broker (authenticated).JmsIO.Read<T>withQueue(java.lang.String queue)Specify the JMS queue destination name where to read messages from.JmsIO.Read<T>withReceiveTimeout(org.joda.time.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.JmsIO.Read<T>withRequiresDeduping()If set, requires runner deduplication for the messages.JmsIO.Read<T>withTopic(java.lang.String topic)Specify the JMS topic destination name where to receive messages from.JmsIO.Read<T>withUsername(java.lang.String username)Define the username to connect to the JMS broker (authenticated).-
Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, setDisplayData, setResourceHints, toString, validate, validate
-
-
-
-
Method Detail
-
withConnectionFactory
public JmsIO.Read<T> withConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
Specify the JMS connection factory to connect to the JMS broker.The
ConnectionFactoryobject has to be serializable, if it is not consider using thewithConnectionFactoryProviderFn(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Void, ? extends javax.jms.ConnectionFactory>)For instance:
pipeline.apply(JmsIO.read().withConnectionFactory(myConnectionFactory)- Specified by:
withConnectionFactoryin interfaceJmsIO.ConnectionFactoryContainer<T>- Parameters:
connectionFactory- The JMSConnectionFactory.- Returns:
- The corresponding
JmsIO.Read.
-
withConnectionFactoryProviderFn
public JmsIO.Read<T> withConnectionFactoryProviderFn(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Void,? extends javax.jms.ConnectionFactory> connectionFactoryProviderFn)
Specify a JMS connection factory provider function to connect to the JMS broker. Use this method in case yourConnectionFactoryobjects are themselves not serializable, but you can recreate them as needed with aSerializableFunctionproviderFor instance:
pipeline.apply(JmsIO.read().withConnectionFactoryProviderFn(() -> new MyJmsConnectionFactory());- Specified by:
withConnectionFactoryProviderFnin interfaceJmsIO.ConnectionFactoryContainer<T>- Parameters:
connectionFactoryProviderFn- aSerializableFunctionthat creates aConnectionFactory- Returns:
- The corresponding
JmsIO.Read
-
withQueue
public JmsIO.Read<T> withQueue(java.lang.String queue)
Specify the JMS queue destination name where to read messages from. TheJmsIO.Readacts 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(java.lang.String topic)
Specify the JMS topic destination name where to receive messages from. TheJmsIO.Readacts 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(java.lang.String username)
Define the username to connect to the JMS broker (authenticated).
-
withPassword
public JmsIO.Read<T> withPassword(java.lang.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 fromLong.MAX_VALUEmeans the source will beBounded, 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(org.joda.time.Duration maxReadTime)
Define the max read time that the source will read. Using a non null max read time duration means the source will beBounded, 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(org.apache.beam.sdk.coders.Coder<T> coder)
-
withAutoScaler
public JmsIO.Read<T> withAutoScaler(AutoScaler autoScaler)
Sets theAutoScalerto use for reporting backlog during the execution of this source.
-
withCloseTimeout
public JmsIO.Read<T> withCloseTimeout(org.joda.time.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(org.joda.time.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 itsJMSMessageID.
-
expand
public org.apache.beam.sdk.values.PCollection<T> expand(org.apache.beam.sdk.values.PBegin input)
- Specified by:
expandin classorg.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PBegin,org.apache.beam.sdk.values.PCollection<T>>
-
populateDisplayData
public void populateDisplayData(org.apache.beam.sdk.transforms.display.DisplayData.Builder builder)
- Specified by:
populateDisplayDatain interfaceorg.apache.beam.sdk.transforms.display.HasDisplayData- Overrides:
populateDisplayDatain classorg.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PBegin,org.apache.beam.sdk.values.PCollection<T>>
-
-