public class PublishSubscribe
extends java.lang.Object
published
to a topic
and then subscribed
to by
other topologies.
A published topic has a type and subscribers must subscribe using the same
topic and type (inheritance matching is not supported).
Multiple streams from different topologies can be published to
same topic (and type) and there can be multiple subscribers
from different topologies.
A subscriber can exist before a publisher exists, they are connected
automatically when the job starts.
If no PublishSubscribeService
is registered then published
tuples are discarded and subscribers see no tuples.
The recommended style for topics is MQTT topics, where /
is used to provide a hierarchy into topics. For example engine/sensors/temperature
might be a topic that represents temperature sensors in an engine.
Topics that start with edgent/
are reserved for use by Edgent.
MQTT style wild-cards are not supported.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
RESERVED_TOPIC_PREFIX
Topics that start with "edgent/" are reserved for use by Edgent.
|
Constructor and Description |
---|
PublishSubscribe() |
Modifier and Type | Method and Description |
---|---|
static <T> TSink<T> |
publish(TStream<T> stream,
java.lang.String topic,
java.lang.Class<? super T> streamType)
Publish this stream to a topic.
|
static <T> TStream<T> |
subscribe(TopologyElement te,
java.lang.String topic,
java.lang.Class<T> streamType)
Subscribe to a published topic.
|
public static final java.lang.String RESERVED_TOPIC_PREFIX
public static <T> TSink<T> publish(TStream<T> stream, java.lang.String topic, java.lang.Class<? super T> streamType)
T
- Tuple typestream
- stream to publishtopic
- Topic to publish to.streamType
- Type of objects on the stream.subscribe(TopologyElement, String, Class)
public static <T> TStream<T> subscribe(TopologyElement te, java.lang.String topic, java.lang.Class<T> streamType)
T
- Tuple typete
- TopologyElement whose Topology to add totopic
- Topic to subscribe to.streamType
- Type of the stream.publish(TStream, String, Class)
Copyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641