Kafka as event source when using Axon - spring-boot

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.

Related

Axon Event Handler not executing on a different microservice

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.

Axon Event Handler not working on a different microservice

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

Using Kafka without RabbitMQ

I am testing MassTransit with Kafka without RabbitMQ
I need a IBusControl, can i use bus.UsingInMemory()?
Is it safe to use for Kafka ITopicProducers?
Does features like scheduling/sagas will work with Kafka or with InMemory bus?
You can use an in-memory bus with Kafka, but realize that the in-memory bus is not durable. The only reason you would want to use it is because you want to consume/produce Kafka messages without using an accompanying broker.
Sagas work with Kafka just fine, since sagas are a type of consumer.
Scheduling is not supported with Kafka, since it isn't a broker. Using scheduling with in-memory is not recommended outside of unit tests.

How to update data in real-time

I have a small stock-market application with Spring boot and if any product updated I want to serve an updated product to the clients in realtime
does it make sense to use message queues like RabbitMQ and Sse(Server Sent Events) for this, or is there a more sensible solution?
Solution
Publish your updated data to some channel
Your clients should subscribe to that channel to get updated feed in real-time.
Tools
Use in-house setup for RabbitMQ, ActiveMQ, Kafka or other open-source tools and implement WebSocket (For Front end applications)
Use commercial service like Google Cloud PubSub
Readymade and fully packaged solution with supported SDK for backend and frontend, https://www.pubnub.com/.
For this you can use either of
Spring Integration
Web Sockets
JMS
Spring Integration is an implementation of Enterprise Integration Patterns and is ideal for asynchronous processing data at realtime.
However, looking at your scope, it is only about publisher-subscriber pattern. Hence can be solved with JMS.
With JMS the subscribers/consumers can register/de-register dynamically. Also it provides ways to have fall-backs and tracking.

Using AggregateApplicationBuilder with a local binder

I'm trying to aggregate different Sink and Source spring boot applications using the AggregateApplicationBuilder as described here: http://docs.spring.io/spring-cloud-stream/docs/current-SNAPSHOT/reference/htmlsingle/#_aggregation
Since I expect in process communication, I don't want to setup kafka or rabbitmq binder. How to configure a local one? I found that a spring-cloud-stream-binder-local exists but it's in M2 since a long time and is not embedded with a release train.
How I can use the AggregateApplicationBuilder with no external system dependency?
Thanks
With AggregateApplicationBuilder you don't have to configure the binder for the in-process communication of the directly bound channels within the aggregated application. The binder is required only if you need the aggregate application itself consumes messages from broker or produces messages to broker. If the aggregated application itself is self-contained, then there is no need for the binder at all.

Resources