How to create a Session with Transaction using RSocket-RPC?

#1

I would like to know if it is possible to model the following use case using RSocket-RPC.
We currently have three CORBA objects that are used as demonstrated in the diagram:

  • A LoginObject (to which a reference is retrieved via NamingService). Clients can call a login() method to obtain a session
  • The Session object has various methods for query details about the current serivce context and most importatly to obtain a Transaction object
  • The Transaction object can be used to execute various commands via a generic method that take a commandName and a list of key-value pairs as parameters.

After the client executed n commands he can commit or rollback the transaction (also via methods on the Transaction object).
I checked your last sample https://github.com/netifi/proteus-stateful-channel , but still struggle to see how I could mirror this case with RSocket-RPC.

sequenceDiagram

#2

Hi,

I added an example using a channel. Basically what this does is tie the Reactive Streams life cycle to a “transaction” - I’m just using an integer in this simple example, but you could replace this with something like a database query if you wanted. OnSubscribe you could start the transaction, onComplete you can commit, and onError or cancel you could roll the transaction back.

It’s in the same place as last time except I added a TransactedChannelService service example. Here’s the service implementation:

Let me know if that helps.

Thanks,
Robert

#3

Hi,

First of all, thanks a lot for the answer and the example. However, that’s not quite what we need. Because if I understand correctly in your example the server has a shared state, shared as in shared among all request*. What we are looking for is really support for individual client sessions, i.e. a state per client connection / RSocket.
Would be possible to have a state inside the channel (on each connection)?
Also I would like to know if it is possible to create service that returns another service? I.E. You have different “remote objects” that you want to operate on and one can return the other.

Regards,
Danilo

#4

Hi-

Yes - because is connection oriented you can tie session data to the RSocket connection life cycle. I can create an example to show that would work.

Thanks,
Robert

#5

Hi,

It would be amazing Robert :slight_smile:

Regards,
Danilo

#6

Hi Robert I will like to see your example using spring boot. I have an api that will need to connect to microservices using rsocket and I will like to attach the web session to the rsocket session.
Thanks a lot

#7

Hi,

I will get you a pure RSocket version of this - in the meantime- I created a version using the Netifi Broker to create a stateful sessions tied a connections life-cycle - here’s a link to the post about this:

Thanks,
Robert

#8

Hi @robertroeser it looks really awesome. I will implement and test it with netifi broker tomorrow and let you know how everything works because I have some complex usecases and if that work that will be amazing. It will be good to have it in pure Rsocket too. Good job !!!

#9

Thanks a lot Robert.

I have tried to run the project, but the dependency “com.netifi:netifi-spring-boot-starter:1.6.3” is not available in the maven central. Can you upload it?

Thanks again,
Danilo

#10

Hi-

Unfortunately, the changes are in a branch that you’d need to build at the moment and install locally. Here is a link to the branch:

I will let you know when the changes are available in a repository.

Thanks,
Robert