I need to lock one of the instances to allow scheduling for multiinstances web application
Right now we have two started instances of application. Each has scheduler of work. I need to avoid double run the same process because both of instances send message of the same processing
Don't try and do distributed locking, it's a really hard problem to try and solve.
Instead, just set up your two applications to consume from the same queue and have RabbitMQ round-robin messages between them, and then neither will conflict with the work the other one is doing.