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.ConnectionFactoryContainer<T extends JmsIO.ConnectionFactoryContainer<T>> |
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. |
static class |
JmsIO.Write<EventT>
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 <EventT> JmsIO.Write<EventT> |
write() |
public static JmsIO.Read<JmsRecord> read()
public static <T> JmsIO.Read<T> readMessage()
public static <EventT> JmsIO.Write<EventT> write()