title: Sending reply message from python script
body: <p>I developed a camel application that has capabilities to communicating to external systems via Active MQ broker and at the moment I am putting together a short presentation to show how it works.</p>
  
  <p>For that I chose python as the external system as it is free, easy to install and had a bit of exposure in the past with some jython scripts.
  What I want to show in my presentation is that  whenever my system sends a message to the external client via a certain queue, that client will get it do some processing and reply back to the “reply-to” queue as specified in the message header.</p>
  
  <p>So I changed a bit one of the python example scripts which come with Active MQ distribution. Here there is my modified script:</p>
  
  <pre><code>import time
  import sys
  import os
  import stomp
  
  user = os.getenv("ACTIVEMQ_USER") or "admin"
  password = os.getenv("ACTIVEMQ_PASSWORD") or "password"
  host = os.getenv("ACTIVEMQ_HOST") or "localhost"
  port = os.getenv("ACTIVEMQ_PORT") or 61613
  destination = sys.argv[1]
  
  class MyListener(stomp.ConnectionListener):
  
    def __init__(self, receiver, sender):
      self.receiver = receiver
      self.sender = sender
      self.count = 0
      self.start = time.time()
  
    def on_error(self, headers, message):
      print('received an error %s' % message)
  
    def on_message(self, headers, message):
      if message == "SHUTDOWN":
  
        diff = time.time() - self.start
        print("Received %s in %f seconds" % (self.count, diff))
        self.receiver.disconnect()
        self.sender.disconnect()
        sys.exit(0)
  
      else:
        if self.count==0:
          self.start = time.time()
  
        self.count += 1
        if self.count % 1000 == 0:
           print("Received %s messages." % self.count)
  
        if 'reply-to' in headers:
          replyTo = headers['reply-to']
          response = '%s Python says: this is very good indeed' % self.count
          self.sender.send(response, destination=replyTo, persistent='false')
  
  sender = stomp.Connection(host_and_ports = [(host, port)])
  sender.start()
  sender.connect(login=user, passcode=password)
  
  receiver = stomp.Connection(host_and_ports = [(host, port)])
  receiver.set_listener('', MyListener(receiver, sender))
  receiver.start()
  receiver.connect(login=user, passcode=password)
  receiver.subscribe(destination=destination, id=1, ack='auto')
  
  print("Waiting for messages...")
  while 1: 
    time.sleep(10)
  </code></pre>
  
  <p>Then from inside my system I send out ten thousand messages.
  If I comment out the sender part I can see in the console output that the python client receives all my messages. However as soon as I am trying to respond back Ia m getting this error message:</p>
  
  <pre><code>TypeError: send() got multiple values for argument 'destination'
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  This is the full stack trace I am getting</p>
  
  <pre><code>Waiting for messages...
  Exception in thread Thread-2:
  Traceback (most recent call last):
    File "D:\Dev\python\lib\threading.py", line 920, in _bootstrap_inner
      self.run()
    File "D:\Dev\python\lib\threading.py", line 868, in run
      self._target(*self._args, **self._kwargs)
    File "D:\Dev\python\lib\site-packages\stomp\transport.py", line 317, in __receiver_loop
      self.process_frame(f, frame)
    File "D:\Dev\python\lib\site-packages\stomp\transport.py", line 166, in process_frame
      self.notify(frame_type, f.headers, f.body)
    File "D:\Dev\python\lib\site-packages\stomp\transport.py", line 227, in notify
      rtn = notify_func(headers, body)
    File "D:/work/cls-message-router/gradle/scripts/listener4.py", line 42, in on_message
      self.sender.send(response, destination=replyTo, persistent='false')
  TypeError: send() got multiple values for argument 'destination'
  </code></pre>
  
  <p>Can you please spot out what I am doing wrong here and how should I fix it.
  My python knowledge is really very limited so a bit of explanations would be very welcome.</p>
  
  <p>Thank you in advance for your inputs.</p>