Overcoming “invocation forwarded to primary instance” in Adobe AIR
… I’m only referring to AIR applications launched from command line adl here, not of installed AIR applications.
So, I had a java program that needed to run several instances of the same AIR application. By default, calling the following line more than once while the initial application is active:
1 | adl.exe /path/to/air-application-descriptor.xml |
…, will result in all calls being forwarded to the first instance (message: “invocation forwarded to primary instance”). Since the whole idea of running several apps in the same time is for each to do something specific, this is kind of a blocker.
Good thing that AIR uses only the application id (found under <id> tag in the descriptor) to identify between applications launches. Therefor the solution was pretty straight-forward:
- replicate the original application descriptor and give it a standardized unique name
- update the ids for each descriptor and make sure they are unique
- do a programmatic search in the folder for application descriptors matching the standard name and create a thread pool with launchers for them (this was on java side)
You might find this useful (ant code for replicating descriptors/renaming ids):
1 2 3 4 5 6 7 8 9 | <for begin="1" end="${APP_COUNT}" param="i"> <sequential> <copy file="src/demo-app.xml" tofile="dist/demo-app-@{i}.xml" overwrite="true" /> <replace file="dist/demo-app-@{i}.xml"> <replacetoken><![CDATA[<id>demo-app</id>]]></replacetoken> <replacevalue><![CDATA[<id>demo-app-@{i}</id>]]></replacevalue> </replace> </sequential> </for> |
…, where application_id is the ID of the application (usually set to project name) and APP_COUNT is a property setting the number of apps to be deployed.
