public class ActiveMQConnection extends Object implements javax.jms.Connection, javax.jms.TopicConnection, javax.jms.QueueConnection, StatsCapable, Closeable, TransportListener, EnhancedConnection
Modifier and Type | Field and Description |
---|---|
ConcurrentMap<ActiveMQTempDestination,ActiveMQTempDestination> |
activeTempDestinations |
protected boolean |
alwaysSessionAsync |
static String |
DEFAULT_BROKER_URL |
static String |
DEFAULT_PASSWORD |
static int |
DEFAULT_THREAD_POOL_SIZE |
static String |
DEFAULT_USER |
protected boolean |
dispatchAsync |
protected AtomicInteger |
transportInterruptionProcessingComplete |
Modifier | Constructor and Description |
---|---|
protected |
ActiveMQConnection(Transport transport,
IdGenerator clientIdGenerator,
IdGenerator connectionIdGenerator,
JMSStatsImpl factoryStats)
Construct an
ActiveMQConnection |
Modifier and Type | Method and Description |
---|---|
protected void |
addConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer)
Add a ConnectionConsumer
|
void |
addDispatcher(ConsumerId consumerId,
ActiveMQDispatcher dispatcher) |
void |
addProducer(ProducerId producerId,
ActiveMQMessageProducer producer) |
protected void |
addSession(ActiveMQSession session)
Used internally for adding Sessions to the Connection
|
void |
addTransportListener(TransportListener transportListener)
Adds a transport listener so that a client can be notified of events in
the underlying transport
|
void |
asyncSendPacket(Command command)
send a Packet through the Connection - for internal use only
|
void |
changeUserInfo(String userName,
String password)
Changes the associated username/password that is associated with this
connection.
|
void |
checkClientIDWasManuallySpecified()
Ensures that the clientID was manually specified and not auto-generated.
|
protected void |
checkClosed()
simply throws an exception if the Connection is already closed
|
protected void |
checkClosedOrFailed()
simply throws an exception if the Connection is already closed or the
Transport has failed
|
void |
cleanup()
Cleans up this connection so that it's state is as if the connection was
just created.
|
void |
cleanUpTempDestinations()
Removes any TempDestinations that this connection has cached, ignoring
any exceptions generated because the destination is in use as they should
not be removed.
|
void |
close()
Closes the connection.
|
protected BlobTransferPolicy |
createBlobTransferPolicy() |
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Destination destination,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages)
Creates a connection consumer for this connection (optional operation).
|
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Destination destination,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages,
boolean noLocal) |
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Queue queue,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages)
Creates a connection consumer for this connection (optional operation).
|
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Topic topic,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages)
Creates a connection consumer for this connection (optional operation).
|
javax.jms.ConnectionConsumer |
createDurableConnectionConsumer(javax.jms.Topic topic,
String subscriptionName,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages)
Create a durable connection consumer for this connection (optional
operation).
|
javax.jms.ConnectionConsumer |
createDurableConnectionConsumer(javax.jms.Topic topic,
String subscriptionName,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages,
boolean noLocal)
Create a durable connection consumer for this connection (optional
operation).
|
javax.jms.QueueSession |
createQueueSession(boolean transacted,
int acknowledgeMode)
Creates a
QueueSession object. |
javax.jms.Session |
createSession(boolean transacted,
int acknowledgeMode)
Creates a
Session object. |
protected ActiveMQTempDestination |
createTempDestination(boolean topic)
Create the DestinationInfo object for the temporary destination.
|
javax.jms.TopicSession |
createTopicSession(boolean transacted,
int acknowledgeMode)
Creates a
TopicSession object. |
void |
deleteTempDestination(ActiveMQTempDestination destination) |
void |
destroyDestination(ActiveMQDestination destination) |
void |
doCleanup(boolean removeConnection) |
protected void |
ensureConnectionInfoSent()
Send the ConnectionInfo to the Broker
|
BlobTransferPolicy |
getBlobTransferPolicy() |
BrokerInfo |
getBrokerInfo()
Returns the broker information if it is available or null if it is not
available yet.
|
String |
getBrokerName()
Returns the broker name if one is available or null if one is not
available yet.
|
String |
getClientID()
Gets the client identifier for this connection.
|
ClientInternalExceptionListener |
getClientInternalExceptionListener()
Gets the
ClientInternalExceptionListener object for this connection. |
int |
getCloseTimeout() |
ConnectionInfo |
getConnectionInfo() |
JMSConnectionStatsImpl |
getConnectionStats() |
int |
getConnectResponseTimeout() |
long |
getConsumerFailoverRedeliveryWaitPeriod() |
DestinationSource |
getDestinationSource()
Returns the
DestinationSource object which can be used to listen to destinations
being created or destroyed or to enquire about the current destinations available on the broker |
javax.jms.ExceptionListener |
getExceptionListener()
Gets the
ExceptionListener object for this connection. |
protected ThreadPoolExecutor |
getExecutor() |
IOException |
getFirstFailureError() |
String |
getInitializedClientID() |
LongSequenceGenerator |
getLocalTransactionIdGenerator() |
int |
getMaxThreadPoolSize() |
javax.jms.ConnectionMetaData |
getMetaData()
Gets the metadata for this connection.
|
protected SessionId |
getNextSessionId() |
long |
getOptimizeAcknowledgeTimeOut() |
long |
getOptimizedAckScheduledAckInterval()
Gets the configured time interval that is used to force all MessageConsumers that have optimizedAcknowledge enabled
to send an ack for any outstanding Message Acks.
|
ActiveMQPrefetchPolicy |
getPrefetchPolicy() |
int |
getProducerWindowSize() |
int |
getProtocolVersion() |
RedeliveryPolicy |
getRedeliveryPolicy() |
RedeliveryPolicyMap |
getRedeliveryPolicyMap()
Gets the Connection's configured RedeliveryPolicyMap which will be used by all the
Consumers when dealing with transaction messages that have been rolled back.
|
RejectedExecutionHandler |
getRejectedTaskHandler() |
String |
getResourceManagerId() |
protected Scheduler |
getScheduler() |
int |
getSendTimeout() |
protected CopyOnWriteArrayList<ActiveMQSession> |
getSessions() |
TaskRunnerFactory |
getSessionTaskRunner() |
StatsImpl |
getStats() |
long |
getTimeCreated()
Returns the time this connection was created
|
MessageTransformer |
getTransformer() |
Transport |
getTransport() |
Transport |
getTransportChannel() |
List<String> |
getTrustedPackages() |
long |
getWarnAboutUnstartedConnectionTimeout() |
boolean |
hasDispatcher(ConsumerId consumerId) |
boolean |
isAlwaysSessionAsync() |
boolean |
isAlwaysSyncSend() |
boolean |
isCheckForDuplicates() |
boolean |
isClosed()
Returns true if the connection is closed
|
boolean |
isClosing()
Returns true if the connection is in the process of being closed
|
boolean |
isConsumerExpiryCheckEnabled() |
boolean |
isCopyMessageOnSend() |
boolean |
isDeleted(ActiveMQDestination dest) |
boolean |
isDisableTimeStampsByDefault() |
boolean |
isDispatchAsync() |
protected boolean |
isDuplicate(ActiveMQDispatcher dispatcher,
Message message) |
boolean |
isExclusiveConsumer() |
boolean |
isMessagePrioritySupported() |
boolean |
isNestedMapAndListEnabled() |
boolean |
isNonBlockingRedelivery() |
boolean |
isObjectMessageSerializationDefered() |
boolean |
isOptimizeAcknowledge() |
boolean |
isOptimizedMessageDispatch() |
boolean |
isRmIdFromConnectionId() |
boolean |
isSendAcksAsync() |
boolean |
isStarted()
Returns true if this connection has been started
|
boolean |
isStatsEnabled() |
boolean |
isTransactedIndividualAck() |
boolean |
isTransportFailed()
Returns true if the underlying transport has failed
|
boolean |
isTrustAllPackages() |
boolean |
isUseAsyncSend() |
boolean |
isUseCompression() |
boolean |
isUseDedicatedTaskRunner() |
boolean |
isUseRetroactiveConsumer() |
boolean |
isUserSpecifiedClientID() |
boolean |
isWatchTopicAdvisories() |
static ActiveMQConnection |
makeConnection()
A static helper method to create a new connection
|
static ActiveMQConnection |
makeConnection(String uri)
A static helper method to create a new connection
|
static ActiveMQConnection |
makeConnection(String user,
String password,
String uri)
A static helper method to create a new connection
|
void |
onAsyncException(Throwable error)
Used for handling async exceptions
|
void |
onClientInternalException(Throwable error)
Handles async client internal exceptions.
|
void |
onCommand(Object o)
called to process a command
|
protected void |
onConnectionControl(ConnectionControl command) |
protected void |
onConsumerControl(ConsumerControl command) |
void |
onException(IOException error)
An unrecoverable exception has occured on the transport
|
protected void |
onWireFormatInfo(WireFormatInfo info) |
protected void |
removeConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer)
Remove a ConnectionConsumer
|
protected void |
removeDispatcher(ActiveMQDispatcher dispatcher) |
void |
removeDispatcher(ConsumerId consumerId) |
void |
removeProducer(ProducerId producerId) |
protected void |
removeSession(ActiveMQSession session)
Used interanlly for removing Sessions from a Connection
|
void |
removeTransportListener(TransportListener transportListener) |
protected void |
rollbackDuplicate(ActiveMQDispatcher dispatcher,
Message message) |
void |
setAlwaysSessionAsync(boolean alwaysSessionAsync)
If this flag is not set then a separate thread is not used for dispatching messages for each Session in
the Connection.
|
void |
setAlwaysSyncSend(boolean alwaysSyncSend)
Set true if always require messages to be sync sent
|
void |
setAuditDepth(int auditDepth) |
void |
setAuditMaximumProducerNumber(int auditMaximumProducerNumber) |
void |
setBlobTransferPolicy(BlobTransferPolicy blobTransferPolicy)
Sets the policy used to describe how out-of-band BLOBs (Binary Large
OBjects) are transferred from producers to brokers to consumers
|
void |
setCheckForDuplicates(boolean checkForDuplicates) |
void |
setClientID(String newClientID)
Sets the client identifier for this connection.
|
void |
setClientInternalExceptionListener(ClientInternalExceptionListener listener)
Sets a client internal exception listener for this connection.
|
void |
setCloseTimeout(int closeTimeout)
Sets the timeout before a close is considered complete.
|
void |
setConnectResponseTimeout(int connectResponseTimeout) |
void |
setConsumerExpiryCheckEnabled(boolean consumerExpiryCheckEnabled)
Controls whether message expiration checking is done in each MessageConsumer
prior to dispatching a message.
|
void |
setConsumerFailoverRedeliveryWaitPeriod(long consumerFailoverRedeliveryWaitPeriod) |
void |
setCopyMessageOnSend(boolean copyMessageOnSend)
Should a JMS message be copied to a new JMS Message object as part of the
send() method in JMS.
|
void |
setDefaultClientID(String clientID)
Sets the default client id that the connection will use if explicitly not
set with the setClientId() call.
|
void |
setDisableTimeStampsByDefault(boolean timeStampsDisableByDefault)
Sets whether or not timestamps on messages should be disabled or not.
|
void |
setDispatchAsync(boolean asyncDispatch)
Enables or disables the default setting of whether or not consumers have
their messages dispatched
synchronously or asynchronously by the broker.
|
void |
setExceptionListener(javax.jms.ExceptionListener listener)
Sets an exception listener for this connection.
|
void |
setExclusiveConsumer(boolean exclusiveConsumer)
Enables or disables whether or not queue consumers should be exclusive or
not for example to preserve ordering when not using Message Groups
|
void |
setMaxThreadPoolSize(int maxThreadPoolSize) |
void |
setMessagePrioritySupported(boolean messagePrioritySupported) |
void |
setNestedMapAndListEnabled(boolean structuredMapsEnabled)
Enables/disables whether or not Message properties and MapMessage entries
support Nested
Structures of Map and List objects
|
void |
setNonBlockingRedelivery(boolean nonBlockingRedelivery) |
void |
setObjectMessageSerializationDefered(boolean objectMessageSerializationDefered)
When an object is set on an ObjectMessage, the JMS spec requires the
object to be serialized by that set method.
|
void |
setOptimizeAcknowledge(boolean optimizeAcknowledge)
Enables an optimised acknowledgement mode where messages are acknowledged
in batches rather than individually
|
void |
setOptimizeAcknowledgeTimeOut(long optimizeAcknowledgeTimeOut)
The max time in milliseconds between optimized ack batches
|
void |
setOptimizedAckScheduledAckInterval(long optimizedAckScheduledAckInterval)
Sets the amount of time between scheduled sends of any outstanding Message Acks for consumers that
have been configured with optimizeAcknowledge enabled.
|
void |
setOptimizedMessageDispatch(boolean dispatchOptimizedMessage)
If this flag is set then an larger prefetch limit is used - only
applicable for durable topic subscribers.
|
protected void |
setPassword(String password) |
void |
setPrefetchPolicy(ActiveMQPrefetchPolicy prefetchPolicy)
Sets the prefetch
policy for consumers created by this connection.
|
void |
setProducerWindowSize(int producerWindowSize) |
void |
setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
Sets the redelivery policy to be used when messages are rolled back
|
void |
setRedeliveryPolicyMap(RedeliveryPolicyMap redeliveryPolicyMap)
Sets the Connection wide RedeliveryPolicyMap for handling messages that are being rolled back.
|
void |
setRejectedTaskHandler(RejectedExecutionHandler rejectedTaskHandler) |
void |
setRmIdFromConnectionId(boolean rmIdFromConnectionId) |
void |
setSendAcksAsync(boolean sendAcksAsync) |
void |
setSendTimeout(int sendTimeout) |
void |
setSessionTaskRunner(TaskRunnerFactory sessionTaskRunner) |
void |
setStatsEnabled(boolean statsEnabled) |
void |
setTransactedIndividualAck(boolean transactedIndividualAck) |
void |
setTransformer(MessageTransformer transformer)
Sets the transformer used to transform messages before they are sent on
to the JMS bus or when they are received from the bus but before they are
delivered to the JMS client
|
void |
setTrustAllPackages(boolean trustAllPackages) |
void |
setTrustedPackages(List<String> trustedPackages) |
void |
setUseAsyncSend(boolean useAsyncSend)
Forces the use of Async Sends which
adds a massive performance boost; but means that the send() method will
return immediately whether the message has been sent or not which could
lead to message loss.
|
void |
setUseCompression(boolean useCompression)
Enables the use of compression of the message bodies
|
void |
setUseDedicatedTaskRunner(boolean useDedicatedTaskRunner) |
void |
setUseRetroactiveConsumer(boolean useRetroactiveConsumer)
Sets whether or not retroactive consumers are enabled.
|
protected void |
setUserName(String userName) |
void |
setWarnAboutUnstartedConnectionTimeout(long warnAboutUnstartedConnectionTimeout)
Enables the timeout from a connection creation to when a warning is
generated if the connection is not properly started via
start()
and a message is received by a consumer. |
void |
setWatchTopicAdvisories(boolean watchTopicAdvisories) |
void |
start()
Starts (or restarts) a connection's delivery of incoming messages.
|
void |
stop()
Temporarily stops a connection's delivery of incoming messages.
|
Response |
syncSendPacket(Command command)
Send a packet through a Connection - for internal use only
|
void |
syncSendPacket(Command command,
AsyncCallback onComplete)
Send a packet through a Connection - for internal use only
|
Response |
syncSendPacket(Command command,
int timeout) |
String |
toString() |
protected void |
transportFailed(IOException error) |
protected void |
transportInterruptionProcessingComplete() |
void |
transportInterupted()
The transport has suffered an interuption from which it hopes to recover
|
void |
transportResumed()
The transport has resumed after an interuption
|
void |
unsubscribe(String name)
Unsubscribes a durable subscription that has been created by a client.
|
protected void |
waitForTransportInterruptionProcessingToComplete() |
public static final String DEFAULT_USER
public static final String DEFAULT_PASSWORD
public static final String DEFAULT_BROKER_URL
public static int DEFAULT_THREAD_POOL_SIZE
public final ConcurrentMap<ActiveMQTempDestination,ActiveMQTempDestination> activeTempDestinations
protected boolean dispatchAsync
protected boolean alwaysSessionAsync
protected AtomicInteger transportInterruptionProcessingComplete
protected ActiveMQConnection(Transport transport, IdGenerator clientIdGenerator, IdGenerator connectionIdGenerator, JMSStatsImpl factoryStats) throws Exception
ActiveMQConnection
transport
- factoryStats
- Exception
protected void setUserName(String userName)
protected void setPassword(String password)
public static ActiveMQConnection makeConnection() throws javax.jms.JMSException
javax.jms.JMSException
public static ActiveMQConnection makeConnection(String uri) throws javax.jms.JMSException, URISyntaxException
uri
- javax.jms.JMSException
URISyntaxException
public static ActiveMQConnection makeConnection(String user, String password, String uri) throws javax.jms.JMSException, URISyntaxException
user
- password
- uri
- javax.jms.JMSException
URISyntaxException
public JMSConnectionStatsImpl getConnectionStats()
public javax.jms.Session createSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
Session
object.createSession
in interface javax.jms.Connection
transacted
- indicates whether the session is transactedacknowledgeMode
- indicates whether the consumer or the client will
acknowledge any messages it receives; ignored if the
session is transacted. Legal values are
Session.AUTO_ACKNOWLEDGE
,
Session.CLIENT_ACKNOWLEDGE
, and
Session.DUPS_OK_ACKNOWLEDGE
.javax.jms.JMSException
- if the Connection
object fails to
create a session due to some internal error or lack of
support for the specific transaction and acknowledgement
mode.Session.AUTO_ACKNOWLEDGE
,
Session.CLIENT_ACKNOWLEDGE
,
Session.DUPS_OK_ACKNOWLEDGE
protected SessionId getNextSessionId()
public String getClientID() throws javax.jms.JMSException
This value is specific to the JMS provider. It is either preconfigured by
an administrator in a ConnectionFactory
object or assigned
dynamically by the application by calling the setClientID
method.
getClientID
in interface javax.jms.Connection
javax.jms.JMSException
- if the JMS provider fails to return the client ID
for this connection due to some internal error.public void setClientID(String newClientID) throws javax.jms.JMSException
The preferred way to assign a JMS client's client identifier is for it to
be configured in a client-specific ConnectionFactory
object and transparently assigned to the Connection
object
it creates.
Alternatively, a client can set a connection's client identifier using a
provider-specific value. The facility to set a connection's client
identifier explicitly is not a mechanism for overriding the identifier
that has been administratively configured. It is provided for the case
where no administratively specified identifier exists. If one does exist,
an attempt to change it by setting it must throw an
IllegalStateException
. If a client sets the client
identifier explicitly, it must do so immediately after it creates the
connection and before any other action on the connection is taken. After
this point, setting the client identifier is a programming error that
should throw an IllegalStateException
.
The purpose of the client identifier is to associate a connection and its objects with a state maintained on behalf of the client by a provider. The only such state identified by the JMS API is that required to support durable subscriptions.
If another connection with the same clientID
is already
running when this method is called, the JMS provider should detect the
duplicate ID and throw an InvalidClientIDException
.
setClientID
in interface javax.jms.Connection
newClientID
- the unique client identifierjavax.jms.JMSException
- if the JMS provider fails to set the client ID for
this connection due to some internal error.javax.jms.InvalidClientIDException
- if the JMS client specifies an
invalid or duplicate client ID.javax.jms.IllegalStateException
- if the JMS client attempts to set
a connection's client ID at the wrong time or when it has
been administratively configured.public void setDefaultClientID(String clientID) throws javax.jms.JMSException
javax.jms.JMSException
public javax.jms.ConnectionMetaData getMetaData() throws javax.jms.JMSException
getMetaData
in interface javax.jms.Connection
javax.jms.JMSException
- if the JMS provider fails to get the connection
metadata for this connection.ConnectionMetaData
public javax.jms.ExceptionListener getExceptionListener() throws javax.jms.JMSException
ExceptionListener
object for this connection. Not
every Connection
has an ExceptionListener
associated with it.getExceptionListener
in interface javax.jms.Connection
ExceptionListener
for this connection, or
null, if no ExceptionListener
is associated with
this connection.javax.jms.JMSException
- if the JMS provider fails to get the
ExceptionListener
for this connection.Connection.setExceptionListener(ExceptionListener)
public void setExceptionListener(javax.jms.ExceptionListener listener) throws javax.jms.JMSException
If a JMS provider detects a serious problem with a connection, it informs
the connection's ExceptionListener
, if one has been
registered. It does this by calling the listener's onException
method, passing it a JMSException
object describing the
problem.
An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn their connection has failed.
A connection serializes execution of its ExceptionListener
.
A JMS provider should attempt to resolve connection problems itself before it notifies the client of them.
setExceptionListener
in interface javax.jms.Connection
listener
- the exception listenerjavax.jms.JMSException
- if the JMS provider fails to set the exception
listener for this connection.public ClientInternalExceptionListener getClientInternalExceptionListener()
ClientInternalExceptionListener
object for this connection.
Not every ActiveMQConnectionn
has a ClientInternalExceptionListener
associated with it.null
if no listener is registered with the connection.public void setClientInternalExceptionListener(ClientInternalExceptionListener listener)
onException()
method passing it a Throwable
describing the problem.listener
- the exception listenerpublic void start() throws javax.jms.JMSException
start
on a connection that has already been started is
ignored.start
in interface javax.jms.Connection
javax.jms.JMSException
- if the JMS provider fails to start message delivery
due to some internal error.Connection.stop()
public void stop() throws javax.jms.JMSException
start
method. When
the connection is stopped, delivery to all the connection's message
consumers is inhibited: synchronous receives block, and messages are not
delivered to message listeners.
This call blocks until receives and/or message listeners in progress have completed.
Stopping a connection has no effect on its ability to send messages. A
call to stop
on a connection that has already been stopped
is ignored.
A call to stop
must not return until delivery of messages
has paused. This means that a client can rely on the fact that none of
its message listeners will be called and that all threads of control
waiting for receive
calls to return will not return with a
message until the connection is restarted. The receive timers for a
stopped connection continue to advance, so receives may time out while
the connection is stopped.
If message listeners are running when stop
is invoked, the
stop
call must wait until all of them have returned before
it may return. While these message listeners are completing, they must
have the full services of the connection available to them.
stop
in interface javax.jms.Connection
javax.jms.JMSException
- if the JMS provider fails to stop message delivery
due to some internal error.Connection.start()
public void close() throws javax.jms.JMSException
Since a provider typically allocates significant resources outside the JVM on behalf of a connection, clients should close these resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.
There is no need to close the sessions, producers, and consumers of a closed connection.
Closing a connection causes all temporary destinations to be deleted.
When this method is invoked, it should not return until message
processing has been shut down in an orderly fashion. This means that all
message listeners that may have been running have returned, and that all
pending receives have returned. A close terminates all pending message
receives on the connection's sessions' consumers. The receives may return
with a message or with null, depending on whether there was a message
available at the time of the close. If one or more of the connection's
sessions' message listeners is processing a message at the time when
connection close
is invoked, all the facilities of the
connection and its sessions must remain available to those listeners
until they return control to the JMS provider.
Closing a connection causes any of its sessions' transactions in progress
to be rolled back. In the case where a session's work is coordinated by
an external transaction manager, a session's commit
and
rollback
methods are not used and the result of a closed
session's work is determined later by the transaction manager. Closing a
connection does NOT force an acknowledgment of client-acknowledged
sessions.
Invoking the acknowledge
method of a received message from
a closed connection's session must throw an
IllegalStateException
. Closing a closed connection must
NOT throw an exception.
close
in interface javax.jms.Connection
close
in interface Closeable
javax.jms.JMSException
- if the JMS provider fails to close the connection
due to some internal error. For example, a failure to
release resources or to close a socket connection can
cause this exception to be thrown.public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, String subscriptionName, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
createDurableConnectionConsumer
in interface javax.jms.Connection
createDurableConnectionConsumer
in interface javax.jms.TopicConnection
topic
- topic to accesssubscriptionName
- durable subscription namemessageSelector
- only messages with properties matching the message
selector expression are delivered. A value of null or an
empty string indicates that there is no message selector
for the message consumer.sessionPool
- the server session pool to associate with this durable
connection consumermaxMessages
- the maximum number of messages that can be assigned to
a server session at one timejavax.jms.JMSException
- if the Connection
object fails to
create a connection consumer due to some internal error
or invalid arguments for sessionPool
and
messageSelector
.javax.jms.InvalidDestinationException
- if an invalid destination
is specified.javax.jms.InvalidSelectorException
- if the message selector is
invalid.ConnectionConsumer
public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, String subscriptionName, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages, boolean noLocal) throws javax.jms.JMSException
topic
- topic to accesssubscriptionName
- durable subscription namemessageSelector
- only messages with properties matching the message
selector expression are delivered. A value of null or an
empty string indicates that there is no message selector
for the message consumer.sessionPool
- the server session pool to associate with this durable
connection consumermaxMessages
- the maximum number of messages that can be assigned to
a server session at one timenoLocal
- set true if you want to filter out messages published
locallyjavax.jms.JMSException
- if the Connection
object fails to
create a connection consumer due to some internal error
or invalid arguments for sessionPool
and
messageSelector
.javax.jms.InvalidDestinationException
- if an invalid destination
is specified.javax.jms.InvalidSelectorException
- if the message selector is
invalid.ConnectionConsumer
public boolean isStarted()
public boolean isClosed()
public boolean isClosing()
public boolean isTransportFailed()
public ActiveMQPrefetchPolicy getPrefetchPolicy()
public void setPrefetchPolicy(ActiveMQPrefetchPolicy prefetchPolicy)
public Transport getTransportChannel()
public String getInitializedClientID() throws javax.jms.JMSException
javax.jms.JMSException
public boolean isDisableTimeStampsByDefault()
public void setDisableTimeStampsByDefault(boolean timeStampsDisableByDefault)
public boolean isOptimizedMessageDispatch()
public void setOptimizedMessageDispatch(boolean dispatchOptimizedMessage)
public int getCloseTimeout()
public void setCloseTimeout(int closeTimeout)
public ConnectionInfo getConnectionInfo()
public boolean isUseRetroactiveConsumer()
public void setUseRetroactiveConsumer(boolean useRetroactiveConsumer)
public boolean isNestedMapAndListEnabled()
public void setNestedMapAndListEnabled(boolean structuredMapsEnabled)
public boolean isExclusiveConsumer()
public void setExclusiveConsumer(boolean exclusiveConsumer)
exclusiveConsumer
- public void addTransportListener(TransportListener transportListener)
public void removeTransportListener(TransportListener transportListener)
public boolean isUseDedicatedTaskRunner()
public void setUseDedicatedTaskRunner(boolean useDedicatedTaskRunner)
public TaskRunnerFactory getSessionTaskRunner()
public void setSessionTaskRunner(TaskRunnerFactory sessionTaskRunner)
public MessageTransformer getTransformer()
public void setTransformer(MessageTransformer transformer)
public boolean isStatsEnabled()
public void setStatsEnabled(boolean statsEnabled)
statsEnabled
- the statsEnabled to setpublic DestinationSource getDestinationSource() throws javax.jms.JMSException
DestinationSource
object which can be used to listen to destinations
being created or destroyed or to enquire about the current destinations available on the brokergetDestinationSource
in interface EnhancedConnection
javax.jms.JMSException
protected void addSession(ActiveMQSession session) throws javax.jms.JMSException
session
- javax.jms.JMSException
javax.jms.JMSException
protected void removeSession(ActiveMQSession session)
session
- protected void addConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer) throws javax.jms.JMSException
connectionConsumer
- javax.jms.JMSException
protected void removeConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer)
connectionConsumer
- public javax.jms.TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
TopicSession
object.createTopicSession
in interface javax.jms.TopicConnection
transacted
- indicates whether the session is transactedacknowledgeMode
- indicates whether the consumer or the client will
acknowledge any messages it receives; ignored if the
session is transacted. Legal values are
Session.AUTO_ACKNOWLEDGE
,
Session.CLIENT_ACKNOWLEDGE
, and
Session.DUPS_OK_ACKNOWLEDGE
.javax.jms.JMSException
- if the TopicConnection
object fails
to create a session due to some internal error or lack of
support for the specific transaction and acknowledgement
mode.Session.AUTO_ACKNOWLEDGE
,
Session.CLIENT_ACKNOWLEDGE
,
Session.DUPS_OK_ACKNOWLEDGE
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Topic topic, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
createConnectionConsumer
in interface javax.jms.TopicConnection
topic
- the topic to accessmessageSelector
- only messages with properties matching the message
selector expression are delivered. A value of null or an
empty string indicates that there is no message selector
for the message consumer.sessionPool
- the server session pool to associate with this
connection consumermaxMessages
- the maximum number of messages that can be assigned to
a server session at one timejavax.jms.JMSException
- if the TopicConnection
object fails
to create a connection consumer due to some internal
error or invalid arguments for sessionPool
and messageSelector
.javax.jms.InvalidDestinationException
- if an invalid topic is
specified.javax.jms.InvalidSelectorException
- if the message selector is
invalid.ConnectionConsumer
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Queue queue, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
createConnectionConsumer
in interface javax.jms.QueueConnection
queue
- the queue to accessmessageSelector
- only messages with properties matching the message
selector expression are delivered. A value of null or an
empty string indicates that there is no message selector
for the message consumer.sessionPool
- the server session pool to associate with this
connection consumermaxMessages
- the maximum number of messages that can be assigned to
a server session at one timejavax.jms.JMSException
- if the QueueConnection
object fails
to create a connection consumer due to some internal
error or invalid arguments for sessionPool
and messageSelector
.javax.jms.InvalidDestinationException
- if an invalid queue is
specified.javax.jms.InvalidSelectorException
- if the message selector is
invalid.ConnectionConsumer
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
createConnectionConsumer
in interface javax.jms.Connection
destination
- the destination to accessmessageSelector
- only messages with properties matching the message
selector expression are delivered. A value of null or an
empty string indicates that there is no message selector
for the message consumer.sessionPool
- the server session pool to associate with this
connection consumermaxMessages
- the maximum number of messages that can be assigned to
a server session at one timejavax.jms.JMSException
- if the Connection
object fails to
create a connection consumer due to some internal error
or invalid arguments for sessionPool
and
messageSelector
.javax.jms.InvalidDestinationException
- if an invalid destination
is specified.javax.jms.InvalidSelectorException
- if the message selector is
invalid.ConnectionConsumer
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages, boolean noLocal) throws javax.jms.JMSException
javax.jms.JMSException
public javax.jms.QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
QueueSession
object.createQueueSession
in interface javax.jms.QueueConnection
transacted
- indicates whether the session is transactedacknowledgeMode
- indicates whether the consumer or the client will
acknowledge any messages it receives; ignored if the
session is transacted. Legal values are
Session.AUTO_ACKNOWLEDGE
,
Session.CLIENT_ACKNOWLEDGE
, and
Session.DUPS_OK_ACKNOWLEDGE
.javax.jms.JMSException
- if the QueueConnection
object fails
to create a session due to some internal error or lack of
support for the specific transaction and acknowledgement
mode.Session.AUTO_ACKNOWLEDGE
,
Session.CLIENT_ACKNOWLEDGE
,
Session.DUPS_OK_ACKNOWLEDGE
public void checkClientIDWasManuallySpecified() throws javax.jms.JMSException
javax.jms.JMSException
public void asyncSendPacket(Command command) throws javax.jms.JMSException
command
- javax.jms.JMSException
public void syncSendPacket(Command command, AsyncCallback onComplete) throws javax.jms.JMSException
command
- javax.jms.JMSException
public Response syncSendPacket(Command command, int timeout) throws javax.jms.JMSException
javax.jms.JMSException
public Response syncSendPacket(Command command) throws javax.jms.JMSException
command
- javax.jms.JMSException
public StatsImpl getStats()
getStats
in interface StatsCapable
protected void checkClosedOrFailed() throws javax.jms.JMSException
javax.jms.JMSException
protected void checkClosed() throws javax.jms.JMSException
javax.jms.JMSException
protected void ensureConnectionInfoSent() throws javax.jms.JMSException
javax.jms.JMSException
public boolean isWatchTopicAdvisories()
public void setWatchTopicAdvisories(boolean watchTopicAdvisories)
public boolean isUseAsyncSend()
public void setUseAsyncSend(boolean useAsyncSend)
public boolean isAlwaysSyncSend()
public void setAlwaysSyncSend(boolean alwaysSyncSend)
alwaysSyncSend
- public boolean isMessagePrioritySupported()
public void setMessagePrioritySupported(boolean messagePrioritySupported)
messagePrioritySupported
- the messagePrioritySupported to setpublic void cleanup() throws javax.jms.JMSException
javax.jms.JMSException
public boolean isUserSpecifiedClientID()
public void doCleanup(boolean removeConnection) throws javax.jms.JMSException
javax.jms.JMSException
public void changeUserInfo(String userName, String password) throws javax.jms.JMSException
javax.jms.IllegalStateException
- if the connection is in used.javax.jms.JMSException
public String getResourceManagerId() throws javax.jms.JMSException
javax.jms.JMSException
public String getBrokerName()
public BrokerInfo getBrokerInfo()
public RedeliveryPolicy getRedeliveryPolicy() throws javax.jms.JMSException
javax.jms.JMSException
public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
public BlobTransferPolicy getBlobTransferPolicy()
public void setBlobTransferPolicy(BlobTransferPolicy blobTransferPolicy)
public boolean isAlwaysSessionAsync()
public void setAlwaysSessionAsync(boolean alwaysSessionAsync)
public boolean isOptimizeAcknowledge()
public void setOptimizeAcknowledge(boolean optimizeAcknowledge)
optimizeAcknowledge
- The optimizeAcknowledge to set.public void setOptimizeAcknowledgeTimeOut(long optimizeAcknowledgeTimeOut)
optimizeAcknowledgeTimeOut
- public long getOptimizeAcknowledgeTimeOut()
public long getWarnAboutUnstartedConnectionTimeout()
public void setWarnAboutUnstartedConnectionTimeout(long warnAboutUnstartedConnectionTimeout)
start()
and a message is received by a consumer. It is a very common gotcha to
forget to start
the connection so this option makes the default case to create a
warning if the user forgets. To disable the warning just set the value to <
0 (say -1).public int getSendTimeout()
public void setSendTimeout(int sendTimeout)
sendTimeout
- the sendTimeout to set (in milliseconds)public boolean isSendAcksAsync()
public void setSendAcksAsync(boolean sendAcksAsync)
sendAcksAsync
- the sendAcksAsync to setpublic long getTimeCreated()
public Transport getTransport()
public void addProducer(ProducerId producerId, ActiveMQMessageProducer producer)
public void removeProducer(ProducerId producerId)
public void addDispatcher(ConsumerId consumerId, ActiveMQDispatcher dispatcher)
public void removeDispatcher(ConsumerId consumerId)
public boolean hasDispatcher(ConsumerId consumerId)
public void onCommand(Object o)
TransportListener
onCommand
in interface TransportListener
o
- - the command to consumeprotected void onWireFormatInfo(WireFormatInfo info)
public void onClientInternalException(Throwable error)
ClientInternalExceptionListener
by invoking
its onException
method, if one has been registered with this connection.error
- the exception that the problempublic void onAsyncException(Throwable error)
error
- public void onException(IOException error)
TransportListener
onException
in interface TransportListener
public void transportInterupted()
TransportListener
transportInterupted
in interface TransportListener
public void transportResumed()
TransportListener
transportResumed
in interface TransportListener
protected ActiveMQTempDestination createTempDestination(boolean topic) throws javax.jms.JMSException
topic
- - if its true topic, else queue.javax.jms.JMSException
public void deleteTempDestination(ActiveMQTempDestination destination) throws javax.jms.JMSException
destination
- javax.jms.JMSException
public boolean isDeleted(ActiveMQDestination dest)
public boolean isCopyMessageOnSend()
public LongSequenceGenerator getLocalTransactionIdGenerator()
public boolean isUseCompression()
public void setUseCompression(boolean useCompression)
public void destroyDestination(ActiveMQDestination destination) throws javax.jms.JMSException
javax.jms.JMSException
public boolean isDispatchAsync()
public void setDispatchAsync(boolean asyncDispatch)
asyncDispatch
- If true then consumers created on this connection
will default to having their messages dispatched
asynchronously. The default value is true.public boolean isObjectMessageSerializationDefered()
public void setObjectMessageSerializationDefered(boolean objectMessageSerializationDefered)
public void unsubscribe(String name) throws javax.jms.InvalidDestinationException, javax.jms.JMSException
This method deletes the state being maintained on behalf of the subscriber by its provider.
It is erroneous for a client to delete a durable subscription while there
is an active MessageConsumer
or
TopicSubscriber
for the subscription, or while a consumed
message is part of a pending transaction or has not been acknowledged in
the session.
name
- the name used to identify this subscriptionjavax.jms.JMSException
- if the session fails to unsubscribe to the durable
subscription due to some internal error.javax.jms.InvalidDestinationException
- if an invalid subscription name is
specified.protected void onConnectionControl(ConnectionControl command)
protected void onConsumerControl(ConsumerControl command)
protected void transportFailed(IOException error)
public void setCopyMessageOnSend(boolean copyMessageOnSend)
protected BlobTransferPolicy createBlobTransferPolicy()
public int getProtocolVersion()
public int getProducerWindowSize()
public void setProducerWindowSize(int producerWindowSize)
public void setAuditDepth(int auditDepth)
public void setAuditMaximumProducerNumber(int auditMaximumProducerNumber)
protected void removeDispatcher(ActiveMQDispatcher dispatcher)
protected boolean isDuplicate(ActiveMQDispatcher dispatcher, Message message)
protected void rollbackDuplicate(ActiveMQDispatcher dispatcher, Message message)
public IOException getFirstFailureError()
protected void waitForTransportInterruptionProcessingToComplete() throws InterruptedException
InterruptedException
protected void transportInterruptionProcessingComplete()
public void setConsumerFailoverRedeliveryWaitPeriod(long consumerFailoverRedeliveryWaitPeriod)
public long getConsumerFailoverRedeliveryWaitPeriod()
protected Scheduler getScheduler() throws javax.jms.JMSException
javax.jms.JMSException
protected ThreadPoolExecutor getExecutor()
protected CopyOnWriteArrayList<ActiveMQSession> getSessions()
public boolean isCheckForDuplicates()
public void setCheckForDuplicates(boolean checkForDuplicates)
checkForDuplicates
- the checkForDuplicates to setpublic boolean isTransactedIndividualAck()
public void setTransactedIndividualAck(boolean transactedIndividualAck)
public boolean isNonBlockingRedelivery()
public void setNonBlockingRedelivery(boolean nonBlockingRedelivery)
public boolean isRmIdFromConnectionId()
public void setRmIdFromConnectionId(boolean rmIdFromConnectionId)
public void cleanUpTempDestinations()
public void setRedeliveryPolicyMap(RedeliveryPolicyMap redeliveryPolicyMap)
redeliveryPolicyMap
- the redeliveryPolicyMap to setpublic RedeliveryPolicyMap getRedeliveryPolicyMap()
public int getMaxThreadPoolSize()
public void setMaxThreadPoolSize(int maxThreadPoolSize)
public RejectedExecutionHandler getRejectedTaskHandler()
public void setRejectedTaskHandler(RejectedExecutionHandler rejectedTaskHandler)
public long getOptimizedAckScheduledAckInterval()
public void setOptimizedAckScheduledAckInterval(long optimizedAckScheduledAckInterval)
optimizedAckScheduledAckInterval
- the scheduledOptimizedAckInterval to setpublic boolean isConsumerExpiryCheckEnabled()
public void setConsumerExpiryCheckEnabled(boolean consumerExpiryCheckEnabled)
consumerExpiryCheckEnabled
- controls whether expiration checking is done prior to dispatch.public List<String> getTrustedPackages()
public void setTrustedPackages(List<String> trustedPackages)
public boolean isTrustAllPackages()
public void setTrustAllPackages(boolean trustAllPackages)
public int getConnectResponseTimeout()
public void setConnectResponseTimeout(int connectResponseTimeout)
Copyright © 2005–2019 The Apache Software Foundation. All rights reserved.