public class AMQConnection extends Closeable implements Connection, javax.jms.QueueConnection, javax.jms.TopicConnection, Referenceable
| Constructor and Description |
|---|
AMQConnection(ConnectionURL connectionURL)
TODO Some horrible stuff going on here with setting exceptions to be non-null to detect if an exception
was thrown during the connection! Intention not clear.
|
AMQConnection(String connection) |
AMQConnection(String host,
int port,
String username,
String password,
String clientName,
String virtualHost) |
AMQConnection(String broker,
String username,
String password,
String clientName,
String virtualHost) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
attemptReconnection() |
boolean |
attemptReconnection(String host,
int port) |
void |
blockUntilNotFailingOver()
If failover is taking place this will block until it has completed.
|
void |
bytesReceived(long receivedBytes) |
void |
bytesSent(long writtenBytes) |
boolean |
channelLimitReached() |
protected boolean |
checkException(Throwable thrown) |
void |
close()
Closes this object.
|
void |
close(long timeout) |
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Destination destination,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages) |
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Queue queue,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages) |
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Topic topic,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages) |
javax.jms.ConnectionConsumer |
createDurableConnectionConsumer(javax.jms.Topic topic,
String subscriptionName,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages) |
javax.jms.QueueSession |
createQueueSession(boolean transacted,
int acknowledgeMode)
Returns an AMQQueueSessionAdaptor which wraps an AMQSession and throws IllegalStateExceptions where specified in
the JMS spec
|
Session |
createSession(boolean transacted,
int acknowledgeMode) |
Session |
createSession(boolean transacted,
int acknowledgeMode,
int prefetch)
Create a session specifying the prefetch limit of messages.
|
Session |
createSession(boolean transacted,
int acknowledgeMode,
int prefetchHigh,
int prefetchLow)
Create a session specifying the prefetch limit of messages.
|
javax.jms.TopicSession |
createTopicSession(boolean transacted,
int acknowledgeMode)
Returns an AMQTopicSessionAdapter which wraps an AMQSession and throws IllegalStateExceptions where specified in
the JMS spec
|
void |
deregisterSession(int channelId) |
void |
exceptionReceived(Throwable cause)
Invoked by the AMQProtocolSession when a protocol session exception has occurred.
|
<T,E extends Exception> |
executeRetrySupport(FailoverProtectedOperation<T,E> operation) |
boolean |
failoverAllowed() |
void |
fireFailoverComplete()
Fires a failover complete event to the registered connection listener (if any).
|
boolean |
firePreFailover(boolean redirect)
Fire the preFailover event to the registered connection listener (if any)
|
boolean |
firePreResubscribe()
Fire the preResubscribe event to the registered connection listener (if any).
|
BrokerDetails |
getActiveBrokerDetails()
Get the details of the currently active broker
|
String |
getBrokerUUID() |
String |
getClientID() |
ConnectionListener |
getConnectionListener()
Get the connection listener that has been registered with this connection, if any
|
Long |
getConnectionNumber() |
ConnectionURL |
getConnectionURL()
Returns connection url.
|
AMQShortString |
getDefaultQueueExchangeName() |
AMQShortString |
getDefaultTopicExchangeName() |
protected AMQConnectionDelegate |
getDelegate() |
javax.jms.ExceptionListener |
getExceptionListener() |
protected javax.jms.ExceptionListener |
getExceptionListenerNoCheck() |
Object |
getFailoverMutex()
In order to protect the consistency of the connection and its child sessions, consumers and producers, the
"failover mutex" must be held when doing any operations that could be corrupted during failover.
|
FailoverPolicy |
getFailoverPolicy() |
long |
getLastFailoverTime() |
long |
getMaximumChannelCount() |
long |
getMaximumFrameSize() |
long |
getMaxPrefetch()
Get the maximum number of messages that this connection can pre-fetch.
|
int |
getMessageCompressionThresholdSize() |
javax.jms.ConnectionMetaData |
getMetaData() |
int |
getNextChannelID() |
String |
getPassword() |
AMQProtocolHandler |
getProtocolHandler() |
ProtocolVersion |
getProtocolVersion() |
Reference |
getReference() |
AMQSession |
getSession(int channelId) |
ChannelToSessionMap |
getSessions() |
boolean |
getSyncAck()
Indicates whether we need to sync on every message ack
|
boolean |
getSyncPersistence()
Indicates whether persistent messages are synchronized
|
String |
getSyncPublish() |
AMQShortString |
getTemporaryQueueExchangeName() |
AMQShortString |
getTemporaryTopicExchangeName() |
String |
getUsername() |
String |
getVirtualHost() |
boolean |
isConnected() |
boolean |
isFailingOver() |
boolean |
isMessageCompressionDesired() |
boolean |
isUseLegacyMapMessageFormat() |
boolean |
isUseLegacyStreamMessageFormat() |
protected void |
logConnected(SocketAddress localAddress,
SocketAddress remoteAddress) |
ProtocolVersion |
makeBrokerConnection(BrokerDetails brokerDetail) |
void |
performConnectionTask(Runnable task) |
void |
resubscribeSessions() |
void |
setClientID(String clientID) |
protected boolean |
setClosed() |
protected void |
setConnected(boolean connected) |
void |
setConnectionListener(ConnectionListener listener) |
void |
setDefaultQueueExchangeName(AMQShortString defaultQueueExchangeName) |
void |
setDefaultTopicExchangeName(AMQShortString defaultTopicExchangeName) |
void |
setExceptionListener(javax.jms.ExceptionListener listener) |
void |
setFailoverPolicy(FailoverPolicy policy) |
void |
setMaximumChannelCount(long maximumChannelCount) |
void |
setMaximumFrameSize(long frameMax) |
void |
setTemporaryQueueExchangeName(AMQShortString temporaryQueueExchangeName) |
void |
setTemporaryTopicExchangeName(AMQShortString temporaryTopicExchangeName) |
void |
setUsername(String id) |
void |
start()
Start the connection, i.e.
|
boolean |
started() |
void |
stop() |
String |
toString() |
String |
toURL()
Returns stringified connection url.
|
boolean |
validateQueueOnSend() |
checkNotClosed, isClosed, isClosing, resetClosedFlag, setClosingpublic AMQConnection(String broker, String username, String password, String clientName, String virtualHost) throws AMQException, URLSyntaxException
broker - brokerdetailsusername - usernamepassword - passwordclientName - clientidvirtualHost - virtualhostAMQExceptionURLSyntaxExceptionpublic AMQConnection(String host, int port, String username, String password, String clientName, String virtualHost) throws AMQException, URLSyntaxException
AMQExceptionURLSyntaxExceptionpublic AMQConnection(String connection) throws AMQException, URLSyntaxException
AMQExceptionURLSyntaxExceptionpublic AMQConnection(ConnectionURL connectionURL) throws AMQException
AMQExceptionprotected boolean checkException(Throwable thrown)
public boolean attemptReconnection(String host, int port)
public boolean attemptReconnection()
public ProtocolVersion makeBrokerConnection(BrokerDetails brokerDetail) throws IOException, AMQException
IOExceptionAMQExceptionpublic <T,E extends Exception> T executeRetrySupport(FailoverProtectedOperation<T,E> operation) throws E extends Exception
E extends Exceptionpublic BrokerDetails getActiveBrokerDetails()
public boolean failoverAllowed()
public Session createSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
createSession in interface javax.jms.Connectionjavax.jms.JMSExceptionpublic Session createSession(boolean transacted, int acknowledgeMode, int prefetch) throws javax.jms.JMSException
Connectionprefetch - the maximum number of messages to buffer in the client. This
applies as a total across all consumersjavax.jms.JMSExceptionpublic Session createSession(boolean transacted, int acknowledgeMode, int prefetchHigh, int prefetchLow) throws javax.jms.JMSException
ConnectionprefetchHigh - the maximum number of messages to buffer in the client.
This applies as a total across all consumersprefetchLow - the number of messages that must be in the buffer in the client to renable message flow.
This applies as a total across all consumersjavax.jms.JMSExceptionpublic void setFailoverPolicy(FailoverPolicy policy)
public FailoverPolicy getFailoverPolicy()
public javax.jms.QueueSession createQueueSession(boolean transacted,
int acknowledgeMode)
throws javax.jms.JMSException
createQueueSession in interface javax.jms.QueueConnectiontransacted - acknowledgeMode - javax.jms.JMSExceptionpublic javax.jms.TopicSession createTopicSession(boolean transacted,
int acknowledgeMode)
throws javax.jms.JMSException
createTopicSession in interface javax.jms.TopicConnectiontransacted - acknowledgeMode - javax.jms.JMSExceptionpublic boolean channelLimitReached()
public String getClientID() throws javax.jms.JMSException
getClientID in interface javax.jms.Connectionjavax.jms.JMSExceptionpublic void setClientID(String clientID) throws javax.jms.JMSException
setClientID in interface javax.jms.Connectionjavax.jms.JMSExceptionpublic javax.jms.ConnectionMetaData getMetaData()
throws javax.jms.JMSException
getMetaData in interface javax.jms.Connectionjavax.jms.JMSExceptionprotected final javax.jms.ExceptionListener getExceptionListenerNoCheck()
public javax.jms.ExceptionListener getExceptionListener()
throws javax.jms.JMSException
getExceptionListener in interface javax.jms.Connectionjavax.jms.JMSExceptionpublic void setExceptionListener(javax.jms.ExceptionListener listener)
throws javax.jms.JMSException
setExceptionListener in interface javax.jms.Connectionjavax.jms.JMSExceptionpublic void start()
throws javax.jms.JMSException
start in interface javax.jms.Connectionjavax.jms.JMSExceptionpublic void stop()
throws javax.jms.JMSException
stop in interface javax.jms.Connectionjavax.jms.JMSExceptionpublic void close()
throws javax.jms.JMSException
Closeablepublic void close(long timeout)
throws javax.jms.JMSException
javax.jms.JMSExceptionpublic 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.Connectionjavax.jms.JMSExceptionpublic 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.QueueConnectionjavax.jms.JMSExceptionpublic 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.TopicConnectionjavax.jms.JMSExceptionpublic 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.ConnectioncreateDurableConnectionConsumer in interface javax.jms.TopicConnectionjavax.jms.JMSExceptionpublic long getMaximumChannelCount()
throws javax.jms.JMSException
javax.jms.JMSExceptionpublic void setConnectionListener(ConnectionListener listener)
public ConnectionListener getConnectionListener()
Connectionpublic void setMaximumChannelCount(long maximumChannelCount)
public void setMaximumFrameSize(long frameMax)
public long getMaximumFrameSize()
public ChannelToSessionMap getSessions()
public String getUsername()
public void setUsername(String id)
public String getPassword()
public String getVirtualHost()
public final AMQProtocolHandler getProtocolHandler()
public final boolean started()
public final boolean isConnected()
protected final void setConnected(boolean connected)
public void bytesSent(long writtenBytes)
public void bytesReceived(long receivedBytes)
public boolean firePreFailover(boolean redirect)
redirect - true if this is the result of a redirect request rather than a connection errorpublic boolean firePreResubscribe()
throws javax.jms.JMSException
javax.jms.JMSExceptionpublic void fireFailoverComplete()
public final Object getFailoverMutex()
public void resubscribeSessions()
throws javax.jms.JMSException,
AMQException,
FailoverException
javax.jms.JMSExceptionAMQExceptionFailoverExceptionpublic void blockUntilNotFailingOver()
throws InterruptedException
InterruptedExceptionpublic void exceptionReceived(Throwable cause)
cause - the exceptionpublic void deregisterSession(int channelId)
public ConnectionURL getConnectionURL()
public String toURL()
AMQConnectionURL.toString() converts any password to asterisks.public Reference getReference() throws NamingException
getReference in interface ReferenceableNamingExceptionpublic AMQShortString getDefaultTopicExchangeName()
public void setDefaultTopicExchangeName(AMQShortString defaultTopicExchangeName)
public AMQShortString getDefaultQueueExchangeName()
public void setDefaultQueueExchangeName(AMQShortString defaultQueueExchangeName)
public AMQShortString getTemporaryTopicExchangeName()
public AMQShortString getTemporaryQueueExchangeName()
public void setTemporaryTopicExchangeName(AMQShortString temporaryTopicExchangeName)
public void setTemporaryQueueExchangeName(AMQShortString temporaryQueueExchangeName)
public void performConnectionTask(Runnable task)
public AMQSession getSession(int channelId)
public ProtocolVersion getProtocolVersion()
public String getBrokerUUID()
public boolean isFailingOver()
public long getMaxPrefetch()
public boolean getSyncPersistence()
public boolean getSyncAck()
public String getSyncPublish()
public boolean isMessageCompressionDesired()
public int getNextChannelID()
public boolean isUseLegacyMapMessageFormat()
public boolean isUseLegacyStreamMessageFormat()
public long getLastFailoverTime()
protected AMQConnectionDelegate getDelegate()
public Long getConnectionNumber()
protected void logConnected(SocketAddress localAddress, SocketAddress remoteAddress)
public boolean validateQueueOnSend()
public int getMessageCompressionThresholdSize()
Copyright © 2006–2015 The Apache Software Foundation. All rights reserved.