|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CommandBusConnector
Interface describing the component that remotely connects multiple CommandBus instances.
Method Summary | ||
---|---|---|
void |
send(String routingKey,
CommandMessage<?> command)
Sends the given command to the node assigned to handle messages with the given
routingKey . |
|
|
send(String routingKey,
CommandMessage<?> command,
CommandCallback<R> callback)
Sends the given command to the node assigned to handle messages with the given
routingKey . |
|
|
subscribe(String commandName,
CommandHandler<? super C> handler)
Subscribe the given handler to commands of type commandType to the local segment of the
command bus. |
|
|
unsubscribe(String commandName,
CommandHandler<? super C> handler)
Unsubscribe the given handler to commands of type commandType . |
Method Detail |
---|
void send(String routingKey, CommandMessage<?> command) throws Exception
command
to the node assigned to handle messages with the given
routingKey
. The sender does not expect a reply.
If this method throws an exception, the sender is guaranteed that the destination of the command did not receive
it. If the method returns normally, the actual implementation of the connector defines the delivery guarantees.
Connectors route the commands based on the given routingKey
. Using the same routingKey
will result in the command being sent to the same member. Each message must be sent to exactly one
member.
routingKey
- The key describing the routing requirements of this command. Generally, commands with the same
routingKey will be sent to the same destination.command
- The command to send to the (remote) member
Exception
- when an error occurs before or during the sending of the message<R> void send(String routingKey, CommandMessage<?> command, CommandCallback<R> callback) throws Exception
command
to the node assigned to handle messages with the given
routingKey
. The sender expect a reply, and will be notified of the result in the given
callback
.
If this method throws an exception, the sender is guaranteed that the destination of the command did not receive
it. If the method returns normally, the actual implementation of the connector defines the delivery guarantees.
Implementations should always invoke the callback with an outcome.
If a member's connection was lost, and the result of the command is unclear, the CommandCallback.onFailure(Throwable)
method is invoked with a RemoteCommandHandlingException
describing
the failed connection. A client may choose to resend a command.
Connectors route the commands based on the given routingKey
. Using the same routingKey
will result in the command being sent to the same member.
R
- The type of object expected as return value in the callbackroutingKey
- The key describing the routing requirements of this command. Generally, commands with the same
routingKey will be sent to the same destination.command
- The command to send to the (remote) membercallback
- The callback on which result notifications are sent
Exception
- when an error occurs before or during the sending of the message<C> void subscribe(String commandName, CommandHandler<? super C> handler)
handler
to commands of type commandType
to the local segment of the
command bus.
If a subscription already exists for the given type, the behavior is undefined. Implementations may throw an
Exception to refuse duplicate subscription or alternatively decide whether the existing or new
handler
gets the subscription.
C
- The Type of commandcommandName
- The name of the command to subscribe the handler tohandler
- The handler instance that handles the given type of command<C> boolean unsubscribe(String commandName, CommandHandler<? super C> handler)
handler
to commands of type commandType
. If the handler is not
currently assigned to that type of command, no action is taken.
C
- The Type of commandcommandName
- The name of the command the handler is subscribed tohandler
- The handler instance to unsubscribe from the CommandBus
true
of this handler is successfully unsubscribed, false
of the given
handler
was not the current handler for given commandType
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |