.withInterceptors(interceptors) .dispatch(serializer.serialize(command, routingStrategy.getRoutingKey(command), priorityCalculator.determinePriority(command)), new StreamObserver<CommandResponse>() {
@Override public Optional<Member> findDestination(CommandMessage<?> message) { String routingKey = routingStrategy.getRoutingKey(message); return consistentHash.get().getMember(routingKey, message); }
@Override public Optional<Member> findDestination(CommandMessage<?> commandMessage) { return atomicConsistentHash.get().getMember(routingStrategy.getRoutingKey(commandMessage), commandMessage); }
@Override public Optional<Member> findDestination(CommandMessage<?> message) { String routingKey = routingStrategy.getRoutingKey(message); return consistentHash.get().getMember(routingKey, message); }
/** * {@inheritDoc} * * @throws CommandDispatchException when an error occurs while dispatching the command to a segment */ @Override public void dispatch(CommandMessage<?> command) { command = intercept(command); String routingKey = routingStrategy.getRoutingKey(command); try { connector.send(routingKey, command); } catch (Exception e) { logger.error(DISPATCH_ERROR_MESSAGE, e); } }
/** * {@inheritDoc} * * @throws CommandDispatchException when an error occurs while dispatching the command to a segment */ @Override public <R> void dispatch(CommandMessage<?> command, CommandCallback<R> callback) { command = intercept(command); String routingKey = routingStrategy.getRoutingKey(command); try { connector.send(routingKey, command, callback); } catch (Exception e) { callback.onFailure(new CommandDispatchException(DISPATCH_ERROR_MESSAGE + ": " + e.getMessage(), e)); } }
.withInterceptors(interceptors) .dispatch(serializer.serialize(command, routingStrategy.getRoutingKey(command), priorityCalculator.determinePriority(command)), new StreamObserver<CommandResponse>() {