Non-blocking Gosub() to context with variables

I have read Non-blocking version of Gosub command as an effort to implement a non-blocking Gosub() (or rather a context that returns right away but continues processing a long-running task in the background).

I generally understand the concept of Local channels in the Dial() command and already have scratched the surface in using it.

But in this case, the context I want to run in the background (which would be the target of a Local/ channel) takes an argument and I cannot see how Dial() can pass an argument.

Generally I’m thinking of the non-blocking-long-running context to look like this:

context send_message_non_blocking {
    s => {
        NoOp(Message: ${ARG1});
        Dial(Local/s@noop&Local/s@send_message);
    }
};

context noop {
        NoOp(Doing nothing in noop);
	return;
};

context send_message {
    s => {
        NoOp(Sending a Message...);
        NoOp(This can take a long time);
        NoOp(Message: ${ARG1});
...
	return;
    }
};

With goal being to be able to call Gosub(send_message_non_blocking,s,1(Message goes here)) and have it return immediately, without waiting for the long running send_admin_message to finish.

Or is my approach above completely unworkable?

The extension that you dial can have wildcard parts that are used to contain parameters.

Channels created by Dial obey the inheritance rules for channel variables.

Dial will block, unless you use the G option, to start a new PBX instance on the B side.

Running something in a separate thread sounds more like a case for Orignate, than Dial, although I’m not sure how channel variables are handled.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.