public interface BroadcastSubscription extends Subscription
A BroadcastSubscription
represents a subscription to many subjects. The scope of the
subscription is defined by a Namespace
. When you make a
broadcast subscription, the associated
SubscriptionListener
implementation will receive all
incoming updates for subjects that match the provided
Namespace
.
The following example shows how to create a BroadcastSubscription
:
import java.util.logging.Level;
import com.caplin.datasource.DataSource;
import com.caplin.datasource.Peer;
import com.caplin.datasource.messaging.record.RecordMessage;
import com.caplin.datasource.namespace.Namespace;
import com.caplin.datasource.namespace.PrefixNamespace;
import com.caplin.datasource.subscription.BaseSubscriptionListener;
import com.caplin.datasource.subscription.Subscription;
public class ExampleBroadcastSubscriber extends BaseSubscriptionListener
{
public ExampleBroadcastSubscriber(DataSource dataSource)
{
super(dataSource.getLogger());
Namespace namespace = new PrefixNamespace("/BROADCAST/");
dataSource.createBroadcastSubscription(namespace, this);
}
@Override
public void recordUpdated(Subscription subscription, Peer peer, RecordMessage recordMessage)
{
logger.log(Level.INFO, String.format("Received a record update for %s: %s", recordMessage.getSubject(), recordMessage));
}
}
Modifier and Type | Method and Description |
---|---|
Namespace |
getNamespace()
Gets the namespace for this subscription.
|
getSubscriptionListener, unsubscribe
Namespace getNamespace()
Gets the namespace for this subscription.
Please send bug reports and comments to Caplin support