How to create Stateful Functions using RSocket RPC service?


#1

In my project I am currently using CORBA, and I would like to replace it by RSocket RPC (as CORBA is deprecated in the latest java version).
In my current design after request a channel, we have the state of the functions.
Is it possible to share state between functions during a “requestChannel” in the RSocket RPC?


#2

Hi,

Just so I understand your question better - Would you like to have multiple request channels stream in data, but the results streamed out are the same? Something like that?

Thanks,
Robert


#3

Hi Robert,

Yes, I would like to have multiple request channels. Inside each of them, I need have for example, a counter of "how many requests were received by the server during the request channel.

Because, in my case when I start the request channel, I start a transaction and when before the end of the request channel, I can commit or rollback the transaction.

Regards,

Danilo


#4

Hi Danilo,

Okay - makes sense - I can come up with an example how to do this.

Thanks,
Robert


#5

Thanks a lot Robert!


#6

Hi Danilo,

Here’s an example application I created. It streams random integers from n different clients. The results are added up and streamed back to all the default clients. The state is tied to a single Publisher that is shared across multiple different requestChannels:
Here’s the code on GitHub:

To run the example start a broker:

docker run -p 8001:8001 -p 7001:7001 -p 9000:9000 -e BROKER_SERVER_OPTS="'-Dnetifi.authentication.0.accessKey=9007199254740991'  \
'-Dnetifi.broker.console.enabled=true' \
'-Dnetifi.authentication.0.accessToken=kTBDVtfRBO4tHOnZzSyY5ym2kfY=' \
'-Dnetifi.broker.admin.accessKey=9007199254740991' \
'-Dnetifi.broker.admin.accessToken=kTBDVtfRBO4tHOnZzSyY5ym2kfY='" netifi/proteus:1.5.3

And then start a server:

./gradlew :service:run

And then you can start one or more clients:

./gradlew :client:run

Let me know if this helps.

Thanks,
Robert


#7

Hi Robert,

You have solved my problem, really thank you!!!

Regards,

Danilo