Class SimpleConnection
- java.lang.Object
-
- org.springframework.amqp.rabbit.connection.SimpleConnection
-
- All Implemented Interfaces:
com.rabbitmq.client.impl.NetworkConnection
,java.lang.AutoCloseable
,Connection
public class SimpleConnection extends java.lang.Object implements Connection, com.rabbitmq.client.impl.NetworkConnection
Simply a Connection.- Since:
- 1.0
- Author:
- Dave Syer, Gary Russell, Artem Bilan
-
-
Constructor Summary
Constructors Constructor Description SimpleConnection(com.rabbitmq.client.Connection delegate, int closeTimeout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.java.net.InetAddress
getAddress()
com.rabbitmq.client.Connection
getDelegate()
Return the underlying RabbitMQ connection.java.net.InetAddress
getLocalAddress()
int
getLocalPort()
int
getPort()
boolean
isOpen()
True if the connection is open.boolean
removeBlockedListener(com.rabbitmq.client.BlockedListener listener)
Remove aBlockedListener
.java.lang.String
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
-
-
-
-
Method Detail
-
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 interfacejava.lang.AutoCloseable
- 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
public java.net.InetAddress getLocalAddress()
- Specified by:
getLocalAddress
in interfacecom.rabbitmq.client.impl.NetworkConnection
-
getAddress
public java.net.InetAddress 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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-