@Test public void testUpdateMembershipsOnHeartbeatEventFiltersInstancesWithoutCommandRouterSpecificMetadata() { int expectedMemberSetSize = 1; String expectedServiceInstanceId = "nonCommandRouterServiceInstance"; serviceInstanceMetadata.put(LOAD_FACTOR_KEY, Integer.toString(LOAD_FACTOR)); serviceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER_KEY, serializedCommandFilterData); serviceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER_CLASS_NAME_KEY, serializedCommandFilterClassName); ServiceInstance nonCommandRouterServiceInstance = mock(ServiceInstance.class); when(nonCommandRouterServiceInstance.getServiceId()).thenReturn(expectedServiceInstanceId); when(discoveryClient.getServices()) .thenReturn(ImmutableList.of(SERVICE_INSTANCE_ID, expectedServiceInstanceId)); when(discoveryClient.getInstances(SERVICE_INSTANCE_ID)) .thenReturn(ImmutableList.of(localServiceInstance, nonCommandRouterServiceInstance)); testSubject.updateMemberships(mock(HeartbeatEvent.class)); AtomicReference<ConsistentHash> resultAtomicConsistentHash = getFieldValue(atomicConsistentHashField, testSubject); Set<Member> resultMemberSet = resultAtomicConsistentHash.get().getMembers(); assertEquals(expectedMemberSetSize, resultMemberSet.size()); verify(discoveryClient).getServices(); verify(discoveryClient).getInstances(SERVICE_INSTANCE_ID); verify(discoveryClient).getInstances(expectedServiceInstanceId); }
@EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); }
SpringCloudCommandRouter implements CommandRouter { @EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); } }
SpringCloudCommandRouter implements CommandRouter { @EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); } protected  SpringCloudCommandRouter(Builder builder); }
SpringCloudCommandRouter implements CommandRouter { @EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); } protected  SpringCloudCommandRouter(Builder builder); static Builder builder(); static boolean serviceInstanceMetadataContainsMessageRoutingInformation(ServiceInstance serviceInstance); @Override Optional<Member> findDestination(CommandMessage<?> commandMessage); @Override void updateMembership(int loadFactor, CommandMessageFilter commandFilter); @EventListener @SuppressWarnings("UnusedParameters") void resetLocalMembership(InstanceRegisteredEvent event); @EventListener @SuppressWarnings("UnusedParameters") void updateMemberships(HeartbeatEvent event); }
SpringCloudCommandRouter implements CommandRouter { @EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); } protected  SpringCloudCommandRouter(Builder builder); static Builder builder(); static boolean serviceInstanceMetadataContainsMessageRoutingInformation(ServiceInstance serviceInstance); @Override Optional<Member> findDestination(CommandMessage<?> commandMessage); @Override void updateMembership(int loadFactor, CommandMessageFilter commandFilter); @EventListener @SuppressWarnings("UnusedParameters") void resetLocalMembership(InstanceRegisteredEvent event); @EventListener @SuppressWarnings("UnusedParameters") void updateMemberships(HeartbeatEvent event);  }