How to pass a parameter in the "requestHandled" HTTP request callback function in apama EPL?

Hope you’re doing good!
I had a query regarding the use of the “requestHandled” callback function while executing an HTTP request in an EPL app.

My main question is about sending a parameter in this function. As we see here, there is no parameter passed in this function, but there is a Response parameter passed to it by default in the function definition:

Is it possible to send another parameters to this function? I tried doing so but it threw some errors stating that it accepts only one parameter.
Our use case is to extract a URL from the response and assign it to a global variable and then pass that global variable to another action sendOperation. But due to some reason, when we call sendOperation and pass the URL global variable as a parameter, it receives an empty string. This means that sendOperation is called before the URL is assigned to the global variable in requestHandled action. To prevent this, I have tried a workaround to wait for a few seconds and then call sendOperation().

Waiting allows the URL to be assigned to the global variable and it then works fine. However it is not a suitable approach (for obvious reasons).
Now, the reason why sendOperation action is not being called from inside the requestHandled action is that it requires an Event Type parameter (e) which cannot be sent through the requestHandled action (since it cannot accept another parameter apart from Response).

This brings us to the main question: Is there a way to send another parameter to the requestHandled callback action so that we can send the Event parameter through it and thereby call the sendOperation action from inside the requestHandled action, by which we can avoid waiting for a few seconds?

Please help me find a better approach to execute our use case efficiently.

Thanks

One option might be to define your own event to contain the URL. You could send this event from inside the responseHandled action and listen for it where you have “on wait(2.0)” currently, calling sendOperation with the URL contained in the event.

1 Like

To follow on from Joel’s comment, here is some pseudocode of what that might look like (you’ll need to define your event somewhere).

monitor.subscribe("TempChannel")
on CustEvent() as event {
	sendOperation(e, event.serviceURL)
}

[...]

action responseHandled(Response resp) {
	[...]
  send CustEvent(serviceURL) to "TempChannel";
}
1 Like

Thank you very much… I’ll try this.

Thanks for the pseudocode. Appreciate it!

Glad to have helped. If you’re able to, would you be willing to share what you’re using this API for, and whether the GenericRequest API would have been an adequate substitute here? We’re interested to know if there are areas of our documentation we can improve :slight_smile:.