Remote Activation; what should be expected

Given the following code on Uniface 9.4, what should be expected to happen?

CLIENT_FORM; Form so running on the client variables string vString endvariables newinstance ?REMOTE_1?, ?myRemote1? activate ?myRemote1?.setText(?Text From CLIENT_FRM?) newinstance ?REMOTE_2?, ?myRemote2? activate ?myRemote2?.getText(vString) message/info vString
REMOTE_1; a Service running remotely operation setText Params String pString : IN endParams newinstance ?REMOTE_2?, ?myRemote2? activate ?myRemote2?.SetText(pString) end

REMOTE_2; a Service running remotely operation init $MY_TEXT$ = ?Set in init? end operation setText Params String $MY_TEXT$ : IN endParams end operation getText params string $MY_TEXT$ : OUT endParams end

So to the questions:

  1. What should the activate of ?myRemote2?.GetText return?

    ?Set in init?

  2. Should both the instances created by CLIENT_FORM be created on the same userver?

    If the userver is defined as exclusive then they will be on the same userver, if the uservers are shared between multiple clients then the second newinstance will be created on the oldest userver free at the time.

  3. If both instances are created on the same server why doesn?t ?myRemote2?.GetText return ?Text From CLIENT_FRM?

    The scope of an instance is only within the context (client or userver) it was created. Even though both instances of REMOTE_2 are named myRemote2 (one created by CLIENT_FORM and the other by REMOTE_1) they are created in different contexts so will be isolated from one another. If this wasn?t the case there would be some very hard to diagnose bugs.

  4. Can I directly access to the instance of REMOTE_2 created by REMOTE_1 from within CLIENT_FORM.

    Yes. A handle to myRemote2 can be obtained from within myRemote1 and passed back to the client. This handle can then be used to gain access to the existing remote instance.

  5. Should the code from REMOTE_1 and REMOTE_2 be visible in the clients debugger?

    No. To debug code running on a userver you must attach a separate debugger instance to the userver. Whist debugging an application it is a good idea to use the /max=1 userver option so the application will not be tempted to start off new userver sessions and you can be sure to see all the calls in the debugger. There are a few videos which demonstrate how to do this.

0 thoughts on “Remote Activation; what should be expected”

  1. Hi Mike, thank you for that great explanations about remote activation. There is a difference in “MyRemote2” and “myRemote2” but I think uniface uses all uppercase so it does not make a difference. *** 2 questions: ??? what is $status after execution of newinstance remote_2 on the client form? I guess a 0 because a new instance was created *** executing the services locally (which is just a change in the ASN) what will “myRemote2”.GetText return? I guess “Text From CLIENT_FRM” *** Success, Uli ***

  2. Hi Uli. You are quite correct, Uniface will not worry about the differences in case but I have updated the article for clarity. After the newinstance of remote_2 the vales $status and $procerror are 0 and if I were to change my asn file to have my services locally I would get “Text From CLIENT_FRM” returned…. But if I did change the code so that everything was local I would get a negative $status and $procerror returned from the newinstance of REMOTE_2 and I would have to decide whether this was acceptable or not. For my code to be as robust as possible and to allow both local and remote execution I should consider re-factoring in one of two ways. 1) Extend REMOTE_1 to allow it to proxy the calls to REMOTE_2 or 2) Pass back from REMOTE_1 a handle to the exact instance of REMOTE_2. Personally I believe option 2 allows for a more maintainable application but both would work.

  3. Thanks Mike about the $status of 0. Unfortunately a problem with the handle stopped using them in my customers framework: ** putitem a handle and getitem afterwords don’t restore a proper handle. ** I have not tested if solved in 9.4, but our production runs on a 8.4. Success, Uli

  4. Hi Mike, just to clear the situation: it makes no difference if /ex is set or not; even in exclusive userver we would have 2 instances with the same $instancename? TIA, SUccess, Uli

Leave a Reply