[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.ecf] Re: Simple Client Server Example?

Hi Phil,

Philip Quitslund wrote:
Hey all,

I've been intrigued by ECF for a while so I was delighted when I found an excuse to dig in. I poked around in the docs but probably missed the obvious. (Forgive me for that!) Anyway, I'm looking at implementing a basic client server protocol to support simple communication between two OSGi/Equinox app instances. The protocol will be dead simple (essentially just a way to send remote commands). Is there an example of something like this that I've overlooked?


Well, there are several examples of different use cases...but none which *exactly* match yours (which is good!).

So I have one question to ask about 'sending remote commands'. Do you want to have your own infrastructure for sending and interpreting the commands, or would you rather use an RPC/remote service approach? Reason I ask...ECF has support for both

1) sending arbitrary messages (strings, ints, etc) over a messaging channel (via datashare API)
2) synchronously and/or asynchronously executing remote methods/services (remote services).


So if by sending remote commands you mean sending (say) a fixed set of strings that identify what the receiver should do...and then receiving the command, interpreting it (by running the appropriate blocks of code and responding) then '1' would probably be best. If you want support for proxys, mapping requests to method calls, marshaling/unmarshaling parameters, calling synchronously/blocking and/or asynchronously, then '2' would be more helpful.


Here's a sketch of a use case:

* Machine A (the client) wants to send a command to another machine
* Machine A discovers available (server) machines, finding Machine B


ECF has a discovery API...so if you want the clients to discover via (LAN-or-WAN-based) discovery, then you can/could use the ECF discovery API (there are example apps and test code that use the discovery API to discover external processes of a certain type (i.e. those that understand your protocol).

But I'm not sure if you want all this for this example/your app...that is...perhaps you don't want to do network discovery...and if not then you can have other ways to 'discover' servers/services (e.g. consulting centralized/web registry, etc).

So it sounds like this (dynamic network discovery or not) is another design choice point for your app (i.e. network discovery or not).

* Machine A sends a command request to Machine B
* Machine B receives the command and consumes it
* Machine B responds when it has completed the request

Is there an ECF "Hello World" or test case that approximates something like this?

There is some test code for the datashare API that is very much like this. That is, all that happens is that an IChannel is created (with a specific, unique name), a sender sends a String/command to the other side, and the other side simply prints out that it received it (rather than responding).


This code is in org.eclipse.ecf.tests.datashare.ChannelTest...which is here [1]. Note that there is a fair amount of support code in the ContainerAbstractTestCase, which is in org.eclipse.ecf.tests project. But the basic operation of sending a message (String converted to byte[] is in ChannelTest.testSender().

Also note that the docshare real-time shared editing is built over the datashare API (i.e. '1' above). So if you want a more complicated example of sending/receiving messages (in this case serialized objects) using datashare, then that code is in org.eclipse.ecf.docshare.DocShare class, which in viewcvs is here [2].

There are also examples of using remote services API in the following bundles (in /cvsroot/rt org.eclipse.ecf/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.client
org.eclipse.ecf/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.common
org.eclipse.ecf/server-side/examples/bundles/org.eclipse.ecf.examples.remoteservices.server
).


This example code also uses the discovery API to publish and dynamically discover remote services.


BTW, if there isn't such a thing (and there's sufficient interest), I'd be happy to contribute back whatever I get working.

That would be great. If you are willing, I will offer to help with the development given that it can be contributed back.


Thanks,

Scott

[1] http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ecf/tests/bundles/org.eclipse.ecf.tests.datashare/src/org/eclipse/ecf/tests/datashare/?root=RT_Project

[2] http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.docshare/src/org/eclipse/ecf/internal/provisional/docshare/DocShare.java?root=RT_Project&view=log