|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jlab.coda.cMsg.cMsgDomainAdapter
org.jlab.coda.cMsg.cMsgDomain.client.cMsg
public class cMsg
This class implements a cMsg client in the cMsg domain.
Field Summary | |
---|---|
java.lang.String |
monitorXML
String containing monitor data received from a cMsg server as a keep alive response. |
java.util.Set<cMsgSubscription> |
subscriptions
Collection of all of this client's message subscriptions which are cMsgSubscription objects. |
Fields inherited from class org.jlab.coda.cMsg.cMsgDomainAdapter |
---|
connected, description, domain, host, name, receiving, shutdownHandler, UDL, UDLremainder |
Constructor Summary | |
---|---|
cMsg()
Constructor which does NOT automatically try to connect to the name server specified. |
Method Summary | |
---|---|
void |
connect()
Method to connect to the domain server from this client. |
void |
disconnect()
Method to close the connection to the domain server. |
void |
flush(int timeout)
Method to force cMsg client to send pending communications with domain server. |
cMsgMessage |
monitor(java.lang.String command)
This method is a synchronous call to receive a message containing monitoring data which describes the state of the cMsg domain the user is connected to. |
void |
send(cMsgMessage message)
Method to send a message to the domain server for further distribution. |
cMsgMessage |
sendAndGet(cMsgMessage message,
int timeout)
The message is sent as it would be in the send(org.jlab.coda.cMsg.cMsgMessage) method. |
void |
shutdownClients(java.lang.String client,
boolean includeMe)
Method to shutdown the given clients. |
void |
shutdownServers(java.lang.String server,
boolean includeMyServer)
Method to shutdown the given servers. |
java.lang.Object |
subscribe(java.lang.String subject,
java.lang.String type,
cMsgCallbackInterface cb,
java.lang.Object userObj)
Method to subscribe to receive messages of a subject and type from the domain server. |
cMsgMessage |
subscribeAndGet(java.lang.String subject,
java.lang.String type,
int timeout)
This method is like a one-time subscribe. |
int |
syncSend(cMsgMessage message,
int timeout)
Method to send a message to the domain server for further distribution and wait for a response from the subdomain handler that got it. |
void |
unsubscribe(java.lang.Object obj)
Method to unsubscribe a previous subscription to receive messages of a subject and type from the domain server. |
Methods inherited from class org.jlab.coda.cMsg.cMsgDomainAdapter |
---|
getDescription, getDomain, getHost, getName, getShutdownHandler, getString, getUDL, getUDLRemainder, isConnected, isReceiving, setDescription, setName, setShutdownHandler, setUDL, setUDLRemainder, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.lang.String monitorXML
public java.util.Set<cMsgSubscription> subscriptions
cMsgSubscription
objects. This set is synchronized. A client is either
a regular client or a bridge but not both. That means it does not matter that
a bridge client will add namespace data to the stored subscription but a regular
client will not.
Constructor Detail |
---|
public cMsg() throws cMsgException
cMsgException
- if local host name cannot be foundMethod Detail |
---|
public void connect() throws cMsgException
connectDirect()
.
connect
in interface cMsgDomainInterface
connect
in class cMsgDomainAdapter
cMsgException
- if there are problems parsing the UDL or
communication problems with the server(s)public void flush(int timeout)
flush
in interface cMsgDomainInterface
flush
in class cMsgDomainAdapter
timeout
- ignored in this domainpublic void disconnect()
disconnect
in interface cMsgDomainInterface
disconnect
in class cMsgDomainAdapter
public void send(cMsgMessage message) throws cMsgException
send
in interface cMsgDomainInterface
send
in class cMsgDomainAdapter
message
- message to send
cMsgException
- if there are communication problems with the server;
subject and/or type is null; message is too big for
UDP packet size if doing UDP sendpublic int syncSend(cMsgMessage message, int timeout) throws cMsgException
syncSend
in interface cMsgDomainInterface
syncSend
in class cMsgDomainAdapter
message
- messagetimeout
- ignored in this domain
cMsgException
- if there are communication problems with the server;
subject and/or type is nullpublic java.lang.Object subscribe(java.lang.String subject, java.lang.String type, cMsgCallbackInterface cb, java.lang.Object userObj) throws cMsgException
subscribe
in interface cMsgDomainInterface
subscribe
in class cMsgDomainAdapter
subject
- message subjecttype
- message typecb
- callback object whose single method is called upon receiving a message
of subject and typeuserObj
- any user-supplied object to be given to the callback method as an argument
cMsgException
- if the callback, subject and/or type is null or blank;
an identical subscription already exists; there are
communication problems with the serverpublic void unsubscribe(java.lang.Object obj) throws cMsgException
unsubscribe
in interface cMsgDomainInterface
unsubscribe
in class cMsgDomainAdapter
obj
- the object "handle" returned from a subscribe call
cMsgException
- if there are communication problems with the server; object arg is nullpublic cMsgMessage subscribeAndGet(java.lang.String subject, java.lang.String type, int timeout) throws cMsgException, java.util.concurrent.TimeoutException
subscribeAndGet
in interface cMsgDomainInterface
subscribeAndGet
in class cMsgDomainAdapter
subject
- subject of message desired from servertype
- type of message desired from servertimeout
- time in milliseconds to wait for a message
cMsgException
- if there are communication problems with the server;
server dies; subject and/or type is null or blank
java.util.concurrent.TimeoutException
- if timeout occurspublic cMsgMessage sendAndGet(cMsgMessage message, int timeout) throws cMsgException, java.util.concurrent.TimeoutException
send(org.jlab.coda.cMsg.cMsgMessage)
method. The server notes
the fact that a response to it is expected, and sends it to all subscribed to its
subject and type. When a marked response is received from a client, it sends the
first response back to the original sender regardless of its subject or type.
NOTE: Disconnecting when one thread is in the waiting part of a sendAndGet may cause that
thread to block forever. It is best to always use a timeout with sendAndGet so the thread
is assured of eventually resuming execution.
sendAndGet
in interface cMsgDomainInterface
sendAndGet
in class cMsgDomainAdapter
message
- message sent to servertimeout
- time in milliseconds to wait for a reponse message
cMsgException
- if there are communication problems with the server;
server died; subject and/or type is null
java.util.concurrent.TimeoutException
- if timeout occurspublic cMsgMessage monitor(java.lang.String command) throws cMsgException
monitor
in interface cMsgDomainInterface
monitor
in class cMsgDomainAdapter
command
- directive for monitoring process
cMsgException
public void shutdownClients(java.lang.String client, boolean includeMe) throws cMsgException
shutdownClients
in interface cMsgDomainInterface
shutdownClients
in class cMsgDomainAdapter
client
- client(s) to be shutdownincludeMe
- if true, it is permissible to shutdown calling client
cMsgException
- if there are communication problems with the serverpublic void shutdownServers(java.lang.String server, boolean includeMyServer) throws cMsgException
shutdownServers
in interface cMsgDomainInterface
shutdownServers
in class cMsgDomainAdapter
server
- server(s) to be shutdownincludeMyServer
- if true, it is permissible to shutdown calling client's cMsg server
cMsgException
- if server arg is not in the correct form (host:port),
the host is unknown, client not connected to server,
or IO error.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |