4

I am new to Axon and have written a sample code wherein we have an inventory service which is used for adding new inventory, updating inventory and we want to send events to Product Service for any update. Product service should act as a read replica to Inventory Service.

Inventory Service code:

So I created Inventory Aggregate which various command handlers. enter image description here

Inventory Controller responsible for sending commands

enter image description here

In product Service, I added event handlers

enter image description here

Problem i am facing currently is, when i add a new inventory, it gets reflected in product service db but when i try to do update, it gives me an exception: Command 'com.example.demo.command.UpdateInventoryCommand' resulted in org.axonframework.commandhandling.CommandExecutionException(The aggregate was not found in the event store) org.axonframework.axonserver.connector.command.AxonServerRemoteCommandHandlingException: An exception was thrown by the remote message handling component: The aggregate was not found in the event store

When i try to make one more insert into inventory, Inventory Service throws Exception saying:

: "OUT_OF_RANGE: [AXONIQ-2000] Invalid sequence number 0 for aggregate 0, expected 1", An exception was thrown by the remote message handling component: OUT_OF_RANGE: [AXONIQ-2000] Invalid sequence number 0 for aggregate 0, expected 1 Caused by OUT_OF_RANGE: [AXONIQ-2000] Invalid sequence number 0 for aggregate 0, expected 1

Any help would be really appreciated. Complete code available at :

https://github.com/jahanvibansal/Axon-ProductService

https://github.com/jahanvibansal/Axon-InventoryOrderService

Payal Bansal
  • 725
  • 5
  • 17
  • 2
    I do not think this a code thing @PayalBansal, but more something with how you are running and have configured Axon Server. Please update your ticket with specifics how your project is started, how Axon Server is started and if you're configuring anything specifics for the event storage side of things. – Steven Feb 03 '20 at 09:44
  • Yes, I started my axon server before that. But I had not done any configuration for event storage side of things. I realized we need to specify axon.eventhandling.processors.name.mode=tracking property in spring boot application which got it working. I understand there are 2 modes tracking and publish subscribe. I would read more about it. – Payal Bansal Feb 04 '20 at 16:00
  • Aaaah missed a little piece of configuration. Great that you've solved it yourself @PayalBansal! Make sure to mark your response as the answer for future answer-seekers :-) – Steven Feb 05 '20 at 08:45

1 Answers1

3

. I realized we need to specify axon.eventhandling.processors.name.mode=tracking property in spring boot application which got it working. I understand there are 2 modes tracking and publish subscribe. I would read more about it.

Payal Bansal
  • 725
  • 5
  • 17