Best practices for server -> front-end notifications

Hi! Just wondering what people here do for front-end notifications. I’ve tried using the Kafka broker but the latency is way too high for a UI. Plus, a web front-end wouldn’t be able to subscribe to a Kafka topic…

Thanks

Curtis

Hi @countfloyd,

I think an alternative here, if you can afford at-most-once delivery for you notifications, is to use lagom’s Pub-Sub.

Consuming Kafka is a task distributed across your service nodes so, unless the websocket is connected to the same node where the kafka partition your data is processed, you wouldn’t see it.

Using pubsub, which uses at-most-once semantics, you could build a websocket that’s connected on the pubsub topic and feed the topic from anywhere. Now, I would discourage you from feeding the topic from anywhere and instead Id’ feed it from the code in the ServiceCall or broker subscriber that generated the event you are interested in (once you know the event was generated*). That’d be similar to the tempreature sample in the docs

Cheers,

Thanks @ignasi35, appreciate the answer. However, I do need at-least-once delivery. I managed to get the latency down on the persistent entity publishing to Kafka. I’m just worried that if we go to a web UI, we won’t be able to connect to a Kafka topic directly.

It’s possible to publish a kafka topic to a websocket. I have done it but I’m experiencing some latency (10s) between the publication of an event and the display of it in the frontend. For that reason, I’m interested to know how you manage to get the latency down.

Hi Dominique, we have moved away from Lagom for now but these are the config options we added to application.conf to deal with event latency:

cassandra-query-journal {
  eventual-consistency-delay = 200ms
  delayed-event-timeout = 30s
}

cassandra-journal {
  pubsub-minimum-interval = 1s
  # experimental
  connection-pool {
    pool-timeout-millis = 180
    max-queue-size = 1028
  }
}

Hi, all what I needed, I’ve copy pasted your config and auto-magically I’ve passed from 10s of latency to something like 0,2 s !! Big big thank you !

However I’m experiencing the “Socket closed. Reason: internal error (1011)” problem as mentioned by someone on this post: https://github.com/lagom/lagom-java-chirper-example/issues/108.
No clear answer in that post so may be someone knows how to solved it ?