Class SimpleConnection
java.lang.Object
org.springframework.amqp.rabbit.connection.SimpleConnection
- All Implemented Interfaces:
com.rabbitmq.client.impl.NetworkConnection,AutoCloseable,Connection
public class SimpleConnection
extends Object
implements Connection, com.rabbitmq.client.impl.NetworkConnection
Simply a Connection.
- Since:
- 1.0
- Author:
- Dave Syer, Gary Russell, Artem Bilan, Salk Lee
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleConnection(com.rabbitmq.client.Connection delegate, int closeTimeout) SimpleConnection(com.rabbitmq.client.Connection delegate, int closeTimeout, @Nullable BackOffExecution backOffExecution) Construct an instance with theBackOffExecutionarguments. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBlockedListener(com.rabbitmq.client.BlockedListener listener) Add aBlockedListener.voidclose()Close this connection and all its channels with theAMQP.REPLY_SUCCESSclose code and message 'OK'.com.rabbitmq.client.ChannelcreateChannel(boolean transactional) Create a new channel, using an internally allocated channel number.com.rabbitmq.client.ConnectionReturn the underlying RabbitMQ connection.@Nullable InetAddressintintgetPort()booleanisOpen()True if the connection is open.booleanremoveBlockedListener(com.rabbitmq.client.BlockedListener listener) Remove aBlockedListener.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.amqp.rabbit.connection.Connection
closeThreadChannel
-
Constructor Details
-
SimpleConnection
public SimpleConnection(com.rabbitmq.client.Connection delegate, int closeTimeout) -
SimpleConnection
public SimpleConnection(com.rabbitmq.client.Connection delegate, int closeTimeout, @Nullable BackOffExecution backOffExecution) Construct an instance with theBackOffExecutionarguments.- Parameters:
delegate- delegate connectioncloseTimeout- the time of physical close time outbackOffExecution- backOffExecution is nullable- Since:
- 3.1.3
-
-
Method Details
-
createChannel
public com.rabbitmq.client.Channel createChannel(boolean transactional) Description copied from interface:ConnectionCreate a new channel, using an internally allocated channel number.- Specified by:
createChannelin interfaceConnection- Parameters:
transactional- true if the channel should support transactions- Returns:
- a new channel descriptor, or null if none is available
-
close
public void close()Description copied from interface:ConnectionClose this connection and all its channels with theAMQP.REPLY_SUCCESSclose code and message 'OK'.Waits for all the close operations to complete.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection
-
isOpen
public boolean isOpen()True if the connection is open.- Specified by:
isOpenin interfaceConnection- Returns:
- true if the connection is open
- Throws:
AutoRecoverConnectionNotCurrentlyOpenException- if the connection is anAutorecoveringConnectionand is currently closed; this is required to prevent theCachingConnectionFactoryfrom discarding this connection and opening a new one, in which case the "old" connection would eventually be recovered and orphaned - also any consumers belonging to it might be recovered too and the broker will deliver messages to them when there is no code actually running to deal with those messages (when using theSimpleMessageListenerContainer). If we have actually closed the connection (e.g. viaCachingConnectionFactory.resetConnection()) this will return false.
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPortin interfaceConnection- Specified by:
getLocalPortin interfacecom.rabbitmq.client.impl.NetworkConnection- Returns:
- the local port if the underlying connection supports it.
-
addBlockedListener
public void addBlockedListener(com.rabbitmq.client.BlockedListener listener) Description copied from interface:ConnectionAdd aBlockedListener.- Specified by:
addBlockedListenerin interfaceConnection- Parameters:
listener- the listener to add- See Also:
-
removeBlockedListener
public boolean removeBlockedListener(com.rabbitmq.client.BlockedListener listener) Description copied from interface:ConnectionRemove aBlockedListener.- Specified by:
removeBlockedListenerin interfaceConnection- Parameters:
listener- the listener to remove- Returns:
trueif the listener was found and removed,falseotherwise- See Also:
-
getLocalAddress
- Specified by:
getLocalAddressin interfacecom.rabbitmq.client.impl.NetworkConnection
-
getAddress
- Specified by:
getAddressin interfacecom.rabbitmq.client.impl.NetworkConnection
-
getPort
public int getPort()- Specified by:
getPortin interfacecom.rabbitmq.client.impl.NetworkConnection
-
getDelegate
public com.rabbitmq.client.Connection getDelegate()Description copied from interface:ConnectionReturn the underlying RabbitMQ connection.- Specified by:
getDelegatein interfaceConnection- Returns:
- the connection.
-
toString
-