com.supermap.messagequeue
Class AMQPManager
- java.lang.Object
-
- com.supermap.messagequeue.InternalHandle
-
- com.supermap.messagequeue.AMQPManager
-
public class AMQPManager extends InternalHandle
AMQP manager class. Message bus client scheme based on AMQP protocolUsed to create and bind the queue, switch, receive and send. Through binding queue and switch, and set the unique routingkey to realize the message receiving and sending.
Please note that, the receiver needs to receive the messages in the sub-thread. And the receive messages is blocking.
-
-
Constructor Summary
Constructors Constructor and Description AMQPManager()
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
bindQueue(java.lang.String exchange, java.lang.String queue, java.lang.String bindingKey)
Bind the queue and switch through the specified routingkeyboolean
connection(java.lang.String ip, int port, java.lang.String hostName, java.lang.String usrName, java.lang.String password, java.lang.String clientID)
Builds connectionboolean
declareExchange(java.lang.String name, AMQPExchangeType exchangeType)
Declares the switchboolean
declareQueue(java.lang.String queueName)
Declare the queueboolean
deleteExchange(java.lang.String name)
Delete the switchboolean
deleteQueue(java.lang.String queueName)
Delete the queuevoid
disconnection()
DisconnectAMQPReceiver
newReceiver(java.lang.String queueName)
Creates a receiverAMQPSender
newSender()
Creates a senderboolean
unbindQueue(java.lang.String queue, java.lang.String exchange, java.lang.String bindingKey)
Remove the binding between queue and switch
-
-
-
Method Detail
-
connection
public boolean connection(java.lang.String ip, int port, java.lang.String hostName, java.lang.String usrName, java.lang.String password, java.lang.String clientID)
Builds connection- Parameters:
ip
- Service IPport
- Port NumberhostName
- Virtual Host NameusrName
- Usernamepassword
- PasswordclientID
- The custom client name. Users can use it to distinguish who is sending messages- Returns:
- Whether the connection is success
-
disconnection
public void disconnection()
Disconnect
-
newSender
public AMQPSender newSender()
Creates a sender- Returns:
- Returns the send object
-
newReceiver
public AMQPReceiver newReceiver(java.lang.String queueName)
Creates a receiver- Parameters:
queueName
- queue name- Returns:
- Returns the receive port object
-
declareExchange
public boolean declareExchange(java.lang.String name, AMQPExchangeType exchangeType)
Declares the switch- Parameters:
name
- Switch nameexchangeType
- Switch type- Returns:
- Declare true if sent successfully; otherwise false.
-
deleteExchange
public boolean deleteExchange(java.lang.String name)
Delete the switch- Parameters:
name
- Switch name- Returns:
- Returns true if it is removed successfully; false otherwise.
-
declareQueue
public boolean declareQueue(java.lang.String queueName)
Declare the queue- Parameters:
queueName
- queue name- Returns:
- Declare true if sent successfully; otherwise false.
-
deleteQueue
public boolean deleteQueue(java.lang.String queueName)
Delete the queue- Parameters:
queueName
- queue name- Returns:
- Returns true if it is removed successfully; false otherwise.
-
bindQueue
public boolean bindQueue(java.lang.String exchange, java.lang.String queue, java.lang.String bindingKey)
Bind the queue and switch through the specified routingkey- Parameters:
exchange
- Switch namequeue
- queue namebindingKey
- The key used for binding- Returns:
- True, if successful; otherwise false.
-
unbindQueue
public boolean unbindQueue(java.lang.String queue, java.lang.String exchange, java.lang.String bindingKey)
Remove the binding between queue and switch- Parameters:
queue
- queue nameexchange
- Switch namebindingKey
- The key used to bind the queue and switch- Returns:
- True, if successful; otherwise false.
-
-