Hello, Can anyone show me an example (code) of a Remote Call Back in RMI ? Is their standard code for this process? - rmi

Is it just for some revisions I'm doing on RMI? Been just researching and finding it difficult to find an example of "a remote call back".
OK, I shall add to this, is the following a good way to describe an example of a callback?
"You have a Server and a Client. Server calls method from Client,
Client has already looked up Server and passed reference to itself."
How's that? Is it better?
Thanks,
Caroline

is this a good way to describe an example of a callback ?
"You have a Server and a Client. Server calls method from Client, Client has already looked up Server and passed reference".
Yes. You've omitted that the client object must be an exported remote object, typically by extending UnicastRemoteObject, and must implement a remote interface. Just like the server.

Related

Sockets can replace HTTP requests? (sockets vs http)

Creating a user, adding some record to collection in the DB, updating some stuff, etc..
All of these we regularly do with HTTP requests against REST api.
Think about making Event bus as server instead of REST api.
In that method, create user will be an event name: "CreateUser" instead of REST api endpoint: POST /users.
In reflect to any action done in the event bus, it will re-emit a following event telling to any body needed to know about, that the event was done.
If for example someone viewing the vehicles collection and another user just edit one of the columns or add a new vehicle instance, it will be reflected immediately to who views it online.
My question is if there attitudes like I mentioned above, if there some formally names for it, if it a good practice, if you know someone who regularly uses it, a framework or something etc. Does the socket.io server can handle and behave like http server in high workloads?
You can use websockets for this; they provide a bidirectional channel between client and server to send messages across. You will have to catch and parse the messages on each end yourself, as there is no additional protocol on top of them.
They don't hold state, so there is no knowledge of who is looking at what, or who got what. You could send the same update message to all connected clients and leave it to the client to use it or not.
You would have to reprogram your client code and the API endpoints, because it's a different way of doing things, and it can also do server push.
I have no idea about frameworks though, as I always use them without one. Websockets are fast, but server behaviour at high workloads depends on implementation, and I only have experience with the websocket server I wrote myself. I suppose the performance of the socket.io can easily be googled.

How to emulate a Timeout property?

I have a call to a remote Datasnap REST method where the server sometimes doesn't respond and I need to detect it and terminate the application instead of leaving it frozen.
I use a DSRestConnection, and a Datasnap REST Client Module where all the remote methods are defined, attached to the DSRestConnection. I can't find a Timeout property on them, AFAIK I can only set Timeouts on the Datasnap Server, but sometimes the client loses connection to the server, so I also need to raise a Timeout on the client.
How can I emulate a Timeout when I don't have one ?. Is there a class to help do that or do I need to code it from the ground up ?. in this case, the way to go is to do the remote call on a secondary threat, so the main thread is still responsive and use something like a Timer to check if the call has succeeded in time ?.
I would appreciate any suggestion. Thank you.
The TDSRestConnection should give you access to the underlying TDSHTTP client via its HTTP property. The TDSHTTP client exposes a ConnectTimeout and a ReadTimeout property. Perhaps the latter one is what you are looking for.

Can server communicate directly to client?

Everybody knows that client always request to server to execute script and get required data and we can give lot of examples of this.
But the question is that. Is there any example that server directly communicate/request to client. The server is not categorized i mean that any server.
Thanks in advance

Searching for an efficient Client-Server-Networking method

I have a Server and a ton of Clients. (1,000 - 1,000,000)
I am new to networking.
I would like realize the System as follows:
Client registers to the Server. (through a normal Socket-Connection)
Connection is closed after registration.
Receiving a message:
Server sends a 'wake-up-packet' to the Client, which then connects (through the Socket-Connection) to the Server to retrieve the data that's waiting.
Connection gets closed after data-transfer is over.
Sending a message:
1. Client connects by itself to send data.
2. Connection gets closed after data-transfer is over.
In PHP, Server-Sent-Events do this job and I have not found an equivalent for Java, C++ or C# (the languages I have to chose from).
If you know technique that does what I described (or something similar) or, if you have a better (more resource-efficient) Client-Server-Model and maybe even an example of the implementation then please leave an answer.
Thanks in advance!
Simon

Where should I look for a Scala framework that supports bidirectional asynchronous communication?

I have a single server which can have multiple clients. Each client sends an asynchronous message to the server which immediately routes the message to a third party provider. At some point in the future, the server receives a response from the third party provider which should immediately be routed back to the sending client. I have had a look at Akka but had trouble figuring out how to route messages from the server back to clients at arbitrary points in the future. If I can be given some pointers even to the right parts of documentation I'm happy to take it from there. At the moment I am bewildered by the array of frameworks and options available.
"I have had a look at Akka but had trouble figuring out how to route messages from the server back to clients at arbitrary points in the future."
When a message comes in from a client, store away the reference of the sender, so you can send to it later.
Perhaps if you elaborate on the problem you experienced we can assist?
Cheers,
√
BlueEyes is designed for this kind of workflow.
You could also use atmosphere.
If your clients are browsers, you can use Lift and its comet support. This post gives you one example of doing async work using Lift