I am trying to write a small microservice using lagom framework with read side implemented to support mysql. https://github.com/codingkapoor/lagom-scala-slick
The objective of this service is to expose apis to create, update, and read employees.
Upon execution, however, the project is not creating kafka topic and publishing messages to it. I tried debugging, reading docs and referring couple of other similar projects but no luck so far.
Lagom documentations and similar projects are the only sources that's available to find any help for such fairly newer tech. I really need help to debug and understand this issue. Let me know if this the right platform to ask for such a help.
Steps I take to create an employee and possibly see kafka topic created are as follows:
#1. sbt runAll
#2. curl -X POST \
http://localhost:9000/api/employees \
-H 'Content-Type: application/json' \
-d '{
"id": "128",
"name": "Shivam",
"gender": "M",
"doj": "2017-01-16",
"pfn": "PFKN110"
}'
#3. /opt/kafka_2.12-2.3.0/bin/kafka-topics.sh --list --zookeeper localhost:2181
#4. /opt/kafka_2.12-2.3.0/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic employee --from-beginning
After some struggle I was able to resolve the issue. So basically there were two issues:
First issue was because of the order in which the traits ReadSideJdbcPersistenceComponents
and WriteSideCassandraPersistenceComponents
are extended to create EmployeeApplication
. Due to a bug in Lagom the ordering in which you mix in those two traits is relevant and only if you mix in ReadSideJdbcPersistenceComponents before WriteSideCassandraPersistenceComponents you will be able to use this combination.
Please see this README from lagom-samples.
Also, I was not implementing polymorphic event stream properly as explained in the lagom documentation here.
I have now come up with a working github project which you can refer: lagom-scala-slick.