I want to check my solution with you. We are makin...
# suitescript
m
I want to check my solution with you. We are making an implementation for an shipping company. They have a system that tells Netsuite when the shipments is delivered. So my solution is: Set RESTlet endpoint to listen to shipments, create a scheduled task with the shipments parameters. And the scheduled script will create a sales order. Now when I am doing this, I get "Failed to submit job request: INPROGRESS" So, can't I add the same scheduled script task to the queue?
b
cant add the same deployment
you can queue multiple different deployments of the same script
expect to have more robust error handling than simply script parameters
if the deployment fails, those parameters could be lost
m
So in my case, I can't just create a deployment for every shipment, that would be weird. Should I use map/reduce, or this is not its place?
I feel like I am using the wrong type of script, but I don't know what to use too.
b
depends on what your needs are
simplest solution is to siimply use the restlet to do your work
has the advantage of being synchronous
and relatively simple to do
m
Won't I get a lot of rejected requests, if the client sent a lot of requests?
b
depends on how many requests the client sends at once
m
Do you know SQS?
b
nope
m
Or google tasks?
You just get a queue, and there is a function at the end of the queue, or many instances of that function. Exactly like cashers. You can send any number of jobs or tasks in the queue, and the function at the other end keeps processing the requests.
Now, that is totally different from what Netsuite is offering, right?
b
different model
restlets are simple servlets
suitelets too
map/reduce scripts, and to a lesser degree scheduled scripts function more like queues
m
But you can't achieve the same thing with Netsuites. As I understand it, there is no way to have an endless queue of the same type of tasks, right?
b
major difference being that those scripts have to build the queue themselves
map/reduce scripts have more structure to them and have ways of defining how the queue is consumed
m
Is there open source solutions for this?
b
no
m
hmm
maybe I could do one later. thanks very much.
b
@stalbert would probably be interested in explaining how NFT works for you
either way, i would recommend learning the basic idea of map/reduce scripts
which is making a search of results to process
and then making functions to process those results
m
A common pattern is a custom record as the queue. The restlet creates a job in the queue and a M/R every 15 minutes processes items from the queue.
If you wanted to use scheduled scripts for queuing, I have heard of people creating deployments dynamically, but this is no where near as robust
@Brendan Boyd has shared a queue implementation that looks like a good starting point https://medium.com/tolaeon/a-message-queue-in-netsuite-60b080042624
🙌 2
m
Will check it out, thanks ❤️