@Experimental(value=SOURCE_SINK) public class JmsIO extends java.lang.Object
JmsIO source returns unbounded collection of JMS records as PCollection<JmsRecord>
. A
JmsRecord
includes JMS headers and properties, along with the JMS TextMessage
payload.
To configure a JMS source, you have to provide a ConnectionFactory
and the
destination (queue or topic) where to consume. The following example illustrates various options
for configuring the source:
pipeline.apply(JmsIO.read()
.withConnectionFactory(myConnectionFactory)
.withQueue("my-queue")
// above two are required configuration, returns PCollection<JmsRecord>
// rest of the settings are optional
It is possible to read any type of JMS Message
into a custom POJO using the
following configuration:
pipeline.apply(JmsIO.<T>readMessage()
.withConnectionFactory(myConnectionFactory)
.withQueue("my-queue")
.withMessageMapper((MessageMapper<T>) message -> {
// code that maps message to T
})
.withCoder(
// a coder for T
)
JmsIO sink supports writing text messages to a JMS destination on a broker. To configure a JMS
sink, you must specify a ConnectionFactory
and a Destination
name. For instance:
pipeline
.apply(...) // returns PCollection<String>
.apply(JmsIO.write()
.withConnectionFactory(myConnectionFactory)
.withQueue("my-queue")
Modifier and Type | Class and Description |
---|---|
static interface |
JmsIO.MessageMapper<T>
An interface used by
JmsIO.Read for converting each jms Message into an element
of the resulting PCollection . |
static class |
JmsIO.Read<T>
A
PTransform to read from a JMS destination. |
protected static class |
JmsIO.UnboundedJmsSource<T>
An unbounded JMS source.
|
static class |
JmsIO.Write
A
PTransform to write to a JMS queue. |
Modifier and Type | Method and Description |
---|---|
static JmsIO.Read<JmsRecord> |
read() |
static <T> JmsIO.Read<T> |
readMessage() |
static JmsIO.Write |
write() |
public static JmsIO.Read<JmsRecord> read()
public static <T> JmsIO.Read<T> readMessage()
public static JmsIO.Write write()