title: RabbitMQ for passing messages between web aplication and twisted backend server
body: <p>I have a php web application and twisted backend server, thus for communication between two of these I am using RabbitMQ where web application is producer while twisted server is consumer. Following is my code for twisted server.</p>
  
  <pre><code>def rabbitMQConsumer():
      connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
      channel = connection.channel()
      channel.queue_declare(queue='hello')
      print ' [*] Waiting for messages. To exit press CTRL+C'
      def callback(ch, method, properties, body):
          print " [x] Received %r" % (body,)
  
      channel.basic_consume(callback, queue='hello', no_ack=True)
      channel.start_consuming()
  
  
  class Echo(LineReceiver):
      def connectionMade(self):
          self.factory.clients.append(self)
          self.setRawMode()
          self._peer = self.transport.getPeer()
          logging.info('Connected Client %s' %self._peer)
          print 'Connected Client', self._peer
  
      def connectionLost(self, reason):
          self.factory.clients.remove(self)
          logging.info('Lost connection from %s' %self._peer)
          print 'Lost connection from', self._peer
  
      def rawDataReceived(self, data):
          inputArray = ["%02X"%ord(inp) for inp in data]
          logging.info('Packet received from %s client : %s'%(self._peer,''.join(inputArray)))
  
  
  t = Thread(target=rabbitMQConsumer)
  t.daemon = True
  t.start()
  </code></pre>
  
  <p>I am able to pass messages between web application and twisted server but my problem is that whenever twisted server receives messages from web application I want to forward that message to a particular client connected to server. Whenever callback function is called server sends message to a particular client. How can I solve my problem?</p>