Get Control over NetSuite’s Scheduled Tasks

This article is relevant if you are working with NetSuite SuiteScript and you seek to optimize the use of scheduled scripts.

Background

When we design applications for our clients, we consider the need for scalability and good user experiences. At all times, we must respect that NetSuite has a computing governance model which (appropriately) constrains our capacity to get work done. These considerations influence our design and software development practices. When programming in NetSuite, to respect the governor, we must check how much capacity is available to continue an operation or we risk a script error.

Once you understand the governance model, you can begin to create more reliable applications. NetSuite offers a mechanism to run scheduled background scripts which are useful to improve a user experience or to run processes at some future and / or periodic interval. Many times, we need to perform operations that may affect a large number of records. While there are different techniques to process records, and execute long-running operations, we found that working with complex multi-user applications can get tricky.

Consider when you design a user-friendly web page (SuiteLet or otherwise) that upon user submit, you want to immediately return a response because you will issue a background scheduled job to act on the submitted data. The challenge comes if the target queue is already being used by an existing job. The program will return an error because it can’t get a handle to the scheduler. Even if your account is configured with multiple queues (NetSuite offers one queue by default — but an add-on allows you to buy more queues in blocks of 5), you still can have insufficient capacity.

Solving the NetSuite Queue Challenge

After being troubled by this common NetSuite programming challenge, one of our senior consultants, who has had long-term experience working on mainframes, understood the processing pattern. What was need was a Queue Manager. This manager would ensure that scheduled jobs will indeed get operated on. Jobs could be scheduled to run autonomously. Each job could be given data which needed to be acted on — in essence, the job request would carry state. Jobs could be prioritized. Furthermore, if a job failed, we could retry a specified number of times. The manager would also allow us to see a history and we could ensure the health of our applications because we could look for error situations with rich diagnostic information.

Key Steps to Using Queue Manager

The Queue Manager is part of our Prolecto Utilities Library which we leverage across all of our clients and applications. The key to using the library is as follows:

  1. Name your Queue: provide a string token to identify unique jobs.
  2. Add a Queue Entry: when you need a job to run, first produce an entry in the Queue. Provide as much parameter information as needed. This makes the job stateless.
  3. Fire Scheduled Job: scheduled jobs then work to “Get Next Queue Entry” to retrieve parameters and understand the work to do. Depending on priorities, the correct next queue entry will come forward. Scarce resources are fairly allocated.
  4. Mark Queue Entry Complete: if the job runs successfully, tell Queue Manager you are complete.
  5. Watch Governor: check the governor during processing; if you are going to run out of resources, add another queue entry but now with a modified parameter set.
  6. Mark Queue Entry Failures: if something fails in the job, mark the queue entry as a failure. Depending on the failure nature, the job may run again later; or it needs user attention.

While this is the general pattern, there are options that drive usage to fine tune the operation. Now, with the use of Queue Manager, we notice that our client environments are more stable and we are able to better see usage patterns and find exceptions that otherwise were difficult to discover or diagnose.

Watch Queue Manager Video (11:40)

To learn how Queue Manager better works, the following video is a technical discussion offered to one of our consultants. It will help you see the programming model.

Work with Strong NetSuite Talent

Since we are a NetSuite systems integration practice, it is important that we have strong actors which understand and leverage the NetSuite technical framework to produce client solutions. In my mind, NetSuite is a great business platform: but it takes background and experience to learn the techniques and practices to get the most from the environment. I find that talented individuals appreciate working with other strong actors and want to be challenged — if you hold high standards for care and wish to be appreciated for your skills and thinking, let’s have a conversation.

Be Sociable, Share!

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

More Posts - Website - Twitter - Facebook - LinkedIn - YouTube

| Category: Infrastructure, NetSuite, Strategy, Technical | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *