@RestController @RequestMapping(value="${axon.distributed.spring-cloud.fallback-url:/message-routing-information}") public class SpringCloudHttpBackupCommandRouter extends SpringCloudCommandRouter
SpringCloudCommandRouter
which has a
backup mechanism to provide Message Routing Information for other nodes and to retrieve Message Routing Information
from other Axon nodes.
It is annotated with the RestController
and contains the
GetMapping
annotated
getLocalMessageRoutingInformation()
function to have a queryable place to
retrieve this node its Message Routing Information.
The default endpoint for this is "/message-routing-information"
.
To configure this endpoint the "axon.distributed.spring-cloud.fallback-url" application property should be adjusted.
For retrieving the Message Routing Information from other Axon nodes, it uses a
RestTemplate
to request Message Routing Information through an override of the
getMessageRoutingInformation(ServiceInstance)
function.
serializer
Constructor and Description |
---|
SpringCloudHttpBackupCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient,
org.springframework.cloud.client.serviceregistry.Registration localServiceInstance,
RoutingStrategy routingStrategy,
Predicate<org.springframework.cloud.client.ServiceInstance> serviceInstanceFilter,
ConsistentHashChangeListener consistentHashChangeListener,
org.springframework.web.client.RestTemplate restTemplate,
String messageRoutingInformationEndpoint)
Initialize a
CommandRouter with the given DiscoveryClient to update its own membership as a CommandRouter and to create its own awareness of available nodes to send commands to in a ConsistentHash . |
SpringCloudHttpBackupCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient,
org.springframework.cloud.client.serviceregistry.Registration localServiceInstance,
RoutingStrategy routingStrategy,
Predicate<org.springframework.cloud.client.ServiceInstance> serviceInstanceFilter,
org.springframework.web.client.RestTemplate restTemplate,
String messageRoutingInformationEndpoint)
Initialize a
CommandRouter with the given DiscoveryClient to update its own membership as a CommandRouter and to create its own awareness of available nodes to send commands to in a ConsistentHash . |
SpringCloudHttpBackupCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient,
org.springframework.cloud.client.serviceregistry.Registration localServiceInstance,
RoutingStrategy routingStrategy,
org.springframework.web.client.RestTemplate restTemplate,
String messageRoutingInformationEndpoint)
Initialize a
CommandRouter with the given DiscoveryClient to update its own membership as a CommandRouter and to create its own awareness of available nodes to send commands to in a ConsistentHash . |
Modifier and Type | Method and Description |
---|---|
MessageRoutingInformation |
getLocalMessageRoutingInformation()
Get the local
MessageRoutingInformation , thus the MessageRoutingInformation of the node this
CommandRouter is a part of. |
protected Optional<MessageRoutingInformation> |
getMessageRoutingInformation(org.springframework.cloud.client.ServiceInstance serviceInstance)
Retrieve the
MessageRoutingInformation of the provided serviceInstance . |
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.
|
buildMember, findDestination, resetLocalMembership, serviceInstanceMetadataContainsMessageRoutingInformation, updateMemberships
@Autowired public SpringCloudHttpBackupCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient, org.springframework.cloud.client.serviceregistry.Registration localServiceInstance, RoutingStrategy routingStrategy, org.springframework.web.client.RestTemplate restTemplate, @Value(value="${axon.distributed.spring-cloud.fallback-url:/message-routing-information}") String messageRoutingInformationEndpoint)
CommandRouter
with the given DiscoveryClient
to update its own membership as a CommandRouter
and to create its 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 RestTemplate
is used as a backup mechanism to request another member's
MessageRoutingInformation
with.
Uses a default Predicate<ServiceInstance>
filter function which allows any
ServiceInstance
through the update membership process.
Uses a default NoOp ConsistentHashChangeListener
which is
called if the ConsistentHash changed.discoveryClient
- The DiscoveryClient
used to discovery and notify other nodeslocalServiceInstance
- A Registration
representing the local Service Instance of this application. Necessary
to differentiate between other instances for correct message routingroutingStrategy
- The strategy for routing Commands to a NoderestTemplate
- The RestTemplate
used to request another member's MessageRoutingInformation
with.messageRoutingInformationEndpoint
- The endpoint where to retrieve the another nodes message routing
information frompublic SpringCloudHttpBackupCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient, org.springframework.cloud.client.serviceregistry.Registration localServiceInstance, RoutingStrategy routingStrategy, Predicate<org.springframework.cloud.client.ServiceInstance> serviceInstanceFilter, org.springframework.web.client.RestTemplate restTemplate, String messageRoutingInformationEndpoint)
CommandRouter
with the given DiscoveryClient
to update its own membership as a CommandRouter
and to create its 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.
A Predicate<ServiceInstance>
to filter a ServiceInstance
from
the membership update loop.
The RestTemplate
is used as a backup mechanism to request another member's
MessageRoutingInformation
with.
* Uses a default NoOp ConsistentHashChangeListener
which is
called if the ConsistentHash changed.discoveryClient
- The DiscoveryClient
used to discovery and notify other nodeslocalServiceInstance
- A Registration
representing the local Service Instance of this application. Necessary
to differentiate between other instances for correct message routingroutingStrategy
- The strategy for routing Commands to a NodeserviceInstanceFilter
- The Predicate<ServiceInstance>
used to filterrestTemplate
- The RestTemplate
used to request another member's MessageRoutingInformation
with.messageRoutingInformationEndpoint
- The endpoint where to retrieve the
another nodes message routing
information frompublic SpringCloudHttpBackupCommandRouter(org.springframework.cloud.client.discovery.DiscoveryClient discoveryClient, org.springframework.cloud.client.serviceregistry.Registration localServiceInstance, RoutingStrategy routingStrategy, Predicate<org.springframework.cloud.client.ServiceInstance> serviceInstanceFilter, ConsistentHashChangeListener consistentHashChangeListener, org.springframework.web.client.RestTemplate restTemplate, String messageRoutingInformationEndpoint)
CommandRouter
with the given DiscoveryClient
to update its own membership as a CommandRouter
and to create its 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.
A Predicate<ServiceInstance>
to filter a ServiceInstance
from
the membership update loop.
The given consistentHashChangeListener
is notified about changes in membership that affect routing of
messages.
The RestTemplate
is used as a backup mechanism to request another member's
MessageRoutingInformation
with.discoveryClient
- The DiscoveryClient
used to discovery and notify other nodeslocalServiceInstance
- A Registration
representing the local Service Instance of this application. Necessary
to differentiate between other instances for correct message routingroutingStrategy
- The strategy for routing Commands to a NodeserviceInstanceFilter
- The Predicate<ServiceInstance>
used to filterconsistentHashChangeListener
- The callback to invoke when there is a change in the ConsistentHashrestTemplate
- The RestTemplate
used to request another member's MessageRoutingInformation
with.messageRoutingInformationEndpoint
- The endpoint where to retrieve the
another nodes message routing
information frompublic void updateMembership(int loadFactor, Predicate<? super CommandMessage<?>> commandFilter)
CommandRouter
updateMembership
in interface CommandRouter
updateMembership
in class SpringCloudCommandRouter
loadFactor
- the new load factor of the member for this endpointcommandFilter
- the new capabilities of the member for this endpoint@GetMapping public MessageRoutingInformation getLocalMessageRoutingInformation()
MessageRoutingInformation
, thus the MessageRoutingInformation of the node this
CommandRouter is a part of. Can either be called directly or through a GET operation on the specified
messageRoutingInformationEndpoint
of this node.MessageRoutingInformation
if the node this CommandRouter implementation is part of.protected Optional<MessageRoutingInformation> getMessageRoutingInformation(org.springframework.cloud.client.ServiceInstance serviceInstance)
SpringCloudCommandRouter
MessageRoutingInformation
of the provided serviceInstance
. If the
MessageRoutingInformation could not be found, an Optional.empty()
will be returned. Otherwise the
MessageRoutingInformation will be contained in the Optional.getMessageRoutingInformation
in class SpringCloudCommandRouter
serviceInstance
- A ServiceInstance
to retrieve MessageRoutingInformation
from.Optional
of type MessageRoutingInformation
, containing the corresponding
MessageRoutingInformation for the given serviceInstance
if it could be retrieved.Copyright © 2010–2018. All rights reserved.