Package org.ow2.joram.tools.jmscheck
Class JMSConnectorCheck
- java.lang.Object
-
- org.ow2.joram.tools.jmscheck.JMSConnectorCheck
-
public final class JMSConnectorCheck extends Object
Component allowing to check a JMS connector.
-
-
Field Summary
Fields Modifier and Type Field Description private jakarta.jms.ConnectionFactorycfprivate StringcfnameJNDI Name of the ConnectionFactory to use.private static booleanDEBUGprivate StringerrorMsgprivate intfailuresprivate InitialContextictx(package private) static String[]infoprivate StringlastConnectTimeprivate longlatencyConnectprivate longlatencyPubSubprivate static Loggerloggerprivate intnbtryprivate Stringpassprivate Stringqnameprivate Queuequeueprivate intretryStatusCountretryStatusCount == 0 => RUNNING, retryStatusCount > 0 => UNREACHABLEstatic intRUNNINGprivate inttimeoutThe maximum time waiting for connection.static intUNREACHABLEprivate Stringuser
-
Constructor Summary
Constructors Constructor Description JMSConnectorCheck(jakarta.jms.ConnectionFactory cf, String user, String pass, String qname, int timeOut)Creates a new component allowing to check a JMS connector.JMSConnectorCheck(String cfname, InitialContext ictx, String user, String pass, String qname, int timeOut)Creates a new component allowing to check a JMS connector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheck()Checks the related JMS connector, creates a connection, then sends and receives a message.StringgetCFName()private voidgetConnectionFactory()StringgetErrorMsg()Returns the error message of the last try.StringgetLastConnectTime()Returns the date of last successful connection.longgetLatencyConnect()Returns the latency of the connection during the last try.longgetLatencyPubSub()Returns the latency of the send/receive during the last try.intgetNbFailures()Returns the total number of failures since starting.intgetNbTry()Returns the total number of try since starting.intgetStatus()Returns the status of the connector: 0 => RUNNING, >0 => UNREACHABLE.StringgetStatusInfo()intgetTimeOut()Returns the maximum time waiting for connection.private voidsetLatencyConnect(long latencyConnect)private voidsetLatencyPubSub(long latencyPubSub)private voidsetStatus(int retry)voidsetTimeOut(int timeOut)Sets the maximum time waiting for connection.StringtoString()
-
-
-
Field Detail
-
logger
private static final Logger logger
-
DEBUG
private static final boolean DEBUG
-
RUNNING
public static final int RUNNING
- See Also:
- Constant Field Values
-
UNREACHABLE
public static final int UNREACHABLE
- See Also:
- Constant Field Values
-
info
static final String[] info
-
retryStatusCount
private int retryStatusCount
retryStatusCount == 0 => RUNNING, retryStatusCount > 0 => UNREACHABLE
-
nbtry
private int nbtry
-
failures
private transient int failures
-
errorMsg
private String errorMsg
-
lastConnectTime
private String lastConnectTime
-
latencyConnect
private long latencyConnect
-
latencyPubSub
private long latencyPubSub
-
timeout
private int timeout
The maximum time waiting for connection.
-
cfname
private String cfname
JNDI Name of the ConnectionFactory to use.
-
user
private String user
-
pass
private String pass
-
qname
private String qname
-
ictx
private InitialContext ictx
-
cf
private jakarta.jms.ConnectionFactory cf
-
queue
private Queue queue
-
-
Constructor Detail
-
JMSConnectorCheck
public JMSConnectorCheck(String cfname, InitialContext ictx, String user, String pass, String qname, int timeOut)
Creates a new component allowing to check a JMS connector.- Parameters:
cfname- JNDI name of the ConnectionFactory to use.ictx- JNDI context allowing to retrieve ConnectionFactory.user- User name for authentication, if no defined uses the ConnectionFactory default.pass- Password for authentication, if no defined uses the ConnectionFactory default.qname- Internal name of JMS destination.timeout- Maximum amount of time to wait connecting and receiving messages, by default 10s.
-
JMSConnectorCheck
public JMSConnectorCheck(jakarta.jms.ConnectionFactory cf, String user, String pass, String qname, int timeOut)Creates a new component allowing to check a JMS connector.- Parameters:
cf- ConnectionFactory to use.user- User name for authentication, if no defined uses the ConnectionFactory default.pass- Password for authentication, if no defined uses the ConnectionFactory default.qname- Internal name of JMS destination.timeout- Maximum amount of time to wait connecting and receiving messages, by default 10s.
-
-
Method Detail
-
getStatus
public int getStatus()
Returns the status of the connector: 0 => RUNNING, >0 => UNREACHABLE.- Returns:
- the number of unreachable connection
-
getStatusInfo
public String getStatusInfo()
-
setStatus
private void setStatus(int retry)
-
getNbTry
public int getNbTry()
Returns the total number of try since starting.- Returns:
- the total number of try since starting.
-
getNbFailures
public int getNbFailures()
Returns the total number of failures since starting.- Returns:
- the total number of failures since starting.
-
getErrorMsg
public String getErrorMsg()
Returns the error message of the last try. Returns null if the test is successful.- Returns:
-
getLastConnectTime
public String getLastConnectTime()
Returns the date of last successful connection.- Returns:
- the date of last successful connection.
-
getLatencyConnect
public long getLatencyConnect()
Returns the latency of the connection during the last try. Returns -1 if the test failed.- Returns:
- the latency of the connection during the last try.
-
setLatencyConnect
private void setLatencyConnect(long latencyConnect)
-
getLatencyPubSub
public long getLatencyPubSub()
Returns the latency of the send/receive during the last try. Returns -1 if the test failed.- Returns:
- the latency of the send/receive during the last try.
-
setLatencyPubSub
private void setLatencyPubSub(long latencyPubSub)
-
getTimeOut
public int getTimeOut()
Returns the maximum time waiting for connection.- Returns:
- the maximum time waiting for connection.
-
setTimeOut
public void setTimeOut(int timeOut)
Sets the maximum time waiting for connection.- Parameters:
timeOut- the maximum time waiting for connection.
-
getCFName
public String getCFName()
-
getConnectionFactory
private void getConnectionFactory() throws NamingException- Throws:
NamingException
-
check
public boolean check()
Checks the related JMS connector, creates a connection, then sends and receives a message. After the call the test results are updated.- Returns:
- true if the check is successful, false otherwise.
-
-