title: Receive a message with RabbitMQ then process it then send back the results
body: <p>I would like to send a message (directly) from a script and than process it, and send back the results.
  So it's like a double publish-subscribe.</p>
  
  <p>I have 2 scripts:</p>
  
  <ul>
  <li>Processer</li>
  <li>Client</li>
  </ul>
  
  <p>The Client sends a message directly (simple string) to the Processer, and than the Processer script counts the characters in the string and sends back the results to the client.</p>
  
  <p><em>This is how I tried to do:</em></p>
  
  <p>The Processer waits for a message, calculates something and than answers back to the original sender.</p>
  
  <pre><code>#Processer.py:
  import pika
  import sys
  
  #Sends back the score
  #addr: Connection address
  #exchName: Exchange name (where to send)
  #rKey: Name of the queue for direct messages
  #score: The detected score
  def SendActualScore(addr, exchName, rKey, score):
      #Send the image thru the created channel with the given routing key (queue name)
      channel.basic_publish(exchange=exchName, routing_key=rKey, body=score)
      print "(*) Sent: " + score
  
  #When we receive something this is called
  def CallbackImg(ch, method, properties, body):
      print "(*) Received: " + str(body)
      score = str(len(body))
      #Send back the score
      SendActualScore('localhost', 'valami', rKey, score)
  
  
  #Subscribe connection
  #Receive messages thru this
  connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
  channel = connection.channel()
  #RECEIVE MESSAGES - Subscribe
  channel.exchange_declare(exchange='valami', type='direct')
  #Define a queue, where we don't need the name
  #After we disconnected delete the queue (exclusive flag)
  result = channel.queue_declare(exclusive=True)
  #We need the name of our temporary queue
  queue_name = result.method.queue
  
  rKeys = sys.argv[1:]
  for rKey in rKeys:
      channel.queue_bind(exchange='valami', queue=queue_name, routing_key = rKey)
  
  channel.basic_consume(CallbackImg, queue=queue_name, no_ack=True)
  print(' [*] Waiting for messages. To exit press CTRL+C')
  channel.start_consuming()
  </code></pre>
  
  <p>The Client just sends the message and than waits for the answer.</p>
  
  <pre><code>#Client.py:
  import pika
  import sys
  
  connAddr = 'localhost'
  
  #Establish connection
  connection = pika.BlockingConnection(pika.ConnectionParameters(connAddr))
  channel = connection.channel()
  
  #Define an exchange channel, we don't need a queue
  channel.exchange_declare(exchange='valami', type='direct')
  
  #Send the image thru the created channel
  channel.basic_publish(exchange='valami', routing_key='msg', body='Message in the body')
  
  print "[*] Sent"
  
  def Callback(ch, method, properties, body):
      print "(*) Received: " + str(body)
  
  result = channel.queue_declare(exclusive=True)
  #We need the name of our temporary queue
  queue_name = result.method.queue
  
  channel.queue_bind(exchange='valami', queue=queue_name)
  
  channel.basic_consume(Callback, queue=queue_name, no_ack=True)
  print(' [*] Waiting for messages. To exit press CTRL+C')
  channel.start_consuming()
  </code></pre>
  
  <p>There could be multiple Clients and I don't know how to send back the messages directly to them.</p>