Class JmsIO.Read<T>
- All Implemented Interfaces:
Serializable
,JmsIO.ConnectionFactoryContainer<JmsIO.Read<T>>
,HasDisplayData
- Enclosing class:
JmsIO
PTransform
to read from a JMS destination. See JmsIO
for more information on
usage and configuration.- See Also:
-
Field Summary
Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOverride this method to specify how thisPTransform
should be expanded on the givenInputT
.void
populateDisplayData
(DisplayData.Builder builder) Register display data for the given transform or component.withAutoScaler
(AutoScaler autoScaler) Sets theAutoScaler
to use for reporting backlog during the execution of this source.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.withConnectionFactory
(javax.jms.ConnectionFactory connectionFactory) Specify the JMS connection factory to connect to the JMS broker.withConnectionFactoryProviderFn
(SerializableFunction<Void, ? extends javax.jms.ConnectionFactory> connectionFactoryProviderFn) Specify a JMS connection factory provider function to connect to the JMS broker.withMaxNumRecords
(long maxNumRecords) Define the max number of records that the source will read.withMaxReadTime
(Duration maxReadTime) Define the max read time that the source will read.withMessageMapper
(JmsIO.MessageMapper<T> messageMapper) withPassword
(String password) Define the password to connect to the JMS broker (authenticated).Specify the JMS queue destination name where to read messages from.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.If set, requires runner deduplication for the messages.Specify the JMS topic destination name where to receive messages from.withUsername
(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
-
Constructor Details
-
Read
public Read()
-
-
Method Details
-
withConnectionFactory
Specify the JMS connection factory to connect to the JMS broker.The
ConnectionFactory
object 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:
withConnectionFactory
in interfaceJmsIO.ConnectionFactoryContainer<T>
- Parameters:
connectionFactory
- The JMSConnectionFactory
.- 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 yourConnectionFactory
objects are themselves not serializable, but you can recreate them as needed with aSerializableFunction
providerFor instance:
pipeline.apply(JmsIO.read().withConnectionFactoryProviderFn(() -> new MyJmsConnectionFactory());
- Specified by:
withConnectionFactoryProviderFn
in interfaceJmsIO.ConnectionFactoryContainer<T>
- Parameters:
connectionFactoryProviderFn
- aSerializableFunction
that creates aConnectionFactory
- Returns:
- The corresponding
JmsIO.Read
-
withQueue
Specify the JMS queue destination name where to read messages from. TheJmsIO.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
Specify the JMS topic destination name where to receive messages from. TheJmsIO.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
Define the username to connect to the JMS broker (authenticated). -
withPassword
Define the password to connect to the JMS broker (authenticated). -
withMaxNumRecords
Define the max number of records that the source will read. Using a max number of records different fromLong.MAX_VALUE
means 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
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
-
withCoder
-
withAutoScaler
Sets theAutoScaler
to use for reporting backlog during the execution of this source. -
withCloseTimeout
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
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
If set, requires runner deduplication for the messages. Each message is identified by itsJMSMessageID
. -
expand
Description copied from class:PTransform
Override this method to specify how thisPTransform
should be expanded on the givenInputT
.NOTE: This method should not be called directly. Instead apply the
PTransform
should be applied to theInputT
using theapply
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 classPTransform<PBegin,
PCollection<T>>
-
populateDisplayData
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 viaDisplayData.from(HasDisplayData)
. Implementations may callsuper.populateDisplayData(builder)
in order to register display data in the current namespace, but should otherwise usesubcomponent.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 interfaceHasDisplayData
- Overrides:
populateDisplayData
in classPTransform<PBegin,
PCollection<T>> - Parameters:
builder
- The builder to populate with display data.- See Also:
-