public class SpringCloudCommandRouter extends Object implements CommandRouter
CommandRouter
implementation which uses Spring Clouds
DiscoveryClient
s to discover and notify other nodes for routing
Commands.Constructor and Description |
---|
SpringCloudCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient,
RoutingStrategy routingStrategy)
Initialize a
CommandRouter with the given
DiscoveryClient to update it's own membership as a
CommandRouter and to create it's own awareness of available nodes to send commands to in a
ConsistentHash . |
SpringCloudCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient,
RoutingStrategy routingStrategy,
Serializer serializer)
Deprecated.
serializer is no longer customizable |
Modifier and Type | Method and Description |
---|---|
Optional<Member> |
findDestination(CommandMessage<?> commandMessage)
Returns the member instance to which the given
message should be routed. |
void |
updateMembership(int loadFactor,
Predicate<? super CommandMessage<?>> commandFilter)
Updates the load factor and capabilities of this member representing the current endpoint if the implementation
allows memberships to be updated dynamically.
|
void |
updateMemberships(org.springframework.cloud.client.discovery.event.HeartbeatEvent event) |
@Deprecated public SpringCloudCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient, RoutingStrategy routingStrategy, Serializer serializer)
serializer
is no longer customizableCommandRouter
with the given
DiscoveryClient
to update it's own membership as a
CommandRouter
and to create it's own awareness of available nodes to send commands to in a
ConsistentHash
. The routingStrategy
is used to
define the key based on which Command Messages are routed to their respective handler nodes.
The serializer
is used to serialize this node it's set of Commands it can handle to be added as meta data
to this ServiceInstance
discoveryClient
- The DiscoveryClient
used to discovery and notify other nodesroutingStrategy
- The strategy for routing Commands to a Nodeserializer
- The serializer used to serialize this node it's set of Commands it can handlepublic SpringCloudCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient, RoutingStrategy routingStrategy)
CommandRouter
with the given
DiscoveryClient
to update it's own membership as a
CommandRouter
and to create it's own awareness of available nodes to send commands to in a
ConsistentHash
. The routingStrategy
is used to
define the key based on which Command Messages are routed to their respective handler nodes.discoveryClient
- The DiscoveryClient
used to discovery and notify other nodesroutingStrategy
- The strategy for routing Commands to a Nodepublic Optional<Member> findDestination(CommandMessage<?> commandMessage)
CommandRouter
message
should be routed. If no suitable member could be
found an empty Optional is returned.findDestination
in interface CommandRouter
commandMessage
- the command message to find a member forpublic void updateMembership(int loadFactor, Predicate<? super CommandMessage<?>> commandFilter)
CommandRouter
updateMembership
in interface CommandRouter
loadFactor
- the new load factor of the member for this endpointcommandFilter
- the new capabilities of the member for this endpoint@EventListener public void updateMemberships(org.springframework.cloud.client.discovery.event.HeartbeatEvent event)
Copyright © 2010–2017. All rights reserved.