blob: 7d9c98ba886d81794cf183c02c295138d64446ba [file] [log] [blame]
<div class="wiki-content maincontent"><p>ActiveBlaze provides infrastructure for fast, reliable peer to peer messaging to meet the demands of high performance and collaborative applications.<br clear="none">
Using the basic building block of a Channel, there exists a functional hierarchy used for different problem domains, each one a super-set of the previous one.</p>
<p>The BlazeChannel supports broadcasting on Topics - either using reliable multicast or point-cast.</p>
<p>To use a BlazeChannel create one from the a factory:</p>
<structured-macro ac:macro-id="f30411e7-098a-436f-aee0-aef2d1b9764d" ac:name="code" ac:schema-version="1"><plain-text-body>
import org.apache.activeblaze.*;
...
BlazeChannelFactory factory = new BlazeChannelFactory();
BlazeChannel sender = factory.createChannel();
//start the channel and send a message
sender.start();
String destination = "foo.bar";
BlazeMessage msg = new BlazeMessage("test payload");
sender.broadcast(destination,msg);
//shutdown the sender
sender.shutDown();
</plain-text-body></structured-macro>
<p>You can similarly subscribe to Topic messages by using a listener</p>
<structured-macro ac:macro-id="f52abf76-f5a1-49db-b7a5-88dcf8f9b651" ac:name="code" ac:schema-version="1"><plain-text-body>
BlazeChannel receiver = factory.createChannel();
receiver.start();
//add a listener
receiver.addBlazeTopicMessageListener(destination, new BlazeMessageListener() {
public void onMessage(BlazeMessage msg) {
System.out.println("Got a msg: " + msg);
}
});
receiver.shutDown();
</plain-text-body></structured-macro></div>