Class AdminRequestor
- java.lang.Object
-
- org.objectweb.joram.client.jms.admin.AdminRequestor
-
public final class AdminRequestor extends Object
The AdminRequestor class allows making administration service requests. The AdminRequestor constructor is given a Connection, it creates a session and a TemporaryTopic for the responses. It provides a request method that sends the request message to the administration topic of the connected server and waits for its reply.- See Also:
AdminWrapper
-
-
Field Summary
Fields Modifier and Type Field Description private MessageConsumerconsumerstatic longDEFAULT_REQUEST_TIMEOUTDefines the default value for timeout before aborting a request.static org.objectweb.util.monolog.api.Loggerloggerprivate MessageProducerproducerstatic StringREQUEST_TIMEOUT_PROPProperty allowing to set the timeout before aborting a request.private longrequestTimeoutDefines the maximum time in milliseconds before aborting a request.private Sessionsessionprivate TemporaryTopictmpTopicprivate Topictopic
-
Constructor Summary
Constructors Constructor Description AdminRequestor(Connection cnx)Constructor for the AdminRequestor class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Aborts the running request.voidclose()Closes the AdminRequestor and its session.longgetRequestTimeout()Returns the maximum time in ms before aborting a request.org.objectweb.joram.shared.admin.AdminReplyrequest(org.objectweb.joram.shared.admin.AdminRequest request)Sends an administration request and waits for a reply.voidsetRequestTimeout(long requestTimeout)Set the maximum time in ms before aborting arequest.private voidthrowException(org.objectweb.joram.shared.admin.AdminReply reply)Throws an exception corresponding to the error code of the reply if needed.
-
-
-
Field Detail
-
session
private Session session
-
topic
private Topic topic
-
tmpTopic
private TemporaryTopic tmpTopic
-
producer
private MessageProducer producer
-
consumer
private MessageConsumer consumer
-
REQUEST_TIMEOUT_PROP
public static final String REQUEST_TIMEOUT_PROP
Property allowing to set the timeout before aborting a request.- See Also:
requestTimeout, Constant Field Values
-
DEFAULT_REQUEST_TIMEOUT
public static final long DEFAULT_REQUEST_TIMEOUT
Defines the default value for timeout before aborting a request.Default value is 60.000 ms.
- See Also:
requestTimeout, Constant Field Values
-
requestTimeout
private long requestTimeout
Defines the maximum time in milliseconds before aborting a request.Default value is 60.000 ms.
This value can be adjusted by setting
org.objectweb.joram.client.jms.admin.requestTimeoutproperty.- Since:
- 5.2.2
- See Also:
DEFAULT_REQUEST_TIMEOUT,REQUEST_TIMEOUT_PROP
-
logger
public static org.objectweb.util.monolog.api.Logger logger
-
-
Constructor Detail
-
AdminRequestor
public AdminRequestor(Connection cnx) throws JMSException
Constructor for the AdminRequestor class. This implementation assumes an unified connection and uses a non-transacted session with an AUTO_ACKNOWLEDGE delivery mode. The Connection needs to be started.- Parameters:
cnx- A Joram connection.- Throws:
JMSException- if Joram fails to create the AdminRequestor due to some internal error.
-
-
Method Detail
-
setRequestTimeout
public void setRequestTimeout(long requestTimeout)
Set the maximum time in ms before aborting arequest.- Parameters:
requestTimeout- the maximum time in ms before aborting request.- Since:
- 5.2.2
-
getRequestTimeout
public long getRequestTimeout()
Returns the maximum time in ms before aborting a request.- Returns:
- the maximum time in ms before aborting request.
- Since:
- 5.2.2
-
request
public org.objectweb.joram.shared.admin.AdminReply request(org.objectweb.joram.shared.admin.AdminRequest request) throws AdminException, ConnectExceptionSends an administration request and waits for a reply. A temporary topic is used for theJMSReplyTodestination and the requestJMSMessageIDasJMSCorrelationIDto select the corresponding reply; any other replies are discarded.- Parameters:
request- the administration request to send- Returns:
- the reply message
- Throws:
AdminException- internal error.ConnectException- network error.
-
throwException
private final void throwException(org.objectweb.joram.shared.admin.AdminReply reply) throws AdminExceptionThrows an exception corresponding to the error code of the reply if needed.- Parameters:
reply- The reply to verify.- Throws:
AdminException- The exception corresponding to the error code in the reply.
-
abort
public void abort() throws ConnectExceptionAborts the running request.- Throws:
ConnectException- A problem occurs with the connection.
-
close
public void close()
Closes the AdminRequestor and its session. All internals allocated resources are closed and freed. Note that this method does not close the Connection object passed to the AdminRequestor constructor.
-
-