public class MessageRouter
extends java.lang.Object
Constructor and Description |
---|
MessageRouter() |
Modifier and Type | Method and Description |
---|---|
void |
addRoute(CommandId commandId_,
MessageHandler messageHandler_,
int requestedAcks_,
int systemAcks_,
boolean isSubscribe_)
Adds a route to self.
|
void |
clear()
Removes all routes from self (MessageRouter).
|
int |
deliverAck(Message ackMessage_,
int ackType_)
Deliver a message that is known already to be an Ack.
|
int |
deliverData(Message dataMessage_)
Delivers a data message (not an Ack) to the registered route.
|
int |
deliverData(Message dataMessage_,
CommandId commandId_)
Delivers a data message using a specific command ID from the message.
|
MessageHandler |
findRoute(CommandId commandId_)
Find and return a route.
|
boolean |
hasRoute(CommandId commandId_)
Return whether or not a command id has a route.
|
boolean |
removeRoute(CommandId commandId_)
Remove a route from MessageRouter.
|
void |
unsubscribeAll()
Removes all routes for subscriptions.
|
public void addRoute(CommandId commandId_, MessageHandler messageHandler_, int requestedAcks_, int systemAcks_, boolean isSubscribe_)
commandId_
- The command, query, or subid used for this route.messageHandler_
- The message handler to route to.requestedAcks_
- The acks requested by the AMPS client infrastructure.systemAcks_
- The acks requested by AMPS client infrastructure. These will not
be delivered to the message handler, but are still processed for
auto-removal.isSubscribe_
- True if this route is for an ongoing subscription.public boolean removeRoute(CommandId commandId_)
commandId_
- The route to remove.public MessageHandler findRoute(CommandId commandId_)
commandId_
- The command id for this route.public boolean hasRoute(CommandId commandId_)
commandId_
- The command id for this route.public void unsubscribeAll()
public void clear()
public int deliverAck(Message ackMessage_, int ackType_) throws java.lang.Exception
ackMessage_
- The Message to deliver.ackType_
- The ack type from that message.java.lang.Exception
- Any exception from user message handlers.public int deliverData(Message dataMessage_) throws java.lang.Exception
dataMessage_
- The non-ack message to deliver.java.lang.Exception
- Any exception thrown by the user message handler.public int deliverData(Message dataMessage_, CommandId commandId_) throws java.lang.Exception
dataMessage_
- The message to deliver.commandId_
- The command ID which will be used to lookup the delivery
routejava.lang.Exception
- Any exception returned thrown by the message handler.