Event created in one service is not picked by another service where saga exist

ProductReservedEvent created in ProductService is not picked by OrderSaga class lies within OrderService application.

Can some one please help me.

I see this question has been lying around for some time. If you still need help, you will need to provide more information, e. g.:

  • Are there other events traveling from ProductService to OrderService? If so, does it work for them?
  • Are there other events sent by ProductService to services other than OrderService? If so, does it work for them?
  • Does OrderService receive events from services other than ProductService? If so, does it work for them?
  • What does your infrastructure setup look like? Are you using Axon Server or something different?
  • Can you show the code used to publish the event, and the code of the event handler?

Thank you very much Sebastian. Please kindly review the details.
Note: The application was working fine with axon saga orchestrator pattern and sometimes it doesnt worked in expected way when there is no change in code despite the ProductService exhibit ProductReservedEvent.

Example: Fine Run → Monday; Unexpected Run → Tuesday. Only the days are the variation. As of now it doesnt working working fine in same way after multiple restarts.

  • Are there other events traveling from ProductService to OrderService? If so, does it work for them?
    Answer: No other events are passed from ProductService to OrderService currently.

  • Are there other events sent by ProductService to services other than OrderService? If so, does it work for them?
    Answer: Yes the other events like UserDetailFetchedEvent are passed from UserService to OrderService only when ProductReservedEvent is worked correctly.

  • Does OrderService receive events from services other than ProductService? If so, does it work for them?
    Answer: The UserService can send UserDetailFetchedEvent to OrderService only after ProductService.

  • What does your infrastructure setup look like? Are you using Axon Server or something different?
    Answer: Axon server is running in docker container. And it is connected to native application in eclipse IDE

  • Can you show the code used to publish the event, and the code of the event handler?
    Answer: Sure.

ProductService
Aggregate :

EventHandler:

@ProcessingGroup(“product-group”)

OrderService
@ProcessingGroup(“order-group”)

OrderCreatedEvent - Works fine since it is exhibited by OrderService itself.

Problem - ProductReservedEvent


It is not called as it was.

import com.saturn.estore.ProductCoreAPI.Event.ProductReservedEvent; is used to import this event at both services.

Could you please kindly help. Please let me know if more information are needed.

OK, so it sometimes works, and sometimes it doesn’t. This rules out basic configuration problems.

From your setup description I infer that this is not a production problem but something you are encountering during local testing, right? If so, I have a few follow-up questions:

  • Are you using the same test data (in particular: the same order ID) every time?
  • Do you conduct your tests in the same order every time?
  • Do you begin each test with a reproducible state (including the event store, the product repository, and any other relevant state)?
  • How do you start the Axon Server? Do you create a new container for each test, or do you reuse the same container? If reusing, how do you reset its state?
  • Can you provide sample logs from a working and a non-working run?

Note: The ProductReservedEvent created in ProductService is not picked by OrderSaga class within OrderService application nowadays, since the issue is raised. The inconsistent problem becomes consistent now.

Yes, The problem is occurring in local testing.

  • Are you using the same test data (in particular: the same order ID) every time?
    Answer: No, I try with new orderId’s as well.

  • Do you conduct your tests in the same order every time?
    Answer: No, multiple orders are involved.

  • Do you begin each test with a reproducible state (including the event store, the product repository, and any other relevant state)?
    Answer: We create new products in productservice every time the application is started up. The same productId is used for OrderService at same time. Hence the event store, product repository will have a fresh records of products when the request is sent to OrderService.
    Axon Server Start up: Once per day
    Applications start up: Multiple times per day as code is updated.

  • How do you start the Axon Server? Do you create a new container for each test, or do you reuse the same container? If reusing, how do you reset its state?
    Answer: Axon Server is started through docker-compose in CLI. We use ‘axoniq/axonserver’ image everytime

  • Can you provide sample logs from a working and a non-working run?
    Answer: Unfortunately i am unable to grab the logs of working time since the issue becomes consistent nowadays.

Working Run: When OrderSaga worked successfully it will fire commands like ReserveProductCommand, FetchUserDetailCommand and consume events like ProductReservedEvent, UserDetailFetchedEvent without any issue. Fires FetchUserDetailCommand too.

Non Working Run:


I can view the events such as ‘ProductCreatedEvent’, ‘OrderCreatedEvent’ and ‘ProductReservedEvent’ are listed along in AXON dashboard. Yet the OrderSaga lies in OrderService is unable to pick ‘ProductReservedEvent’

Well, if the problem is occurring consistently, it may be related to the setup/configuration after all. Here are a few ideas you could try to narrow it down:

  • Implement a regular (non-saga) event handler for ProductReservedEvent in the ProductService (but outside the product aggregate), and check whether it is invoked. If this doesn’t work, something must be very wrong.
  • If it does work, move the event handler to the OrderService, and check whether it is still invoked. If it does, the problem may be related to the matching between event and saga instance (via the associationProperty). If it doesn’t, it may be a communication problem between the services.
  • Generate a ProductReservedEvent by some other means (e.g., from within the OrderService) and check whether it is handled by the saga then.