@Bean @ConditionalOnMissingBean public RoutingStrategy routingStrategy() { return new AnnotationRoutingStrategy(); }
@Override protected String doResolveRoutingKey(CommandMessage<?> command) { String routingKey; try { routingKey = findIdentifier(command); } catch (InvocationTargetException e) { throw new AxonConfigurationException( "An exception occurred while extracting routing information form a command", e ); } catch (IllegalAccessException e) { throw new AxonConfigurationException( "The current security context does not allow extraction of routing information from the given command.", e ); } return routingKey; }
/** * Initializes the command bus with the given <code>connector</code> and an {@link AnnotationRoutingStrategy}. * * @param connector the connector that connects the different command bus segments */ public DistributedCommandBus(CommandBusConnector connector) { this(connector, new AnnotationRoutingStrategy()); }
@Override protected String doResolveRoutingKey(CommandMessage<?> command) { Object aggregateIdentifier; try { aggregateIdentifier = findIdentifier(command); } catch (InvocationTargetException e) { throw new AxonConfigurationException("An exception occurred while extracting aggregate " + "information form a command", e); } catch (IllegalAccessException e) { throw new AxonConfigurationException("The current security context does not allow extraction of " + "aggregate information from the given command.", e); } return aggregateIdentifier != null ? aggregateIdentifier.toString() : null; }
/** * Initialize the connector using the given {@code localSegment} to handle commands on the local node, and the * given * {@code channel} to connect between nodes. A unique {@code clusterName} should be chose to define which nodes can * connect to each other. The given {@code serializer} is used to serialize messages when they are sent between * nodes. * <p> * Commands are routed based on the {@link org.axonframework.commandhandling.TargetAggregateIdentifier} * Uses a cached thread pool {@link ExecutorService} containing the {@link AxonThreadFactory} to create threads * which deal with the message receiving process. * * @param localSegment The CommandBus implementation that handles the local Commands * @param channel The JGroups Channel used to communicate between nodes * @param clusterName The name of the Cluster * @param serializer The serializer to serialize Command Messages with */ public JGroupsConnector(CommandBus localSegment, JChannel channel, String clusterName, Serializer serializer) { this(localSegment, channel, clusterName, serializer, new AnnotationRoutingStrategy()); }
@Override protected String doResolveRoutingKey(CommandMessage<?> command) { String aggregateIdentifier; try { aggregateIdentifier = findIdentifier(command); } catch (InvocationTargetException e) { throw new AxonConfigurationException("An exception occurred while extracting aggregate " + "information form a command", e); } catch (IllegalAccessException e) { throw new AxonConfigurationException("The current security context does not allow extraction of " + "aggregate information from the given command.", e); } return aggregateIdentifier; }
@Bean @ConditionalOnMissingBean public RoutingStrategy routingStrategy() { return new AnnotationRoutingStrategy(UnresolvedRoutingKeyPolicy.RANDOM_KEY); } }
@Override protected String doResolveRoutingKey(CommandMessage<?> command) { String routingKey; try { routingKey = findIdentifier(command); } catch (InvocationTargetException e) { throw new AxonConfigurationException( "An exception occurred while extracting routing information form a command", e ); } catch (IllegalAccessException e) { throw new AxonConfigurationException( "The current security context does not allow extraction of routing information from the given command.", e ); } return routingKey; }
@Bean @ConditionalOnMissingBean public RoutingStrategy routingStrategy() { return new AnnotationRoutingStrategy(); }