Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

Matthew Billy
Tera Expert

@Nisar3 comment is that the event registry record details the queue for the event; so even when failing to pass the 5th parameter of queue name, the name will be determined by the definition of the event registry record. 

I am not sure about the priority, as this value is also part of the event registry record.

This article may also be very helpful, and includes a diagram.
Custom queue event handling in ServiceNow – Implem... - ServiceNow Community

AmolJ
Tera Expert

I have one notification which is OOTB which we want to keep and one custom notification. They both are triggered on the same condition. Custom notification is triggered through a business rule. I never receive emails for custom notification. Do you think the reason is they are using the same Default queue and same trigger conditions? Thanks

KayC33191887207
Tera Contributor

@AmolJ Check the weight of the custom notification. If it is above 0 and lower than the weight of the ootb notification, no email will be sent.  

ValorPhase
Tera Contributor

There's a MUCH better way to do this now -- use the Queue Registry!

https://www.servicenow.com/docs/r/platform-administration/system-events/auto-job-scheduling.html

 

This lets you define a queue and set the max number of queues, which can also scale automatically with the number of nodes you have. 

 

For any events you want to use the queue (no need to specify using the 4th argument), specify the queue to use in the Event Registry record for it, and you're done.

Custom Event Queue.png

 

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