Showing results for 
Search instead for 
Did you mean: 

Pondering Automation: Do you know how to Queue?

Cisco Employee

Howdy out there in Automation land! 2015 has been going for 2.5 months now and I truly apologize for not getting blogs out sooner! I will be publishing this blog and another blog in the next week to catch up. Next blog we will discuss triggers in CPO and all their uses plus some basics around logic in CPO. This time, we cover a more advanced topic around programming and programming structures. We are going to cover queues/stacks and how they can be implemented in CPO and uses to help with the issue of concurrency in programming especially when we make API calls. Let's look at a couple of quick definitions....


Queues - A queue is an advanced data structure which operates on the FIFO or First in First Out idea. Ref:

Stacks - A stack is another advanced data structure which operates on the LIFO or Last In First Out idea.



Obviously those links can give you a lot more detail, but just know the basics for now. I have implemented a basic queue in CPO which you can download and install via TAP @

This is a generic queue which can do the basics. While this is good, we need to attack an issue we can run into with CPO.


What happens when we want to call the same API a ton of times but that API has a limit on concurrent connections or IT limits us or we need to limit ourselves? We need to implement a process queue. Where we can queue processes up for use/connection to the API(or some other system) and then process those.

I like to think of this idea like a bouncer at a party. Imagine a party room where 10 people are allowed in. (these would be our 10 connections to an API) 1 person comes up and the bouncer sees no one in the room, he lets that person into party. No issue. Let's say the room is now full with 10 people. The 11th person comes up and asks the bouncer to go in. The bouncer says "wait and let me look inside". The bouncer looks inside and sees that that room is full, and tells the 11th person, "no you cannot enter, please wait 5 minutes and ask me again". 5 minutes later the person asks again and the bouncer looks into the room. It looks like 2 people have "left" or stopped using the API and there are 2 open spots, so the bouncer lets the 11th person into the room.


But we can run into an issue.... normally a person will stay in and party for a while and then walk out the exit freeing up that space. What happens if the person passes out while at the party? Their space is full and "stuck". We can run into the same situation if we are queuing up processes and allowing them access to the APIs/Systems and one of the processes fails. It can be "stuck" in queue. So in this case, we have another bouncer who waits at the back door. If he hears that someone is stuck or passed out, he looks in and tries to find that person. If he finds them, he removes them, freeing up a space. We can make use of this by using the "Failed Process State" trigger. So if the process fails, we look at the process queue and if the process is still in queue, we remove it.


This is how I wrote and built my process queuing that I use for my API calls. The below VOD explains this idea and how it works, explains my basic queue class, and helps you to develop a stack class. (just as a programming example). This process queuing was built on top of the original CIAC solution for this and then I expanded on it. This VOD is a bit longer than normal, but hey, I figured you, the readers, were worth the extra time since it has been a while since I blogged.


Here is the link for the process queue tap:

Automation Toolkit (which contains Process Queue structure):

Attached to this blog you will find my completed stack class if you do not want to write it yourself!


Now... you have the some taps... ONTO THE VIDEO!




Shaun's Monthly Q/A


No questions this month! Hopefully we'll get some in to answer for next time!



Every month I will pick a handful of questions from you, the reading CPO public, to answer in this part of the blog. Please post comments/questions below. I will no longer be using the external e-mail from previous blogs.


Please also let me know if you like the format of this blog and what else you would like to see/know about. Feel free to give any ideas as to future blog posts, etc and I will be happy to post them. I hope to  do more how-tos, best practices, tips, tricks, and hopefully some interviews of the important people behind the scenes of CPO.



WEEKLY AUTOMATION BLOG DISCLAIMER: As always, this is a blog and my (Shaun Roberts) thoughts on CPO, my thoughts on best practices, and my experiences with the product and customers. The above views are in  no way representative of Cisco or any of it's partners, etc. None  of these views, etc are supported and this is not a place to find standard product support. If you need standard product support  please do so via the current call in numbers on or email



Thanks to all for reading and happy automating!



-Shaun Roberts

CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards