rsocket / rsocket-java

Java implementation of RSocket
http://rsocket.io
Apache License 2.0
2.36k stars 354 forks source link

Question: workarounds for missing cold resumption #664

Closed dpfg closed 5 years ago

dpfg commented 5 years ago

Hello everyone,

I've being evaluating RSocket for my next project where many clients will be connected to a couple of servers. RSocket seems quite nice: simple, but functional. In my case servers can go down periodically so clients should automatically reconnect when server is up. Basically, I don't care about lost messages. What is critical is to resume transmission. If I understood correctly out of the box rsocket-java doesn't support this type of resumption.

The question is there any workaround that can be implemented on application level to gracefully handle server restarts? I'm not quite proficient in reactor and would appreciate any directions.

mostroverkhov commented 5 years ago

Hi, cold resumption is not available yet, and should be implemented in library - there is no way to workaround this. Cold resumption is trickier than warm one, given streams themselves can be cold (e.g. transferring large file as messages stream) or warm (e.g. notifications). Here, in addition to resuming with already sent items of stream, we need to restore Responder with proper state. same applies to Requester streams: they have to be correlated with ones before restart, and e.g. send cancellation signal if not subscribed after resumption.

robertroeser commented 5 years ago

@dpfg hi - are you asking if there is a way to automatically reconnect when your application restarts? If you are here is a link to some code that does that: https://github.com/netifi/netifi-java/blob/develop/netifi-broker-client/src/main/java/com/netifi/broker/rsocket/WeightedReconnectingRSocket.java#L217

dpfg commented 5 years ago

@robertroeser this is exactly what I was looking for. Thank you!