@Experimental(value=SOURCE_SINK)
public class RabbitMqIO
extends java.lang.Object
RabbitMqIO RabbitMqIO.Read returns an unbounded PCollection containing RabbitMQ
messages body (as byte[]) wrapped as RabbitMqMessage.
To configure a RabbitMQ source, you have to provide a RabbitMQ URI to connect to a
RabbitMQ broker. The following example illustrates various options for configuring the source,
reading from the queue:
PCollection<RabbitMqMessage> messages = pipeline.apply(
RabbitMqIO.read().withUri("amqp://user:password@localhost:5672").withQueue("QUEUE"))
It's also possible to read from an exchange (providing the exchange type and routing key) instead of directly from a queue:
PCollection<RabbitMqMessage> messages = pipeline.apply(
RabbitMqIO.read().withUri("amqp://user:password@localhost:5672").withExchange("EXCHANGE", "fanout", "QUEUE"));
RabbitMqIO RabbitMqIO.Write can send RabbitMqMessage to a RabbitMQ server queue
or exchange.
As for the RabbitMqIO.Read, the RabbitMqIO.Write is configured with a RabbitMQ URI.
For instance, you can write to an exchange (providing the exchange type):
pipeline
.apply(...) // provide PCollection<RabbitMqMessage>
.apply(RabbitMqIO.write().withUri("amqp://user:password@localhost:5672").withExchange("EXCHANGE", "fanout"));
For instance, you can write to a queue:
pipeline
.apply(...) // provide PCollection<RabbitMqMessage>
.apply(RabbitMqIO.write().withUri("amqp://user:password@localhost:5672").withQueue("QUEUE"));
| Modifier and Type | Class and Description |
|---|---|
static class |
RabbitMqIO.Read
A
PTransform to consume messages from RabbitMQ server. |
static class |
RabbitMqIO.Write
A
PTransform to publish messages to a RabbitMQ server. |
| Modifier and Type | Method and Description |
|---|---|
static RabbitMqIO.Read |
read() |
static RabbitMqIO.Write |
write() |
public static RabbitMqIO.Read read()
public static RabbitMqIO.Write write()