示例#1
0
    def __init__(self):
        self.hub = MokshaHub()
        self.log = log

        # If the stream specifies an 'app', then setup `self.engine` to
        # be a SQLAlchemy engine for that app, along with a configured DBSession
        app = getattr(self, "app", None)
        self.engine = self.DBSession = None
        if app:
            self.engine = create_app_engine(app)
            self.DBSession = sessionmaker(bind=self.engine)()
示例#2
0
    def __init__(self):
        self.hub = MokshaHub()
        self.log = log

        # If the stream specifies an 'app', then setup `self.engine` to
        # be a SQLAlchemy engine for that app, along with a configured DBSession
        app = getattr(self, 'app', None)
        self.engine = self.DBSession = None
        if app:
            self.engine = create_app_engine(app)
            self.DBSession = sessionmaker(bind=self.engine)()
示例#3
0
    def __init__(self):
        self.hub = MokshaHub()
        self.log = log
        if self.hub.amqp_broker and not self.hub.stomp_broker:
            for topic in listify(self.topic):
                log.debug('Subscribing to consumer topic %s' % topic)

                if isinstance(self.hub, AMQPLibHub):
                    # AMQPLibHub specific
                    queue_name = str(uuid.uuid4())
                    self.hub.queue_declare(queue=queue_name, exclusive=True)
                    self.hub.exchange_bind(queue_name, binding_key=topic)
                    if self.jsonify:
                        self.hub.queue_subscribe(queue_name,
                                                 self._consume_json)
                    else:
                        self.hub.queue_subscribe(queue_name, self._consume)
                else:
                    # Assume we're using Qpid then.
                    server_queue_name = 'moksha_consumer_' + self.hub.session.name
                    self.hub.queue_declare(queue=server_queue_name,
                                           exclusive=True)
                    self.hub.exchange_bind(server_queue_name,
                                           binding_key=topic)
                    local_queue_name = 'moksha_consumer_' + self.hub.session.name
                    self.hub.local_queue = self.hub.session.incoming(
                        local_queue_name)
                    self.hub.message_subscribe(queue=server_queue_name,
                                               destination=local_queue_name)
                    self.hub.local_queue.start()
                    if self.jsonify:
                        self.hub.local_queue.listen(self._consume_json)
                    else:
                        self.hub.local_queue.listen(self._consume)

        # If the consumer specifies an 'app', then setup `self.engine` to
        # be a SQLAlchemy engine, along with a configured DBSession
        app = getattr(self, 'app', None)
        self.engine = self.DBSession = None
        if app:
            log.debug("Setting up individual engine for consumer")
            self.engine = create_app_engine(app)
            self.DBSession = sessionmaker(bind=self.engine)()
示例#4
0
    def __init__(self):
        self.hub = MokshaHub()
        self.log = log
        if self.hub.amqp_broker and not self.hub.stomp_broker:
            for topic in listify(self.topic):
                log.debug('Subscribing to consumer topic %s' % topic)

                if isinstance(self.hub, AMQPLibHub):
                    # AMQPLibHub specific 
                    queue_name = str(uuid.uuid4())
                    self.hub.queue_declare(queue=queue_name, exclusive=True)
                    self.hub.exchange_bind(queue_name, binding_key=topic)
                    if self.jsonify:
                        self.hub.queue_subscribe(queue_name, self._consume_json)
                    else:
                        self.hub.queue_subscribe(queue_name, self._consume)
                else:
                    # Assume we're using Qpid then.
                    server_queue_name = 'moksha_consumer_' + self.hub.session.name
                    self.hub.queue_declare(queue=server_queue_name, exclusive=True)
                    self.hub.exchange_bind(server_queue_name, binding_key=topic)
                    local_queue_name = 'moksha_consumer_' + self.hub.session.name
                    self.hub.local_queue = self.hub.session.incoming(local_queue_name)
                    self.hub.message_subscribe(queue=server_queue_name,
                                           destination=local_queue_name)
                    self.hub.local_queue.start()
                    if self.jsonify:
                        self.hub.local_queue.listen(self._consume_json)
                    else:
                        self.hub.local_queue.listen(self._consume)

        # If the consumer specifies an 'app', then setup `self.engine` to
        # be a SQLAlchemy engine, along with a configured DBSession
        app = getattr(self, 'app', None)
        self.engine = self.DBSession = None
        if app:
            log.debug("Setting up individual engine for consumer")
            self.engine = create_app_engine(app)
            self.DBSession = sessionmaker(bind=self.engine)()