I'm new to ActionHero and I have a need to add something to the queue, wait until that is finished and get the data back, then proceed with another queue'd item before responding to the client. Looks like this:
- API client hits /foo
- the foo action calls the bar action and waits...
- When bar is finished it returns a value of
123abc
123abc
is then passed to the queue again for the task that needs it
It's worth noting here, I understand this isn't optimal, but this involves 3 servers. /foo hits my Node ActionHero server, 123abc
comes from a Java server (think of it as an authentication service), and then my Node ActionHero server is going to send this off to be picked up by a .NET server.
The way I have it setup now with a task does hit the Java server and the Java server logs out the value I need but in the code below it's an empty object
The run() in ACTION:
api.actions.enqueue('MyJavaServerTask', {...}, function(error, toRun){
console.log(arguments) // <-- returns { '0': null, '1': true }
data.response.success = true
api.queue.push(data, next)
})
TASK:
exports.task = {
name: 'MyJavaServerTask',
description: 'My Java Server Task',
frequency: 0,
queue: 'default',
run: function (api, params, next) {
var job = {
response: {},
connection: {id: 'none'},
authorization: params.authorization,
params: {
apiVersion: '1',
action: 'MyJavaServerTask',
...
}
}
api.queue.push(job, function() {
console.log(arguments) // <-- returns {}
next()
})
}
}
On the Java server though, again, I do see the request and it's successful and it returns the right JSON. The log for that looks like
15:19:22.542 [run-main-0] INFO application - apiq read: {"id":"none","params":{"apiVersion":"1","action":"MyJavaServerTask"}}
generating tables and key
15:19:22.543 [run-main-0] INFO application - result: {"key":"..."}
So... how do I get that key
from there back to be used to append to the next queue'd item?