Example #1
0
def main():

    conf = cfg.CONF
    opt_group = cfg.OptGroup(name='zmq_proxy_opts',
                             title='ZeroMQ proxy options')
    conf.register_opts(zmq_proxy.zmq_proxy_opts, group=opt_group)
    zmq_options.register_opts(conf)
    zmq_proxy.parse_command_line_args(conf)

    reactor = zmq_proxy.ZmqProxy(conf)

    try:
        while True:
            reactor.run()
    except (KeyboardInterrupt, SystemExit):
        LOG.info(_LI("Exit proxy by interrupt signal."))
    finally:
        reactor.close()
Example #2
0
def main():
    parser = argparse.ArgumentParser(description='ZeroMQ proxy service',
                                     usage=USAGE)

    parser.add_argument('--config-file',
                        dest='config_file',
                        type=str,
                        help='Path to configuration file')

    parser.add_argument('--host',
                        dest='host',
                        type=str,
                        help='Host FQDN for current proxy')
    parser.add_argument('--frontend-port',
                        dest='frontend_port',
                        type=int,
                        help='Front-end ROUTER port number')
    parser.add_argument('--backend-port',
                        dest='backend_port',
                        type=int,
                        help='Back-end ROUTER port number')
    parser.add_argument('--publisher-port',
                        dest='publisher_port',
                        type=int,
                        help='Back-end PUBLISHER port number')

    parser.add_argument('-d',
                        '--debug',
                        dest='debug',
                        type=bool,
                        default=False,
                        help="Turn on DEBUG logging level instead of INFO")

    args = parser.parse_args()

    if args.config_file:
        cfg.CONF(["--config-file", args.config_file])

    log_level = logging.INFO
    if args.debug:
        log_level = logging.DEBUG
    logging.basicConfig(level=log_level,
                        format='%(asctime)s %(name)s '
                        '%(levelname)-8s %(message)s')

    if args.host:
        CONF.zmq_proxy_opts.host = args.host
    if args.frontend_port:
        CONF.set_override('frontend_port',
                          args.frontend_port,
                          group='zmq_proxy_opts')
    if args.backend_port:
        CONF.set_override('backend_port',
                          args.backend_port,
                          group='zmq_proxy_opts')
    if args.publisher_port:
        CONF.set_override('publisher_port',
                          args.publisher_port,
                          group='zmq_proxy_opts')

    reactor = zmq_proxy.ZmqProxy(CONF, zmq_queue_proxy.UniversalQueueProxy)

    try:
        while True:
            reactor.run()
    except (KeyboardInterrupt, SystemExit):
        reactor.close()
Example #3
0
    def setUp(self):
        super(TestZmqAckManager, self).setUp()

        # register and set necessary config opts
        self.messaging_conf.transport_driver = 'zmq'
        zmq_options.register_opts(self.conf)
        kwargs = {
            'rpc_zmq_matchmaker': 'dummy',
            'use_pub_sub': False,
            'use_router_proxy': True,
            'rpc_thread_pool_size': 1,
            'rpc_use_acks': True,
            'rpc_ack_timeout_base': 5,
            'rpc_ack_timeout_multiplier': 1,
            'rpc_retry_attempts': 2
        }
        self.config(group='oslo_messaging_zmq', **kwargs)
        self.conf.register_opts(zmq_proxy.zmq_proxy_opts,
                                group='zmq_proxy_opts')

        # mock set_result method of futures
        self.set_result_patcher = mock.patch.object(
            zmq_receivers.futurist.Future,
            'set_result',
            side_effect=zmq_receivers.futurist.Future.set_result,
            autospec=True)
        self.set_result = self.set_result_patcher.start()

        # mock send method of senders
        self.send_patcher = mock.patch.object(
            zmq_senders.RequestSenderProxy,
            'send',
            side_effect=zmq_senders.RequestSenderProxy.send,
            autospec=True)
        self.send = self.send_patcher.start()

        # get driver
        transport = oslo_messaging.get_transport(self.conf)
        self.driver = transport._driver

        # prepare and launch proxy
        self.proxy = zmq_proxy.ZmqProxy(self.conf)
        vars(self.driver.matchmaker).update(vars(self.proxy.matchmaker))
        self.executor = zmq_async.get_executor(self.proxy.run)
        self.executor.execute()

        # create listener
        self.listener = zmq_common.TestServerListener(self.driver)

        # create target and message
        self.target = oslo_messaging.Target(topic='topic', server='server')
        self.message = {'method': 'xyz', 'args': {'x': 1, 'y': 2, 'z': 3}}

        # start listening to target
        self.listener.listen(self.target)

        # get ack manager
        self.ack_manager = self.driver.client.get().publishers['default']

        self.addCleanup(
            zmq_common.StopRpc(self, [('listener', 'stop'),
                                      ('executor', 'stop'), ('proxy', 'close'),
                                      ('driver', 'cleanup'),
                                      ('send_patcher', 'stop'),
                                      ('set_result_patcher', 'stop')]))

        # wait for all connections to be established
        # and all parties to be ready for messaging
        time.sleep(1)