Package org.axonframework.commandhandling

Examples of org.axonframework.commandhandling.CommandDispatchInterceptor


    @SuppressWarnings("unchecked")
    @Test
    public void testCallbackInvokedBeforeUnitOfWorkCleanup() throws Throwable {
        CommandHandlerInterceptor mockHandlerInterceptor = mock(CommandHandlerInterceptor.class);
        CommandDispatchInterceptor mockDispatchInterceptor = mock(CommandDispatchInterceptor.class);
        when(mockDispatchInterceptor.handle(isA(CommandMessage.class))).thenAnswer(new Parameter(0));
        ExecutorService customExecutor = Executors.newCachedThreadPool();
        testSubject = new DisruptorCommandBus(
                inMemoryEventStore, eventBus,
                new DisruptorConfiguration().setInvokerInterceptors(Arrays.asList(mockHandlerInterceptor))
                                            .setDispatchInterceptors(Arrays.asList(mockDispatchInterceptor))
View Full Code Here


        });

        // say we have a dispatch interceptor that expects to get the user's session from a ThreadLocal...
        // yes, this should be configured on the gateway instead of the command bus, but still...
        final Thread testThread = Thread.currentThread();
        commandBus.setDispatchInterceptors(Collections.singletonList(new CommandDispatchInterceptor() {
      @Override
      public CommandMessage<?> handle(CommandMessage<?> commandMessage) {
        if (Thread.currentThread() == testThread) {
          return commandMessage; // ok
        } else {
View Full Code Here

   * is not preserved.
   */
    @Test(timeout=10000)
    public void testCommandGatewayDispatchInterceptorMetaDataIsPreservedOnRetry() {
      final Thread testThread = Thread.currentThread();
    commandGateway = new DefaultCommandGateway(commandBus, retryScheduler, new CommandDispatchInterceptor() {
      @Override
      public CommandMessage<?> handle(CommandMessage<?> commandMessage) {
        if (Thread.currentThread() == testThread) {
          return commandMessage.andMetaData(Collections.singletonMap("gatewayMetaData", "myUserSession"));
        } else {
View Full Code Here

                return commandMessage.getMetaData();
              }
            }
        });

        commandBus.setDispatchInterceptors(Collections.singletonList(new CommandDispatchInterceptor() {
      @Override
      public CommandMessage<?> handle(CommandMessage<?> commandMessage) {
        if (Thread.currentThread() == testThread) {
          return commandMessage.andMetaData(Collections.singletonMap("commandBusMetaData", "myUserSession"));
        } else {
View Full Code Here

TOP

Related Classes of org.axonframework.commandhandling.CommandDispatchInterceptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.