@Override public void send(String routingKey, CommandMessage<?> commandMessage) throws Exception { String destination = consistentHash.getMember(routingKey, commandMessage.getPayloadType().getName()); if (destination == null) { throw new CommandDispatchException( "No node known to accept " + commandMessage.getPayloadType().getName()); } Address dest = getAddress(destination); channel.send(dest, new DispatchMessage(commandMessage, serializer, false)); }
@Override public <R> void send( String routingKey, CommandMessage<?> commandMessage, CommandCallback<R> callback) throws Exception { String destination = consistentHash.getMember(routingKey, commandMessage.getPayloadType().getName()); if (destination == null) { throw new CommandDispatchException( "No node known to accept " + commandMessage.getPayloadType().getName()); } Address dest = getAddress(destination); callbacks.put( commandMessage.getIdentifier(), new MemberAwareCommandCallback<R>(dest, callback)); channel.send(dest, new DispatchMessage(commandMessage, serializer, true)); }