question

Nivedita Ravi avatar image
0 Likes"
Nivedita Ravi asked Nivedita Ravi commented

How do I pick a queue at random to create items in?

I have a running model with 20 queues. My input to my model is a table that tells 1) time in secs 2) number of items to create 3) labels to attach to the items. I want to randomly assign each of the 20 queues for the item creation for every 100 - 120 items. For example, the first 100 items were created in queue1, next 100 items have to be created in queue 18, next 100 items in queue 11 and so on.

Choose One
create objectassign labels
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Mischa Spelt avatar image
0 Likes"
Mischa Spelt answered Nivedita Ravi commented

You could use the On Exit trigger to re-evaluate the output port every 100 to 120 items. Here is an example with a Source - which I would use anyway because it allows you to put the table that you describe directly on the source without manually creating any flow items.

See the attached demo model. In the On Reset trigger I sample an initial value of Port and Remaining. Then in the On Exit trigger I decrease the Remaing label and if it reaches zero, sample two new values for Port and Remaining.

In the Send To Port field on the Flow Tab, I use the Port label to decide where to send my items to.

selectrandomportbybatch.fsm


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Nivedita Ravi avatar image Nivedita Ravi commented ·

This was really helpful. Could you explain to me why Port is set to 6 and Remaining is set to 108 specifically ? is 108 the remaining items that will be sent to a queue before you switch ?

Thank you,

Nivedita

0 Likes 0 ·
Jeff Nordgren avatar image
0 Likes"
Jeff Nordgren answered
@Nivedita Ravi

Without seeing your model, it's a bit hard to give a specific answer so here is a general one. Each time you go to create flowitems you could do a duniform(1,20) distribution. Then in an "if" or "switch" statement, you could create the flowitems in the correct queue by sending that queue a message with the item to be created and the number to create (drop down menu option).

If you need something more specific you could either send us your model or a sample model and we could show you how to do it.

Thanks.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.