org.axonframework.commandhandling.distributed
Interface CommandBusConnector

All Known Implementing Classes:
JGroupsConnector

public interface CommandBusConnector

Interface describing the component that remotely connects multiple CommandBus instances.

Since:
2.0
Author:
Allard Buijze

Method Summary
 void send(String routingKey, CommandMessage<?> command)
          Sends the given command to the node assigned to handle messages with the given routingKey.
<R> void
send(String routingKey, CommandMessage<?> command, CommandCallback<R> callback)
          Sends the given command to the node assigned to handle messages with the given routingKey.
<C> void
subscribe(String commandName, CommandHandler<? super C> handler)
          Subscribe the given handler to commands of type commandType to the local segment of the command bus.
<C> boolean
unsubscribe(String commandName, CommandHandler<? super C> handler)
          Unsubscribe the given handler to commands of type commandType.
 

Method Detail

send

void send(String routingKey,
          CommandMessage<?> command)
          throws Exception
Sends the given 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.

Parameters:
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
Throws:
Exception - when an error occurs before or during the sending of the message

send

<R> void send(String routingKey,
              CommandMessage<?> command,
              CommandCallback<R> callback)
          throws Exception
Sends the given 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.

Type Parameters:
R - The type of object expected as return value in the callback
Parameters:
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
callback - The callback on which result notifications are sent
Throws:
Exception - when an error occurs before or during the sending of the message

subscribe

<C> void subscribe(String commandName,
                   CommandHandler<? super C> handler)
Subscribe the given 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.

Type Parameters:
C - The Type of command
Parameters:
commandName - The name of the command to subscribe the handler to
handler - The handler instance that handles the given type of command

unsubscribe

<C> boolean unsubscribe(String commandName,
                        CommandHandler<? super C> handler)
Unsubscribe the given handler to commands of type commandType. If the handler is not currently assigned to that type of command, no action is taken.

Type Parameters:
C - The Type of command
Parameters:
commandName - The name of the command the handler is subscribed to
handler - The handler instance to unsubscribe from the CommandBus
Returns:
true of this handler is successfully unsubscribed, false of the given handler was not the current handler for given commandType.


Copyright © 2010-2016. All Rights Reserved.