|
|
|
|||||
|
Bidirectional vs. Callback
Hi there,
I am relatively new to ICE, so please bear with me. I checked all your examples located under /demo/ice and I have to state that they are couple of things I am still not clear about. They are as follows: 1. In case of a bidirectional invocation, you implement servant as a Thread (run() method is provided), but in case of a Callback such thread does not exist. Why? 2. In one of the postings regarding bidirectional invocation you mentioned and I quote "...A better solution would be to modify the CallbackSenderI::run() method implementation to not lock the mutex while invoking on the callback receiver proxy" . Would you mind giving an example of that? 3. I am having a problem with bidirectional implementation where calls are dispatched to the wrong clients. Well, I have to say that the initial implementation was synchronous and it worked fine. Later we decided to switch to bidirectional mode (due to firewall considerations) and we adjusted the source code accordingly to get Receiver's proxy via Identity, but no further modifications have been made. Are we doing something wrong? |
|
|||||
|
Here's the server method that gets invoked from the client:
public void remoteCommand( Ice.Identity __identity, String __command, Ice.Current __current) throws DakotaException { _logger.info( "Received command: " + __command ); CallbackReceiverPrx callbackreceiverprx; Ice.ObjectPrx proxy = null; try { proxy = __current.con.createProxy( __identity ); callbackreceiverprx = CallbackReceiverPrxHelper.uncheckedCast( proxy ); String line; _process = Runtime.getRuntime().exec( __command ); System.out.println("Executing " + __command ); _input = new BufferedReader( new InputStreamReader( _process.getInputStream()) ); String str = null; while (( str = _input.readLine()) != null) { callbackreceiverprx.stdout( str + '\n'); } _logger.info("Process exit value: " + _process.waitFor() ); } catch (Exception e) { System.out.println("ERROR: " + e.getMessage() ); System.out.println("Caused by: " + Arrays.toString( proxy.ice_getEndpoints() )); e.printStackTrace(); throw setException( e.getMessage() ); } finally { try { callbackreceiverprx = null; cleanOut( _process, _input); }catch( Exception ignored ){} } } |
|
|||||
|
Client's code
Here's a snapshot from the client:
Ice.ObjectPrx proxy = communicator.stringToProxy("XXXXXXX:default -h localhost -p 10040"); CallbackPrx callbackprx = CallbackPrxHelper.checkedCast( proxy ); Ice.ObjectAdapter adapter = communicator.createObjectAdapter(""); Ice.Identity ident = new Ice.Identity(); ident.name = Ice.Util.generateUUID(); ident.category = ""; adapter.add(new CallbackReceiverI(), ident); adapter.activate(); callbackprx.ice_getConnection().setAdapter(adapter ); callbackprx.remoteUnixCommandBidir(ident, _command ); communicator.waitForShutdown(); |
|
||||||
|
Quote:
Your code looks fine. You could replace the following: Code:
Ice.Identity ident = new Ice.Identity(); ident.name = Ice.Util.generateUUID(); ident.category = ""; adapter.add(new CallbackReceiverI(), ident); Code:
adapter.addWithUUID(new CallbackReceiverI()); In any case, I don't see how callbacks to clients could get mixed up. Your client is calling remoteUnixCommandBidir but you only provided the implementation of remoteCommand, is this the same method? To investigate this, I suggest that you add an "Ice.Identity" parameter to your stdout() method and pass back the receiver identity to print it in the callback receiver implementation and ensure it's correct. Cheers, Benoit. |
|
||||||
|
As a further note the best, and often fastest way, to get help on an issue is to post a complete self-contained compilable example that demonstrates your problem. Posting code-snippets, in 99% of cases, doesn't help track down the problem.
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Async bidirectional issue | Kruppy | Help Center | 15 | 05-16-2007 11:44 AM |
| Bidirectional callbacks and mutexes | albertods | Help Center | 1 | 02-28-2007 02:22 PM |
| About bidirectional | level | Help Center | 1 | 12-30-2005 05:53 AM |
| Callback on legacy client without callback support causes deadlock? | timeguest | Help Center | 1 | 07-30-2005 08:12 AM |
| A question about bidirectional connection | rc_hz | Help Center | 3 | 07-21-2005 08:12 AM |