0
votes

I had implement CQRS+ES application using axon and spring-boot. I use separate query model and command model application. I use rabbitmq to publish event from command mode. It works correct. But tracking Processor implementation is not work in my application.

This is my query model

@SpringBootApplication
public class SeatQueryPart1Application {
    public static void main(String[] args) {
        SpringApplication.run(SeatQueryPart1Application.class, args);
    }

    @Bean
    public SpringAMQPMessageSource statisticsQueue(Serializer serializer) {
        return new SpringAMQPMessageSource(new DefaultAMQPMessageConverter(serializer)) {
            @RabbitListener(exclusive = false, bindings = @QueueBinding(value = @Queue, exchange = @Exchange(value = "ExchangeTypesTests.FanoutExchange", type = ExchangeTypes.FANOUT), key = "orderRoutingKey"))
            @Override
            public void onMessage(Message arg0, Channel arg1) throws Exception {
                super.onMessage(arg0, arg1);
            }
        };
    }

    @Autowired
    public void conf(EventHandlingConfiguration configuration) {
        configuration.registerTrackingProcessor("statistics");
    }

}

this is a event handler class

@ProcessingGroup("statistics")
@Component
public class EventLoggingHandler {


    private SeatReservationRepository seatReservationRepo;
    public EventLoggingHandler(final SeatReservationRepository e) {
        this.seatReservationRepo = e;
    }

    @EventHandler
    protected void on(SeatResurvationCreateEvent event) {
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        Seat seat=new Seat(event.getId(), event.getSeatId(), event.getDate(),timestamp ,true);
        seatReservationRepo.save(seat);
    }

}

this is yml configuration

axon:
  eventhandling:
    processors:
      statistics.source: statisticsQueue

How can i do it correct. (Can anyone suggest tutorial or code sample)

1

1 Answers

2
votes

The SpringAMQPMessageSource is a SubscribableMessageSource. This means you cannot use a tracking event processor to process messages. It is only compatible with a Subscribable Event Processor.

Removing configuration.registerTrackingProcessor("statistics"); and leaving it to the default (subscribing) should do the trick.