The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create additional event processors?

xMTinkerer
Giga Expert

Hi fellow developer types!

  I'm in a situation where I have a script action that is taking more time to process than the number of events coming in. This leads to the event queue getting totally backed up as more and more and more stuff comes in but each one takes "long" to process (~20 seconds). So, I'm trying to create 5 different event queues by populating the "Queue" field in the event registry. I did some digging and I think the Script Actions without a queue specified are processed by the "events process" Schedule Item ("sys_trigger" - System Scheduler > Scheduled Jobs... yea, different scheduled jobs than the "other" scheduled jobs").

  This "events process" schedule item has a "Job Context" with something akin to Javascript:

find_real_file.png

I thought I saw on a webex that if you pass a parameter to this for example as gs.eventsProcess( 'my_queue_name' ) it would process the events in the event queue with a queue of 'my_queue_name'. However, that does not seem to be the case. In the new Schedule Item I created, I see it firing the "next action" field, but my events are not being processed

Anyone know how I can get the system to process my events with a queue populated of my choosing?

Thanks!!

    --- Travis

1 ACCEPTED SOLUTION

Hello again,


  I tracked it down. The gs.eventsProcess( 'queue_name' ) wasn't processing the events, but I found another Scheduled Job that was using a different function:



fcScriptName=javascript\:GlideEventManager('queue_name').process();



And this worked great. I'm wondering if the scope of my events had something todo with it. I'm building this inside an app, so my scope is not global. Who knows. Anyway, that works.


View solution in original post

5 REPLIES 5

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Hi Travis,



To have specific events processed by their own events process job you need to do the following:



1. Have a business rule that creates the event in the personalized queue, something like:



gs.eventQueue('my_queue_name', etc, etc, etc);



2. Insert a new record in sys_trigger as a copy of original "events process" job with Job Context having this line modified:



- from:



fcScriptName=javascript\:gs.eventsProcess();



- to:



fcScriptName=javascript\:gs.eventsProcess('my_queue_name');



This will separate those type of events from normal ones and will be processed by the customized events process job.



Hope this helps.



Regards,


Sergiu


Thanks Sergiu! That's kinda what I was thinking, but I'm not seeing my events getting picked up. Is there a way to debug this or see where the mismatch might be?


Hello again,


  I tracked it down. The gs.eventsProcess( 'queue_name' ) wasn't processing the events, but I found another Scheduled Job that was using a different function:



fcScriptName=javascript\:GlideEventManager('queue_name').process();



And this worked great. I'm wondering if the scope of my events had something todo with it. I'm building this inside an app, so my scope is not global. Who knows. Anyway, that works.


What release are you on?



Depending on the release the context can be different. I assumed you were on Fuji.



Regards,


Sergiu