Okay,
So, the first thing is, your code needs to be in an operation on a service. (I'm assuming it's not due to the activate....exec.)
Then, you can call it async as long as the service component is referenced in the [SERVICES_EXEC] part of the asn associated with the client which is calling it. (Which causes a userver process to be selected/spawned by the urouter).
So, if we call the component you are calling FROM (the one your sample code lives in) COMP_A which is running in an environment using a.asn.
In a.asn you need something similar to.
[PATHS]
SVCS TCP:Server|userver|password|ASYNC
[SERVICES_EXEC]
COMP_1 $SVCS:COMP_1
COMP_2 $SVCS:COMP2
In urouter.asn you need
[SERVERS]
ASYNC="userver.exe" /dir=XXX /asn=
b.asn Then you need a b.asn for the userver. This must NOT have the COMP_[12] stuff in the services_exec.
I also think you don't need the newinstance, and should (probably) use activate/stateless/async to ensure the components are cleared from the userver on exit.
If you are calling the services async from a client (uniface.exe) then a.asn is the client asn and b.asn is the userver asn, and you can 'mix' calls to even the same service as sync and async, if you are calling the services async from another service already running in userver.exe then you need two userver asns as one must call the other as a PATH.
I hope that helps, if not it may require me braking out my diagramming skills (which are poor.)
Regards,
Iain
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
Original Message:
Sent: 09-22-2022 02:50
From: Shubham Saini
Subject: Facing -161 on calling a component asynchronously.
Thanks for the quick response.
I understood your answer at very high level. We are using window and linux server and communicate through urouter. Can you explain in more details, on how we can proceed further.
------------------------------
Shubham Saini
Uniface Community Edition Shared Account
US
Original Message:
Sent: 09-21-2022 16:30
From: Iain Sharp
Subject: Facing -161 on calling a component asynchronously.
I don't think you can call forms async. The process has to be started on a new copy of uniface/userver so for the client it has to be called via urouter onto a userver.
We have also called services from within services, but again, the main service has to be running on a userver using an asn with the async service called on a different path using [SERVICES_EXEC] to start the async service on a different path.
Regards
Iain
Sent from my iPad
Original Message:
Sent: 9/21/2022 4:17:00 PM
From: Shubham Saini
Subject: Facing -161 on calling a component asynchronously.
Hi,
I have a requirement where i want to call the components to work parallelly. I did try to create asynchronous instance for the component and activate it, but getting $procerror -161 (Illegal mixture of synchronous and asynchronous communication mode).
Code:
newinstance/async "COMP_1", comp_inst1
newinstance/async "COMP_2",comp_inst2,
instances were successfully created. on moving further.
activate/async comp_inst1.EXEC()
activate/async comp_inst2.EXEC(),
$procerror return -161.
Can anyone please help me out here, on how do i activate the component asynchronously.
------------------------------
Shubham Saini
Uniface Community Edition Shared Account
US
------------------------------