def __init__(self, conf, context, matchmaker):
        self.conf = conf
        self.context = context
        super(UniversalQueueProxy, self).__init__()
        self.matchmaker = matchmaker
        self.poller = zmq_async.get_poller()

        port = conf.zmq_proxy_opts.frontend_port
        host = conf.zmq_proxy_opts.host
        self.fe_router_socket = zmq_socket.ZmqFixedPortSocket(
            conf, context, zmq.ROUTER, host,
            conf.zmq_proxy_opts.frontend_port) if port != 0 else \
            zmq_socket.ZmqRandomPortSocket(conf, context, zmq.ROUTER, host)

        port = conf.zmq_proxy_opts.backend_port
        self.be_router_socket = zmq_socket.ZmqFixedPortSocket(
            conf, context, zmq.ROUTER, host,
            conf.zmq_proxy_opts.backend_port) if port != 0 else \
            zmq_socket.ZmqRandomPortSocket(conf, context, zmq.ROUTER, host)

        self.poller.register(self.fe_router_socket.handle,
                             self._receive_in_request)
        self.poller.register(self.be_router_socket.handle,
                             self._receive_in_request)

        self.pub_publisher = zmq_publisher_proxy.PublisherProxy(
            conf, matchmaker)

        self._router_updater = RouterUpdater(
            conf, matchmaker, self.pub_publisher.host,
            self.fe_router_socket.connect_address,
            self.be_router_socket.connect_address)
示例#2
0
    def setUp(self):
        super(TestPubSub, self).setUp()

        kwargs = {
            'use_pub_sub': True,
            'rpc_zmq_serialization': self.serialization
        }
        self.config(group='oslo_messaging_zmq', **kwargs)

        self.config(host="127.0.0.1", group="zmq_proxy_opts")
        self.config(publisher_port="0", group="zmq_proxy_opts")

        self.publisher = zmq_publisher_proxy.PublisherProxy(
            self.conf, self.driver.matchmaker)
        self.driver.matchmaker.register_publisher((self.publisher.host, ""))

        self.listeners = []
        for i in range(self.LISTENERS_COUNT):
            self.listeners.append(zmq_common.TestServerListener(self.driver))