title: Combining a RabbitMQ consumer and a Mojolicious websocket server
body: <p>I've got a Mojolicious server inspired by <a href="https://github.com/kraih/mojo/wiki/Writing-websocket-chat-using-Mojolicious-Lite" rel="nofollow noreferrer">this</a> example, and a RabbitMQ consumer inspired by <a href="https://metacpan.org/pod/Net::AMQP::RabbitMQ#EXAMPLES" rel="nofollow noreferrer">this</a> 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.</p>
  
  <p>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?</p>
  
  <p>I'm thinking that the server is checking the rabbitmq queue every 10 seconds, but at the same time accepting websocket connections.</p>
  
  <p>Anyone have some ideas on how to solve this? Some pseudo code or anything would be appreciated. </p>