How to setup a FIFO queue to send commands

I just want to add that even with your variable, there is nothing at all to guarantee the order of processing of events, particularly if they occur really really close together. OH isn’t a real time system and there are no checks in place to enforce the order. Usually this doesn’t matter because events don’t usually happen that close together, or if they do it doesn’t matter if they get processed out of order.

I’ll also caution you to make very certain that you do not have any errors in your code between the lock and the unlock. Some errors can occur that will not generate an exception that makes it back into the Rule and in those cases your finally will not execute and you lock will not become unlocked.