Spread Messaging Toolkit

Discussion in 'Automated Trading' started by WallstYouth, Feb 12, 2008.

  1. Spread is an open source toolkit that provides a high performance messaging service that is resilient to faults across local and wide area networks. Spread functions as a unified message bus for distributed applications, and provides highly tuned application-level multicast, group communication, and point to point support. Spread services range from reliable messaging to fully ordered messages with delivery guarantees.

    The API seems pretty straight forward for the most part I was able to startup the spread daemon and send a few test messages in a few minutes.

    [ Standard UNIX installation ]
    ./configure --prefix=/opt/spread && make && make install

    [ If using Java ]
    [wallstyouth@macbookpro:~/Desktop/spread-src-4.0.0/java] $ ant all
    $ cp spread.jar /opt/spread/lib

    The default configuration is good enough for basic testing
    [wallstyouth@macbookpro:/opt/spread/etc] $ egrep '^[^#]' spread.conf
    Spread_Segment 127.0.0.255:4803 {
    localhost 127.0.0.1
    }

    Really quick code to just show you how easy it is to construct messages. Here I send a test message to the spread daemon on port 4803

    1. Startup the spread daemon /opt/spread/sbin/spread &

    2. Startup the spuser utility this is a handy utility to monitor and send/recieve messages
    a. Startup spuser utility : ./spuser
    b. Join a group that will receive messages from clients : j group1

    Using the following I was able to compile and send a message to the spread daemon and see this message register in the spuser utility.

    javac -cp /path/to/spread.jar SpreadExample.java

    --- SpreadExample.java ---
    Code:
     
    import spread.*;
    import java.net.InetAddress;
    import java.io.*;
    
    /**
     * User: wallstyouth
     * Date: Feb 10, 2008
     * Time: 12:46:18 PM
     */
    public class SpreadExample  {
        public static void main(String[] args) throws IOException, SpreadException {
            String text = "Hello spread clients";
            SpreadVersion ver = new SpreadVersion();
            SpreadMessage msgbox = new SpreadMessage();
            SpreadGroup group = new SpreadGroup();
            StringBuffer  msg = new StringBuffer();
    
            SpreadConnection connection = new SpreadConnection();
            InetAddress sp_host = InetAddress.getByName("127.0.0.1");
            connection.connect(sp_host,4803,sp_host.getHostAddress(),false,false);
           
            /* join a group on the connection */
            group.join(connection,"group1");
    
            msg.append(text);
            msg.append(" [spread/");
            msg.append(ver.getVersion());
            msg.append("]");
    
            msgbox.setData(msg.toString().getBytes());
            msgbox.addGroup("group1");
            msgbox.setReliable();
    
            /* Send the msg data */
            connection.multicast(msgbox);
            connection.disconnect();
        }
    }
    
    I recently came across this toolkit and it seems well polished with a decent following, I might end up using it some of our projects just thought I would share this with others.
     
  2. rosy2

    rosy2

    i used this years ago but there's no persistence. you can not get the last 50 messages if you needed.

    i use activemq personally and sonic at work.