Convertigo Public Knowledge base

Execute a sub Sequence asynchronously

Executing a sub sequence from a parent sequence, will wait for the sub sequence to finish before returning to the main sequence and execute following Steps.

To execute a sub sequence asynchronously you can use a SequenceJS Step with the following code:

var running = null; com.twinsoft.convertigo.engine.Engine.logContext.debug("Before creating runnable"); var r = new java.lang.Runnable() { run: function() { // prevent from deletion of variables in previous context var logRunnable = com.twinsoft.convertigo.engine.Engine.logContext; logRunnable.debug("Into runnable function"); // call sequence manually var __project = java.lang.reflect.Array.newInstance(java.lang.String, 1); __project[0] = "<ProjectName>" var __sequence = "<SequenceName>" var parameters = new java.util.HashMap(); parameters.put("__project", __project); parameters.put("__sequence", __sequence); parameters.put("<param1>", <value1>); var request = new com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest(context.httpServletRequest); var requester = new com.twinsoft.convertigo.engine.requesters.InternalRequester(parameters, request); running = true; requester.processRequest(); logRunnable.debug("Into runnable function after processRequest"); } }; new java.lang.Thread(r).start(); var cpt = 200; while(running != true && --cpt){ java.lang.Thread.sleep(50); }

To test success/failure response of the asynchronous sequence, use Set in session and Get from session Steps to transmit information between sequences.

(c) Convertigo 2023 https://www.convertigo.com