简体   繁体   中英

How to execute local bash script from RabbitMQ?

Greeting all.
How can achieve next:

  1. Publisher (Web client) add a message to the queue.
  2. RabbitMQ must execute bash script with an argument from the queue message
  3. If the bash script was executed successfully then sent acknowledgment to RabbitMQ
  4. After receiving the acknowledgment then RabbitMQ will be executing bash script with an argument from the queue message.
  5. Before getting acknowledgment RabbitMQ will be delaying execute the bash script

Is it possible to achive with RabbitMQ?
Could you get me some advice, please?

Thank very much for your help.

You need to use the system C stdlib call to do this. There's some other relevant SO questions that can help you with this. Try help on this one on executing shell built-ins and this one on system . You can also man system and man execv .

Parse your queue message, craft a char * or string object with the command that needs to execute based on the queue message, and then pass it to system . See this SO question for help on the return code from system if you're not getting it based on the man page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM