generator-jhipster-kafka
generator-jhipster-kafka copied to clipboard
Send events through Kafka when CRUDing on entities
Overview of the feature request
When CRUDing on entities, it should send events in topics for given entities.
Maybe propose this by a prompt option?
This could be linked with #4 where consumer/producer would be created by hook when using jhipster entity Foo
.
An event type could be send as a key when producing a message for instance:
byte[] key = "FOO_ENTITY_CREATION".getBytes();
byte[] value = "value".getBytes();
ProducerRecord<byte[],byte[]> record = new ProducerRecord<byte[],byte[]>("my-topic", key, value)
producer.send(record);
An enum could be generated with the different operations values (create, update, delete).
Motivation for or Use Case
Allowing the application to be event-driven.
Use case:
- Create a first JHipster application JH1 with a
Foo
entity, create aFooProducer
. - Create a first JHipster application JH2 with a
Foo
entity, create aFooConsumer
. - Create a
Foo
in the application. - A creation event is send to the
queuing.application_name.foo
topic throughFooProducer
in JH1. - The creation event is read in the
queuing.application_name.foo
topic byFooConsumer
in JH2.
:warning: On JH2 the entity could not be deserialized correctly because the entity doesn't have the same package on JH1 and JH2. Make a test with current deserialization mode or see #63 for deserialization alternatives (to be priorized ?).
Add support for akhq to be launched on multiple apps.
Related issues or PR
#4
- [x] Checking this box is mandatory (this is just to show you read everything)
Is it in accordance with your use cases @pascalgrimaud?
yes, it's nice it could be split into several part, like create, update and delete, and for each case, think about how to implement it.
The hardest would be deleted, as I think we should forbid this, and implement a logical delete, rather than a physical one. It should be discussed
I think we should follow what it's done on the main generator for entities deletion. In my opinion, we just have to manage an event on CRUD operations, not operations themselves. What do you think?