I was implementing event-driven CQRS concept using Axon framework. I created two separate microservices and their own two write and read databases.
I am publishing an event in ms-1 and now I want to handle that event in ms-2, so that I can persist it in my read DB. But the #EventHandler is not working in my ms-2. The events are published on the AxonServer, I can see the updates there.
And yes, I do have #Component on the EventHandler class in ms-2. Also, I am running AxonServer on docker.
The #EventHandler works fine when it is in the same microservice.
My axon-framework dependency is 4.5.8 and google guava's is 30.1.1-jre
Related
We're using a hexagonal architecture in one of our microservice. Spring Boot is the framework implementing the service.
For a use case, we need to update a database table (relational) and send a message to a Kafka topic. Quite usual. We don't want to use any CDC or Outbox Pattern, but we want to rely on the transactional manager of Spring.
However, we need some clarification about how to implement this scenario. We don't want to have any dependency on the framework in the application layer (service/use case). How can we implement transactionality? Should we use the #Transactional annotation on the controller? Should we have a single output port, for example, saveAndPublish (I don't like this solution), and put the transaction management in the implementing adapter?
I know that every use case should be transactional by design.
I'm studying Axon framework to try to use it in one of my microservices. I use Spring boot as my microservice and I want to use Axon framewrok for DDD and event sourcing. The thing is we already use Kafka in production and I'm not sure I can add another service (Axon serve) since it might consume resources I don't have (does it consume a lot of resources by the way?)
So I was thinking to use Kafka as event source and event routing with Axon.
Is it possible?
You can use Kafka as event bus using the Kafka extension for Axon. You can't use Kafka as event store however. So you still need Axon Server or a relational database for the event store to use Axon Framework.
You could also combine those, e.g. have some events via Kafka, and some via Axon Server.
I'm using CQRS with axon Framework in a project,and I'm using Kafka like evnt bus and MongoDB like event store
I have two Microservices, One for the Command Side and the Other for Query Side.
In the Query side I'm try using MySQL database for storing aggregates events, but the eventHandler does not work and I don Know why.
Command Microservice
Query Microservice
Could you share the configuration of the event handler? Or maybe some kind of error you are getting? Could be a lot of things. Might be because you use MySQL and Spring Boot, it actually trying to use MySQL as event store, and not MongoDB.
I'm relatively new to the Axon Framework and just evaluating if the framework is suitable for a project of me. Versioning of events is described in this post. But in the example the EventStore is changed to Jpa. Is it possible to upcast events with Axon Server as event store? Or did I misunderstand something?
The Upcaster logic provided by Axon Framework is in now way biased to the type of EventStore backing your application. It is thus perfectly doable to provide an UpcasterChain to the AxonServerEventStore, containing the EventUpcaster implementation you have written.
Upcaster Registration Update
Nicolas asked the following as a follow-up on my response:
But the upcaster is only applied for the service that contains it.
So is it possible to register an upcaster globally or do I have to implement it in every service connected with the Axon Server?
Axon Server will not delegate registered Upcaster instances throughout the connected Axon Server Clients (aka, the Axon Framework implementations).
It doesn't because you could have a heterogeneous deployment of services, one with old event versions and one with the most recent version including such an Upcaster.
Think about it from a Blue-Green Deployment strategy, or a Rolling-Upgrade approach; you wouldn't want Axon Server to push the upcasters to the clients directly, as the client should be in charge of the exact version they're interested in.
Having said this, you would thus have to share the upcasters together with your messages, as part of your API so to say. This would be a requirement for an Axon application regardless of whether you'd use Axon Server. Having said that, this is the case for Axon Server for at least (the upcoming) version 4.3. I do not know (yet) whether such a feature will be added in the future.
I'm looking for the azure alternative for the Data flow model of Data Source-processor-sink.
I want the three entities to be separate microservices. I want to use messaging as a link between these three.
Basically, Source app takes the data from another service and sends it to processor while processor app acts on it and sends relevant notification/alert to sink.
I'm aware I can use rabbitmq for the messaging but I need to know which one will be better in azure - service bus topics or eventhub? and how can I use them?
At the moment, there isn't a Spring Cloud Stream binder implementation for Azure Event Hubs.
Unless we have this, the out-of-the-box or the custom apps cannot be built as a messaging-microservice app, where Spring Cloud Stream provides the programming model and Spring Cloud Data Flow lets you orchestrate the individual microserivces in to a data pipeline (i.e., source-processor-sink) via the DSL/Drag-and-Drop GUI.
Microsoft was exploring the binder implementation in the past; possibly it would end up in Azure Spring Boot project. Feel free to drop an issue on their backlog.