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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Set<StompConnection.ConnectionCallback> protected DataInputStreamprotected final Set<StompConnection.Listener> protected final Logprotected DataOutputStreamprotected Stringprotected booleanprotected Threadprotected booleanprotected Stringprotected Socketprotected SocketFactoryprotected SSLParametersprotected String -
Constructor Summary
ConstructorsConstructorDescriptionStompConnection(String dest) StompConnection(String dest, boolean reconnect, boolean ssl) StompConnection(String dest, boolean reconnect, SSLContext ssl) StompConnection(String dest, String userid, String password, boolean reconnect, boolean ssl) StompConnection(String dest, String userid, String password, boolean reconnect, SSLContext sslcontext) StompConnection(String dest, String userid, String password, boolean reconnect, SSLContext sslcontext, SSLParameters sslParameters) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddListener(StompConnection.Listener listener) protected SocketbuildSocket(String host, int port) protected voidvoidconnect()protected voidconnectToDestination(String dest) voidconnectToSingleDestination(String destination) voidbooleanstatic voidprotected voidnotifyListeners(Map<String, String> info) protected voidnotifyListeners(Map<String, String> headers, byte[] buf, int offset, int length) voidvoidremoveListener(StompConnection.Listener listener) voidrun()voidvoidvoidvoidSends an INFO without bodyprotected voidprotected voidsendSubscribe(String destination) protected voidsendUnsubscribe(String destination) voidprotected voidvoidvoidunsubscribe(String destination)
-
Field Details
-
socket_factory
-
sock
-
in
-
out
-
server_destinations
-
listeners
-
subscriptions
-
callbacks
-
runner
-
running
protected volatile boolean running -
session_id
-
userid
-
password
-
reconnect
protected boolean reconnect -
log
-
sslParameters
-
-
Constructor Details
-
StompConnection
- Parameters:
dest- IP address + ':' + port, e.g. "192.168.1.5:8787"
-
StompConnection
-
StompConnection
-
StompConnection
-
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
-
addListener
-
addCallback
-
removeListener
-
removeCallback
-
startRunner
protected void startRunner() -
sendConnect
- Throws:
IOException
-
subscribe
-
sendSubscribe
-
unsubscribe
-
sendUnsubscribe
-
send
-
send
Sends an INFO without body -
send
-
send
-
run
public void run() -
notifyListeners
-
notifyListeners
-
connectToSingleDestination
- Throws:
IOException
-
connect
- Throws:
IOException
-
startReconnectingClient
public void startReconnectingClient() -
buildSocket
- Throws:
IOException
-
connectToDestination
- Throws:
IOException
-
disconnect
public void disconnect() -
closeConnections
protected void closeConnections() -
isConnected
public boolean isConnected() -
main
- Throws:
IOException
-