Package org.jgroups.client
Class StompConnection
java.lang.Object
org.jgroups.client.StompConnection
- All Implemented Interfaces:
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
- Author:
- Bela Ban
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DataInputStreamprotected final Set<StompConnection.Listener> protected final Logprotected DataOutputStreamprotected Threadprotected booleanprotected Stringprotected Socket -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(StompConnection.Listener listener) protected voidclose()voidconnect()protected voidvoidvoidbooleanstatic voidprotected voidnotifyListeners(Map<String, String> info) protected voidnotifyListeners(Map<String, String> headers, byte[] buf, int offset, int length) protected static SocketAddressprotected StringvoidvoidremoveListener(StompConnection.Listener listener) voidrun()voidvoidvoidvoidSends an INFO without bodyprotected voidvoidvoidunsubscribe(String destination)
-
Field Details
-
sock
-
in
-
out
-
server_destinations
-
listeners
-
subscriptions
-
runner
-
running
protected volatile boolean running -
session_id
-
log
-
-
Constructor Details
-
StompConnection
- Parameters:
dest- IP address + ':' + port, e.g. "192.168.1.5:8787"
-
-
Method Details
-
getSessionId
-
addListener
-
removeListener
-
connect
- Throws:
IOException
-
reconnect
- Throws:
IOException
-
connect
- Throws:
IOException
-
disconnect
public void disconnect() -
subscribe
-
unsubscribe
-
send
-
send
Sends an INFO without body -
send
-
send
-
run
public void run() -
notifyListeners
-
notifyListeners
-
pickRandomDestination
-
connect
- Throws:
IOException
-
parse
- Throws:
UnknownHostException
-
close
protected void close() -
isConnected
public boolean isConnected() -
startRunner
protected void startRunner() -
main
- Throws:
IOException
-