Page 1 of 1

problem using Asynchronous Method Calls

Posted: Wed Jun 01, 2011 7:37 am
by ghosttie
I'm trying to use Asynchronous Method Calls for the first time.

I create an instance of JadeMethodContext, call initialize, set workerAppName, call invoke and I'm getting a 31923 "Worker application is not running" exception.

The worker application is running - I can't see any reason why this isn't working.

The worker application is calling asyncInitialize in its initialization method and asyncFinalize in its finalize method.

I've tried renaming the application a couple times, I've tried running it as a server app and as a thin client app, but nothing seems to make any difference.

Does anybody with Asynchronous Method Call experience have any ideas?

Re: problem using Asynchronous Method Calls

Posted: Wed Jun 01, 2011 8:39 am
by murray
Use the Jade monitor to verify that the worker process is running in the same node as the main app.

Re: problem using Asynchronous Method Calls

Posted: Wed Jun 01, 2011 8:57 am
by ghosttie
Yes it is

Re: problem using Asynchronous Method Calls

Posted: Thu Jun 02, 2011 9:17 pm
by murray
Hi ghosttie, are you still troubleshooting this problem?
If you happen to be starting the worker process from the method that invokes JadeMethodContext::invoke(), then there may not be enough time from the execution of app.startApplication() to the call to invoke() to allow for the worker application to initialise itself. In this case you could try inserting a process.sleep() statement for to see if that helps.
(BTW, I am not an expert in Jade's Asynchronous Method Call framework: I DIY'd my own equivalents before this feature was available in Jade but am preparing to use it when required in the future).

Re: problem using Asynchronous Method Calls

Posted: Thu Jun 02, 2011 10:57 pm
by ghosttie
Yeah I still haven't got it working.

At the moment I'm not even using startApplication, I'm starting the worker application manually so it's definitely had enough time to get started.

Re: problem using Asynchronous Method Calls

Posted: Fri Jun 03, 2011 4:06 am
by ghosttie
This is weird - I can run the Asynchronous Method Call sample fine, but my simple test doesn't work at all.

Here's what I'm doing:
  1. Create awInit on your subclass of Application and call asyncInitialize in it.
  2. Create awFinalize on your subclass of Application and call asyncFinalize in it.
  3. Create a non-gui application called AsyncWorker with awInit set as its initialize method and awFinalize set as its finalize method.
  4. Run the AsyncWorker application, without selecting Run As Server Application so it runs in the same node (assumes running thin client).
  5. Use the Monitor to check that the application is running.
  6. Create a JadeScript that creates an instance of JadeMethodContext, sets workerAppName to "AsyncWorker" and calls invoke with (global, isValidObject, null) just as a test.

Re: problem using Asynchronous Method Calls

Posted: Fri Jun 03, 2011 5:00 pm
by murray
OK, I've just tried exactly what you describe and it works OK for me.
The only thing I had to change was the final parameter in the call to invoke because null resulted in Error 31914 "Unsupported method parameter type". I changed it to: invoke(global, isValidObject, global) for the sake of the test. I tested it on Windows 2000 (in a VM) running Jade 6.3.08.
Here is my code.

Code: Select all

constants WORKER_APP = "AsynchMethodWorker"; vars jmc1, jmc2 : JadeMethodContext; begin create jmc1 transient; jmc1.workerAppName := WORKER_APP; jmc1.invoke( global, isValidObject, global ); jmc2 := process.waitForMethods( jmc1 ); write "result = " & jmc2.getReturnValue.Boolean.String; write jmc2.display; epilog delete jmc1; end;
To troubleshoot further you could add some code to the JadeScript, prior to the invoke call, that iterates through all processes in the node and displays their details to confirm what the script sees running:

Code: Select all

vars proc : Process; begin foreach proc in node.processes do write proc.String & " " & proc.persistentApp.name; endforeach; end;

Re: problem using Asynchronous Method Calls

Posted: Sat Jun 04, 2011 2:43 am
by ghosttie
I think I've worked out what the problem is - it doesn't like it when the application is defined in a superschema.

Thanks for your help.

Re: problem using Asynchronous Method Calls

Posted: Sat Jun 04, 2011 7:29 pm
by murray
I think I've worked out what the problem is - it doesn't like it when the application is defined in a superschema.
Thanks for your help.
That's OK. The devil is always in the details. ;-)