#How to make a persistent Spring WebSocket?

16 messages · Page 1 of 1 (latest)

wild saffron
#

Hi, I have a WebSocket setup up and it correctly receives and sends messages.

When I open a second browser that hooks into socket, it does not load any messages from before the browser was loaded.

Browser 1:

TestUser: OMG!
TestUser2: Hypeeeee

Browser 2 (Which was launched after those messages were sent):

// Nothing

How could I make it so that Browser 2 loads all previous messages upon launch?
Thanks, AwesomeDude091

regal glacierBOT
#

This post has been reserved for your question.

Hey @wild saffron! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

wild saffron
#

hmmmmmmnmmmm

#

In the mean time I have found the @SubscribeMapping

#

Would a stored content message assist on that front?

wild saffron
#

no that won't work

wild saffron
#

Either works

#

all that matters is that its a separate session

opaque scaffold
#

configure your Spring application by looking docs

dire tree
#

This is actually not a trivial thing to solve because you've inadvertently created a distributed event store: https://en.m.wikipedia.org/wiki/Event_store

An event store is a type of database optimized for storage of events.
Conceptually, in an event store, only the events of a dossier or policy are stored. The idea behind it is that the dossier or policy can be derived from these events. The events (and their corresponding data) are the only "real" facts that should be stored in the database. The...

#

You want new consumers to see all past messages which means you now need to keep track of what they have and haven't seen. This is sometimes called a token or an offset

#

Additionally, if you have an existing consumer you don't want them to see all messages but only messages that arrived since they stopped reading