Example #1
0
 def __init__(self, done_cb):
   self._done_cb = done_cb
   
   # Connect to AMQP broker with default connection and authentication
   # settings (assumes broker is on localhost)
   self._conn = haigha_Connection(transport='gevent',
                                  close_cb=self._connection_closed_cb,
                                  logger=logging.getLogger())
   
   # Start message pump
   self._message_pump_greenlet = gevent.spawn(self._message_pump_greenthread)
   
   # Create message channel
   self._channel = self._conn.channel()
   self._channel.add_close_listener(self._channel_closed_cb)
   
   # Create and configure message exchange and queue
   self._channel.exchange.declare('test_exchange', 'direct')
   self._channel.queue.declare('test_queue', auto_delete=True)
   self._channel.queue.bind('test_queue', 'test_exchange', 'test_routing_key')
   self._channel.basic.consume(queue='test_queue',
                               consumer=self._handle_incoming_messages)
   
   # Publish a message on the channel
   msg = Message('body', application_headers={'hello':'world'})
   print "Publising message: %s" % (msg,)
   self._channel.basic.publish(msg, 'test_exchange', 'test_routing_key')
   return
Example #2
0
  def __init__(self, participant, done_cb):
    self._done_cb = done_cb
    self.participant = participant
    self.participant._runtime = self

    # Connect to AMQP broker with default connection and authentication
    # settings (assumes broker is on localhost)
    self._conn = haigha_Connection(transport='gevent',
                                   close_cb=self._connection_closed_cb,
                                   logger=logging.getLogger())

    # Start message pump
    self._message_pump_greenlet = gevent.spawn(self._message_pump_greenthread)

    # Create message channel
    self._channel = self._conn.channel()
    self._channel.add_close_listener(self._channel_closed_cb)

    sendParticipantDefinition(self._channel, self.participant.definition)

    # Create and configure message exchange and queue
    for p in self.participant.definition['inports']:
      setupQueue(self.participant, self._channel, 'in', p)
    for p in self.participant.definition['outports']:
      setupQueue(self.participant, self._channel, 'out', p)
Example #3
0
    def __init__(self, participant, done_cb):
        self._done_cb = done_cb
        self.participant = participant
        self.participant._runtime = self

        # Connect to AMQP broker with default connection and authentication
        # settings (assumes broker is on localhost)
        self._conn = haigha_Connection(transport='gevent',
                                       close_cb=self._connection_closed_cb,
                                       logger=logging.getLogger())

        # Start message pump
        self._message_pump_greenlet = gevent.spawn(
            self._message_pump_greenthread)

        # Create message channel
        self._channel = self._conn.channel()
        self._channel.add_close_listener(self._channel_closed_cb)

        sendParticipantDefinition(self._channel, self.participant.definition)

        # Create and configure message exchange and queue
        for p in self.participant.definition['inports']:
            setupQueue(self.participant, self._channel, 'in', p)
        for p in self.participant.definition['outports']:
            setupQueue(self.participant, self._channel, 'out', p)
Example #4
0
    def __init__(self, broker, discovery_period=None):
        Engine.__init__(self, broker, discovery_period=discovery_period)

        if isinstance(haigha, Exception):
            raise haigha

        self.participant = None

        # Prepare connection to AMQP broker
        vhost = '/'
        if self.broker_info.path:
            vhost = self.broker_info.path[1:]
        host = self.broker_info.hostname or 'localhost'
        port = self.broker_info.port or 5672
        user = self.broker_info.username or 'guest'
        password = self.broker_info.password or 'guest'
        logger.debug("Using %s:%d %s %s:%s" %
                     (host, port, vhost, user, password))
        self._conn = haigha_Connection(transport='gevent',
                                       close_cb=self._connection_closed_cb,
                                       host=host,
                                       vhost=vhost,
                                       port=port,
                                       user=user,
                                       password=password,
                                       logger=logger)

        # Create message channel
        self._channel = self._conn.channel()
        self._channel.add_close_listener(self._channel_closed_cb)
Example #5
0
 def __init__(self, done_cb):
   self._done_cb = done_cb
   
   # Connect to AMQP broker with default connection and authentication
   # settings (assumes broker is on localhost)
   self._conn = haigha_Connection(
                                  host=r.rmq['hostname'], port=r.rmq['port'],
                                  user=r.rmq['user'], password=r.rmq['pass'],
                                  transport='gevent',
                                  close_cb=self._connection_closed_cb,
                                  logger=logging.getLogger())
   
   # Start message pump
   self._message_pump_greenlet = gevent.spawn(self._message_pump_greenthread)
   
   # Create message channel
   self._channel = self._conn.channel()
   self._channel.add_close_listener(self._channel_closed_cb)
   
   # Create and configure message exchange and queue
   self._channel.exchange.declare('test_exchange', 'direct')
   self._channel.queue.declare('test_queue', auto_delete=True)
   self._channel.queue.bind('test_queue', 'test_exchange', 'test_routing_key')
   self._channel.basic.consume(queue='test_queue',
                               consumer=self._handle_incoming_messages)
   
   # Publish a message on the channel
   msg = Message('body', application_body='XKRX-CS-KR-000100,07:18:08.987349,0,256.43,24.74,50.67,144.84,36.19')
   print "Publising message: %s" % (msg,)
   self._channel.basic.publish(msg, 'test_exchange', 'test_routing_key')
   return
Example #6
0
    def __init__(self, done_cb):
        self._done_cb = done_cb

        # Connect to AMQP broker with default connection and authentication
        # settings (assumes broker is on localhost)
        self._conn = haigha_Connection(host=r.rmq['hostname'],
                                       port=r.rmq['port'],
                                       user=r.rmq['user'],
                                       password=r.rmq['pass'],
                                       transport='gevent',
                                       close_cb=self._connection_closed_cb,
                                       logger=logging.getLogger())

        # Start message pump
        self._message_pump_greenlet = gevent.spawn(
            self._message_pump_greenthread)

        # Create message channel
        self._channel = self._conn.channel()
        self._channel.add_close_listener(self._channel_closed_cb)

        # Create and configure message exchange and queue
        self._channel.exchange.declare('test_exchange', 'direct')
        self._channel.queue.declare('test_queue', auto_delete=True)
        self._channel.queue.bind('test_queue', 'test_exchange',
                                 'test_routing_key')
        self._channel.basic.consume(queue='test_queue',
                                    consumer=self._handle_incoming_messages)

        # Publish a message on the channel
        msg = Message(
            'body',
            application_body=
            'XKRX-CS-KR-000100,07:18:08.987349,0,256.43,24.74,50.67,144.84,36.19'
        )
        print "Publising message: %s" % (msg, )
        self._channel.basic.publish(msg, 'test_exchange', 'test_routing_key')
        return