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
ConstructorDescriptionSimpleConnection
(com.rabbitmq.client.Connection delegate, int closeTimeout) SimpleConnection
(com.rabbitmq.client.Connection delegate, int closeTimeout, BackOffExecution backOffExecution) Construct an instance with theBackOffExecution
arguments. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBlockedListener
(com.rabbitmq.client.BlockedListener listener) Add aBlockedListener
.void
close()
Close this connection and all its channels with theAMQP.REPLY_SUCCESS
close code and message 'OK'.com.rabbitmq.client.Channel
createChannel
(boolean transactional) Create a new channel, using an internally allocated channel number.com.rabbitmq.client.Connection
Return the underlying RabbitMQ connection.int
int
getPort()
boolean
isOpen()
True if the connection is open.boolean
removeBlockedListener
(com.rabbitmq.client.BlockedListener listener) Remove aBlockedListener
.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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 theBackOffExecution
arguments.- 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:Connection
Create a new channel, using an internally allocated channel number.- Specified by:
createChannel
in 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:Connection
Close this connection and all its channels with theAMQP.REPLY_SUCCESS
close code and message 'OK'. Waits for all the close operations to complete.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
-
isOpen
public boolean isOpen()True if the connection is open.- Specified by:
isOpen
in interfaceConnection
- Returns:
- true if the connection is open
- Throws:
AutoRecoverConnectionNotCurrentlyOpenException
- if the connection is anAutorecoveringConnection
and is currently closed; this is required to prevent theCachingConnectionFactory
from 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:
getLocalPort
in interfaceConnection
- Specified by:
getLocalPort
in 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:Connection
Add aBlockedListener
.- Specified by:
addBlockedListener
in interfaceConnection
- Parameters:
listener
- the listener to add- See Also:
-
Connection.addBlockedListener(BlockedListener)
-
removeBlockedListener
public boolean removeBlockedListener(com.rabbitmq.client.BlockedListener listener) Description copied from interface:Connection
Remove aBlockedListener
.- Specified by:
removeBlockedListener
in interfaceConnection
- Parameters:
listener
- the listener to remove- Returns:
true
if the listener was found and removed,false
otherwise- See Also:
-
Connection.removeBlockedListener(BlockedListener)
-
getLocalAddress
- Specified by:
getLocalAddress
in interfacecom.rabbitmq.client.impl.NetworkConnection
-
getAddress
- Specified by:
getAddress
in interfacecom.rabbitmq.client.impl.NetworkConnection
-
getPort
public int getPort()- Specified by:
getPort
in interfacecom.rabbitmq.client.impl.NetworkConnection
-
getDelegate
public com.rabbitmq.client.Connection getDelegate()Description copied from interface:Connection
Return the underlying RabbitMQ connection.- Specified by:
getDelegate
in interfaceConnection
- Returns:
- the connection.
-
toString
-