ink #publish(String,String)}sc.publish(otpTopic, otpContent); // {@link #publish(OtpErlangString,OtpErlangString)}
For the full example, see {@link de.zib.scalaris.examples.PubSubPublishExample}
Subscribing to topics
String topic; String URL; OtpErlangString otpTopic; OtpErlangString otpURL; TransactionSingleOp sc = new PubSub(); sc.subscribe(topic, URL); // {@link #subscribe(String,String)}sc.subscribe(otpTopic, otpURL); // {@link #subscribe(OtpErlangString,OtpErlangString)}
For the full example, see {@link de.zib.scalaris.examples.PubSubSubscribeExample}
Unsubscribing from topics
Unsubscribing from topics works like subscribing to topics with the exception of a {@link NotFoundException} being thrown if either the topic does notexist or the URL is not subscribed to the topic.
String topic; String URL; OtpErlangString otpTopic; OtpErlangString otpURL; TransactionSingleOp sc = new PubSub(); sc.unsubscribe(topic, URL); // {@link #unsubscribe(String,String)}sc.unsubscribe(otpTopic, otpURL); // {@link #unsubscribe(OtpErlangString,OtpErlangString)}
Getting a list of subscribers to a topic
String topic; OtpErlangString otpTopic; List<String> subscribers; OtpErlangList otpSubscribers; // non-static: TransactionSingleOp sc = new PubSub(); subscribers = sc.getSubscribers(topic).stringListValue(); // {@link #getSubscribers(String)}otpSubscribers = (OtpErlangList) sc.getSubscribers(otpTopic).value(); // {@link #getSubscribers(OtpErlangString)}
For the full example, see {@link de.zib.scalaris.examples.PubSubGetSubscribersExample}
Connection errors
Errors when setting up connections or trying to send/receive RPCs will be handed to the {@link ConnectionPolicy} that has been set when the connectionwas created. By default, {@link ConnectionFactory} uses{@link DefaultConnectionPolicy} which implements automatic connection-retriesby classifying nodes as good or bad depending on their previous state. The number of automatic retries is adjustable (default: 3).
@author Nico Kruber, kruber@zib.de
@version 3.4
@since 2.5