Saura Sambit
Tera Expert

ServiceNow’s event queues are mechanisms used to manage and process system events asynchronously. Events trigger actions based on conditions, enabling tasks such as notifications or workflows.

When examining the Events [sysevent] table, you’ll notice that certain out-of-the-box (OOB) events have a value specified in the ‘Queue’ column, while others leave this field blank.

 

event_queue_log.png

 

event_queue_log_empty.png

 

Why custom queue?

 

When the ‘Queue’ column is left blank, the event is automatically processed in the ‘Default’ queue. Typically, when creating custom events, we leave this field empty, allowing them to be handled by the ‘Default’ queue, which works well for infrequent events. If your workflow triggers a high volume of events in a short period, it’s essential to define a separate queue to prevent system slowdowns.

 

In this article, we’ll explore how simple it is to create a custom event queue to optimise performance.

 

Defining queue processor

 

  1. Navigate to the Schedule [sys_trigger] table
  2. Look for and open the record with name ‘text index events process

 

text_index_events_process_record.png

 

       3. Take a look at the ‘Job context’ field. It will have a one-liner script like below.

            ##Fri Sep 13 22:08:00 PDT 2024
            fcScriptName=javascript\:GlideEventManager('text_index').process();

       4. Let’s assume our custom queue is called ‘reminder_queue‘.

  •   Edit the ‘Name’ field to reflect that.
  •   Edit the ‘Job context’ to replace ‘text_index‘ with ‘reminder_queue
  •   Insert and Stay on the record (very important)

 

reminder_queue_record.png

 

 

Next steps

 

Whenever we need to trigger an event in the custom queue that has a defined queue processor, we simply pass the queue name into the function call as the fifth parameter, as shown below:

             gs.eventQueue('event', recordGr,  parm1, parm2, ‘reminder_queue’);

 

Comments
Nisar3
Giga Guru

Another thing to note is that even if the 5th parameter is not passed, the event will still be processed under the custome queue and that value will be picked from the event registry record

 

 gs.eventQueue('event', recordGr,  parm1, parm2); // will still fall under reminder_queue

 

The only difference is that if 5th parameter is passed, its takes priority over those events where it's not passed.

 

nobirip602
Mega Contributor

The only difference is that if 5th parameter is passed, its takes priority over those events where it's not passed.

nobirip602
Mega Contributor

Another thing to note is that even if the 5th parameter is not passed, the event will still be processed under the custome queue and that value will be picked from the event registry record

Version history
Last update:
‎09-16-2024 09:30 PM
Updated by:
Contributors