Class StompConnection

java.lang.Object
org.jgroups.client.StompConnection
All Implemented Interfaces:
Runnable

public class StompConnection extends Object implements Runnable
STOMP client to access the STOMP [1] protocol. Note that the full STOMP protocol is not implemented, e.g. transactions are currently not supported.

The interactive client can be started with -h HOST -p PORT, which are the hostname and port of a JGroups server, running with STOMP in its stack configuration. The interactive client supports automatic failover to a different server if the currently connected-to server crashes, and a simple syntax for sending STOMP messages:

 subscribe DEST // example: subscribe /topics/a
 send DEST message // example: send /topics/a Hello world
 

[1] http://stomp.codehaus.org/Protocol

  • Field Details

  • Constructor Details

    • StompConnection

      public StompConnection(String dest)
      Parameters:
      dest - IP address + ':' + port, e.g. "192.168.1.5:8787"
    • StompConnection

      public StompConnection(String dest, boolean reconnect, boolean ssl)
    • StompConnection

      public StompConnection(String dest, boolean reconnect, SSLContext ssl)
    • StompConnection

      public StompConnection(String dest, String userid, String password, boolean reconnect, boolean ssl)
    • StompConnection

      public StompConnection(String dest, String userid, String password, boolean reconnect, SSLContext sslcontext)
    • StompConnection

      public StompConnection(String dest, String userid, String password, boolean reconnect, SSLContext sslcontext, SSLParameters sslParameters)
  • Method Details

    • getSessionId

      public String getSessionId()
    • addListener

      public void addListener(StompConnection.Listener listener)
    • addCallback

      public void addCallback(StompConnection.ConnectionCallback cb)
    • removeListener

      public void removeListener(StompConnection.Listener listener)
    • removeCallback

      public void removeCallback(StompConnection.ConnectionCallback cb)
    • startRunner

      protected void startRunner()
    • sendConnect

      protected void sendConnect() throws IOException
      Throws:
      IOException
    • subscribe

      public void subscribe(String destination)
    • sendSubscribe

      protected void sendSubscribe(String destination)
    • unsubscribe

      public void unsubscribe(String destination)
    • sendUnsubscribe

      protected void sendUnsubscribe(String destination)
    • send

      public void send(String destination, byte[] buf, int offset, int length, String... headers)
    • send

      public void send(String destination, String... headers)
      Sends an INFO without body
    • send

      public void send(String destination, byte[] buf, int offset, int length)
    • send

      public void send(String destination, byte[] buf)
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • notifyListeners

      protected void notifyListeners(Map<String,String> headers, byte[] buf, int offset, int length)
    • notifyListeners

      protected void notifyListeners(Map<String,String> info)
    • connectToSingleDestination

      public void connectToSingleDestination(String destination) throws IOException
      Throws:
      IOException
    • connect

      public void connect() throws IOException
      Throws:
      IOException
    • startReconnectingClient

      public void startReconnectingClient()
    • buildSocket

      protected Socket buildSocket(String host, int port) throws IOException
      Throws:
      IOException
    • connectToDestination

      protected void connectToDestination(String dest) throws IOException
      Throws:
      IOException
    • disconnect

      public void disconnect()
    • closeConnections

      protected void closeConnections()
    • isConnected

      public boolean isConnected()
    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException