public abstract static class JmsIO.Write<EventT> extends PTransform<PCollection<EventT>,WriteJmsResult<EventT>>
PTransform
to write to a JMS queue. See JmsIO
for more information on usage
and configuration.name, resourceHints
Constructor and Description |
---|
Write() |
Modifier and Type | Method and Description |
---|---|
WriteJmsResult<EventT> |
expand(PCollection<EventT> input)
Override this method to specify how this
PTransform should be expanded on the given
InputT . |
JmsIO.Write<EventT> |
withConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
Specify the JMS connection factory to connect to the JMS broker.
|
JmsIO.Write<EventT> |
withPassword(java.lang.String password)
Define the password to connect to the JMS broker (authenticated).
|
JmsIO.Write<EventT> |
withQueue(java.lang.String queue)
Specify the JMS queue destination name where to send messages to.
|
JmsIO.Write<EventT> |
withRetryConfiguration(RetryConfiguration retryConfiguration)
Specify the JMS retry configuration.
|
JmsIO.Write<EventT> |
withTopic(java.lang.String topic)
Specify the JMS topic destination name where to send messages to.
|
JmsIO.Write<EventT> |
withTopicNameMapper(SerializableFunction<EventT,java.lang.String> topicNameMapper)
Specify the JMS topic destination name where to send messages to dynamically.
|
JmsIO.Write<EventT> |
withUsername(java.lang.String username)
Define the username to connect to the JMS broker (authenticated).
|
JmsIO.Write<EventT> |
withValueMapper(SerializableBiFunction<EventT,javax.jms.Session,javax.jms.Message> valueMapper)
Map the
EventT object to a Message . |
compose, compose, getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setResourceHints, toString, validate, validate
public JmsIO.Write<EventT> withConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
For instance:
.apply(JmsIO.write().withConnectionFactory(myConnectionFactory)
connectionFactory
- The JMS ConnectionFactory
.JmsIO.Read
.public JmsIO.Write<EventT> withQueue(java.lang.String queue)
JmsIO.Write
acts as a producer on the queue.
This method is exclusive with withTopic(String)
. The user has to
specify a destination: queue, topic, or topicNameMapper.
For instance:
.apply(JmsIO.write().withQueue("my-queue")
queue
- The JMS queue name where to send messages to.JmsIO.Read
.public JmsIO.Write<EventT> withTopic(java.lang.String topic)
JmsIO.Read
acts
as a publisher on the topic.
This method is exclusive with withQueue(String)
. The user has to
specify a destination: queue, topic, or topicNameMapper.
For instance:
.apply(JmsIO.write().withTopic("my-topic")
topic
- The JMS topic name.JmsIO.Read
.public JmsIO.Write<EventT> withUsername(java.lang.String username)
public JmsIO.Write<EventT> withPassword(java.lang.String password)
public JmsIO.Write<EventT> withTopicNameMapper(SerializableFunction<EventT,java.lang.String> topicNameMapper)
JmsIO.Write
acts as a publisher on the topic.
This method is exclusive with JmsIO.Write#withQueue(String) and {@link JmsIO.Write#withTopic(String)}. The user has to specify a {@link SerializableFunction} that takes {@code EventT} object as a parameter, and returns the topic name depending of the content of the event object.
For example:
{@code SerializableFunctiontopicNameMapper = (event -> String.format( "company/%s/employee/%s", event.getCompanyName(), event.getEmployeeId())); }
{@code .apply(JmsIO.write().withTopicNameMapper(topicNameNapper) }
topicNameMapper
- The function returning the dynamic topic name.JmsIO.Write
.public JmsIO.Write<EventT> withValueMapper(SerializableBiFunction<EventT,javax.jms.Session,javax.jms.Message> valueMapper)
EventT
object to a Message
.
For instance:
SerializableBiFunction<SomeEventObject, Session, Message> valueMapper = (e, s) -> {
try {
TextMessage msg = s.createTextMessage();
msg.setText(Mapper.MAPPER.toJson(e));
return msg;
} catch (JMSException ex) {
throw new JmsIOException("Error!!", ex);
}
};
.apply(JmsIO.write().withValueMapper(valueNapper)
valueMapper
- The function returning the Message
JmsIO.Write
.public JmsIO.Write<EventT> withRetryConfiguration(RetryConfiguration retryConfiguration)
JmsIO.Write
acts as a publisher on the
topic.
Allows a retry for failed published messages, the user should specify the maximum number
of retries, a duration for retrying and a maximum cumulative retries. By default, the
duration for retrying used is 15s and the maximum cumulative is 1000 days RetryConfiguration
For example:
RetryConfiguration retryConfiguration = RetryConfiguration.create(5);
or
RetryConfiguration retryConfiguration =
RetryConfiguration.create(5, Duration.standardSeconds(30), null);
or
RetryConfiguration retryConfiguration =
RetryConfiguration.create(5, Duration.standardSeconds(30), Duration.standardDays(15));
.apply(JmsIO.write().withPublicationRetryPolicy(publicationRetryPolicy)
retryConfiguration
- The retry configuration that should be used in case of failed
publications.JmsIO.Write
.public WriteJmsResult<EventT> expand(PCollection<EventT> input)
PTransform
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).
expand
in class PTransform<PCollection<EventT>,WriteJmsResult<EventT>>