question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ES and CQRS not working correctly with Mysql Lagom application

See original GitHub issue

Lagom Version : 1.4.7 API Scala Version : 2.12.6 Operating System : Ubuntu 16.04 JDK : java version “1.8.0_201” MySQL: Ver 14.14 Distrib 5.7.27

I am facing the same issue as mentioned by @PallaviSingh1992 in this issue. So, I tried adding a readside in Processor and using a builder setEventHandler() to handle multiple events.

Processor

override def buildHandler(): ReadSideProcessor.ReadSideHandler[EsEvent] = readSide .builder[EsEvent]("EventOffset") .setGlobalPrepare(globalPrepare) .setEventHandler(handleEventsChanged) .build()

val handleEventsChanged: (Connection, EventStreamElement[EsEvent]) => Unit = { (conn, evt) => evt.event match { case addEvent: UserAdded => processUserAdded(conn, addEvent) case userPasswordUpdatedEvent: UserPasswordUpdated => processSetPassword(userPasswordUpdatedEvent) case userStatusUpdatedEvent: UserStatusUpdated => processUserStatusUpdated(userStatusUpdatedEvent) } }

Expected Behavior

Whatever event is coming to handleEventsChanged(), it should match and execute the particular case.

Actual Behavior

For one event it is working perfectly but when we are using multiple events using pattern matching, it will execute the last event and skips other events above it.

@renatocaval @TimMoore Do you have any suggestion about what we are doing wrong here?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
aldenmlcommented, Aug 22, 2019

Hi @ignasi35, I want to make clear that my comment was in a friendly note 😃

What I meant is that in Java it is not possible a pattern match like in Scala (yes, you can always if-instanceof-else). I’m not familiar with the inner working on the Java side of Lagom and for me, what’s happening in the Scala side is expected behavior since it’s how it’s implemented.

Now, I see your point framework design wise, I just happen to think a little bit different.

1reaction
ignasi35commented, Aug 22, 2019

I guess the answer is we chose scala-to-java similarity (since the Java API was developed first) over introducing a difference for scala users where they could only register a single handler implemented with a pattern match.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ES and CQRS not working correctly with Mysql post application ...
We have a lagom Microservice that has ES and CQRS implemented along with MYSQL database. Whenever the database is empty and we are...
Read more >
A CRUD application: Lagom ES & CQRS with MySQL
In this blog, we will look at how we have implemented a CRUD application using Relational Database rather than using a NoSQL database...
Read more >
lagom/lagom - Gitter
As per my understanding this is NOT a ES/CQRS use case . So , I am planning to use CassandraSession for interacting with...
Read more >
A CRUD application: Lagom ES & CQRS with MySQL - Medium
A CRUD application: Lagom ES & CQRS with MySQL ... An event processor we usually create for Cassandra didn't work for me.
Read more >
CQRS & Event Sourcing Cognitive class Exam Answers
Note: Make sure you select all of the correct options—there may be more than one! Question 3 : Which of the following problems...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found