I’m looking to use the async Manager in a place where I’d typically use cfthread, but I’m unsure of the correct syntax.
Here’s the situation - I’m adding a record, and then once it’s added I’ve got three operations that need to take place, but they shouldn’t be blocking and I don’t need data back from them. In pseudocode, it would look something like this:
var record = service.add(thing);
var args = { record: record };
thread
name = "record_#createUUID()#"
attributeCollection = args,
action = "run"
priority="LOW" {
// do these things with the record at some point
make.httpRequest(attributes.record);
make.anotherHttpRequest(attributes.record);
do.something.else(attributes.record);
}
return record;
How would I structure this using the asyncManager to offload the asynchronous requests?
Actually, as I’m typing this I think I’m getting closer to figuring it out. Would it be to just use all()
?
If so, how would I pass the newly created record as an argument to each of the requests?
var record = service.add(thing);
// how do I pass the record as an argument to each request?
async().all(
() => make.httpRequest(),
() => make.anotherHttpRequest(),
() => do.something.else()
);
Or, is there a better approach?
Thanks!