2

I've got a Mojolicious server inspired by this example, and a RabbitMQ consumer inspired by this example. My plan is to combine them, so that a webclient can access the Mojolicious server and subscribe to some kind of updates. The mojo server will from time to time check a rabbitmq queue, to see if there is some updates, and if it is, it will send the data to the connected websocket clients.

I'm struggling to see how this can be done. Do I put the rabbitmq stuff inside the mojo server stuff, or the other way around. How do I prevent the rabbitmq consume from blocking incoming websocket connections. I guess I have to use a timeout on the consume, but then I might have to run it in a loop which might block the websocket. Or have I misunderstood something? Maybe Mojolicious is not the right library to use?

I'm thinking that the server is checking the rabbitmq queue every 10 seconds, but at the same time accepting websocket connections.

Anyone have some ideas on how to solve this? Some pseudo code or anything would be appreciated.

Orjanp
  • 10,641
  • 12
  • 36
  • 39

0 Answers0