示例#1
0
    def test_stream_pub_sub(self):
        self.verified = Event()
        self.route = StreamRoute(exchange_point='xp_test', routing_key='route')
        def verify(message, route, stream):
            self.assertEquals(message,'test')
            self.assertEquals(route, self.route)
            self.assertEquals(stream, '')
            self.verified.set()

        sub_proc = SimpleProcess()
        sub_proc.container = self.container

        sub1 = StreamSubscriber(process=sub_proc, exchange_name='sub1', callback=verify)
        sub1.start()
        self.queue_cleanup.append('sub1')


        pub_proc = SimpleProcess()
        pub_proc.container = self.container
        pub1 = StreamPublisher(process=pub_proc,stream_route=self.route)
        sub1.xn.bind(self.route.routing_key,pub1.xp) 

        pub1.publish('test')

        self.assertTrue(self.verified.wait(2))
    def test_stream_pub_sub(self):
        self.verified = Event()
        self.route = StreamRoute(routing_key='stream_name')

        def verify(message, route, stream):
            self.assertEquals(message, 'test')
            self.assertEquals(route.routing_key, self.route.routing_key)
            self.assertTrue(route.exchange_point.startswith(get_sys_name()))
            self.assertEquals(stream, 'stream_name')
            self.verified.set()

        sub_proc = SimpleProcess()
        sub_proc.container = self.container

        sub1 = StreamSubscriber(process=sub_proc, exchange_name='stream_name', callback=verify)
        sub1.add_stream_subscription("stream_name")
        sub1.start()
        self.queue_cleanup.append('data.stream_name')

        pub_proc = SimpleProcess()
        pub_proc.container = self.container

        pub1 = StreamPublisher(process=pub_proc, stream=self.route)
        sub1.xn.bind(self.route.routing_key, pub1.xp)

        pub1.publish('test')

        self.assertTrue(self.verified.wait(2))
示例#3
0
    def test_stream_pub_sub(self):
        self.verified = Event()
        self.route = StreamRoute(exchange_point='xp_test', routing_key='route')

        def verify(message, route, stream):
            self.assertEquals(message, 'test')
            self.assertEquals(route, self.route)
            self.assertEquals(stream, '')
            self.verified.set()

        sub_proc = SimpleProcess()
        sub_proc.container = self.container

        sub1 = StreamSubscriber(process=sub_proc,
                                exchange_name='sub1',
                                callback=verify)
        sub1.start()
        self.queue_cleanup.append('sub1')

        pub_proc = SimpleProcess()
        pub_proc.container = self.container
        pub1 = StreamPublisher(process=pub_proc, stream_route=self.route)
        sub1.xn.bind(self.route.routing_key, pub1.xp)

        pub1.publish('test')

        self.assertTrue(self.verified.wait(2))
示例#4
0
    def test_stream_pub_sub(self):
        self.verified = Event()
        self.route = StreamRoute(routing_key='stream_name')

        def verify(message, route, stream):
            self.assertEquals(message, 'test')
            self.assertEquals(route.routing_key, self.route.routing_key)
            self.assertTrue(route.exchange_point.startswith(get_sys_name()))
            self.assertEquals(stream, 'stream_name')
            self.verified.set()

        sub_proc = SimpleProcess()
        sub_proc.container = self.container

        sub1 = StreamSubscriber(process=sub_proc,
                                exchange_name='stream_name',
                                callback=verify)
        sub1.add_stream_subscription("stream_name")
        sub1.start()
        self.queue_cleanup.append('data.stream_name')

        pub_proc = SimpleProcess()
        pub_proc.container = self.container

        pub1 = StreamPublisher(process=pub_proc, stream=self.route)
        sub1.xn.bind(self.route.routing_key, pub1.xp)

        pub1.publish('test')

        self.assertTrue(self.verified.wait(2))