Jade6.2 JadeMethodContext

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Jade6.2 JadeMethodContext

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

by Didier >> Thu, 8 Nov 2007 8:56:38 GMT

hi:
i defined a class named SRMast and method
SRMast::method1 ======================================================
method1( _count : Integer ) : String ;

vars
i : Integer ;begin

foreach i in 1 to 10000 do
write "method1 " & i.String ;
endforeach ;
return null ;
end ;
=========================================================
why the following code can not throuht compile
and give me exception message:
Error 6391 -First actual parameter for PseudoMethodCallType must be object reference.

Asynchronous method is very improtant for us
Appriciate for any help.

the program code is as following ========================================================================= button2_click(btn: Button input) updating;

vars
srmast : SRMast ;
jmc : JadeMethodContext ;
count : Integer ;
obj : Object ;begin

create srmast transient ;
create jmc transient ;
jmc.invoke( srmast, "method1", count,count ) ;
epilog
delete srmast ;
delete jmc ;
end ;
==============================================================

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Jade6.2 JadeMethodContext

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

by Murray Symon >> Thu, 8 Nov 2007 9:14:46 GMT

I think the main problem is that your srmast object is transient - so it won't be visible to any other processes (e.g. the asynch worker app). Try creating it as a shared transient.

Minor issue - your declared your method1 with 1x _count parameter, but your invoke call has 2x 'count' parameters being passed (which will both be zero).

Murray Symon.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Jade6.2 JadeMethodContext

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

by Didier >> Thu, 8 Nov 2007 9:24:12 GMT

Hi:
the exception is raised in compilation time.
not in the run time.
didier

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Jade6.2 JadeMethodContext

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

by cnwtb2 >> Thu, 8 Nov 2007 10:55:52 GMT

The messaging framework relies on the asynchronous call (JadeMethodContect::invoke) to hold the messaging information for asynchronous processing, hence, at compile time, Jade expects the PseudoMethodCallType input parameter to hold this messaging information. If it doesn't then it will throw out errors detailing what needs to be set/changed.

The PseudoMethodCallType input parameter expected from Jade at compile time is:

Param1 = Object
Param2 = Method on the class of the Object,
Paramx.... any parameters needed to run the method called in Param2.

hence, jmc.invoke(Class, Method, parameters),

therefore, Murray is correct when he states "...your declared your method1 with 1x _count parameter, but your invoke call has 2x 'count' parameters being passed..." because only one parameter is expected for 'method1' but you are passing in two

Therefore, remove the invalid parameter (count) and compile. This should solve your problem.

For your own testing and understanding, remove the 'method1' parameter and compile it as "jmc.invoke(srmast, count, count); It should error with a 6392 error because there is no method on the srmast class called 'count' that passes 1 parameter called count.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Jade6.2 JadeMethodContext

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

by Didier >> Fri, 9 Nov 2007 7:39:21 GMT

Thanks , It works now.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Jade6.2 JadeMethodContext

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

by Murray Symon >> Fri, 9 Nov 2007 22:09:26 GMT
hi:
i defined a class named SRMast and method
SRMast::method1
[snip]
why the following code can not throuht compile
and give me exception message:
Error 6391 -First actual parameter for PseudoMethodCallType must be object reference.

Asynchronous method is very improtant for us
Appriciate for any help.
[remainder snipped]

I am interested to know what you are using the new asynchronous methods for - you say it very important. Is it something that could not be solved by using 'app.startApplicationWithParameter' in previous versions of Jade? I have used that approach in the past. My employer will still be using Jade 6.1 for some time yet, but I am interested in the benefits of the new feature.
I guess (what you have already found) is that it provides for more compile-time checking!

Murray.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Jade6.2 JadeMethodContext

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

by dcooper@jade.co.nz >> Sat, 10 Nov 2007 12:25:19 GMT

Hi Murray,

You're correct that you can write parallel operations today using app.startApplicationWithParameter(). By many applications also want the following:

1. Type safety on the parallel method calls (as you've noted).

2. The use of a thread/process pool. That is, rather than initiate a new process for every parallel call, they want a pool of workers to handle all parallel calls within a node. And then you need to be able to queue calls to the worker pool as well.

3. If a process wants to initiate multiple parallel operations, it generally then needs an efficient way of waiting for completion of some or all of the tasks, detecting failure of a task, and also handling timeouts in the event that one or more tasks take too long. The Asynchronous Method Calls framework in JADE 6.2 gives you an easy way to do this.

Points 2 and 3 above are do-able without the Asynchronous Method Calls framework and a number of apps have written their own mechanisms. But writing a robust parallel task framework is non-trivial, which is why we wanted to provide one out-of-the-box in JADE 6.2.

Dean.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 35 guests