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.
|
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 self.
|
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 torequestedAcks_
- The acks requested by the user for this commandsystemAcks_
- The acks not requested by the end user, but requested
by AMPS. 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 subscriptionpublic boolean removeRoute(CommandId commandId_)
commandId_
- The route to removepublic MessageHandler findRoute(CommandId commandId_)
commandId_
- The command id for this routepublic boolean hasRoute(CommandId commandId_)
commandId_
- The command id for this routepublic 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.