#NEWLINE# def test_reliable_delivery( rabbit_manager , rabbit_config , start_containers ) : #NEWLINE# #INDENT# ' Events sent to queues declared by ``reliable_delivery`` handlers\n    should be received even if no service was listening when they were\n    dispatched.\n    ' #NEWLINE# vhost = rabbit_config [ 'vhost' ] #NEWLINE# ( container , ) = start_containers ( ServicePoolHandler , ( 'service-pool' , ) ) #NEWLINE# queue_name = 'evt-srcservice-eventtype--service-pool.handle' #NEWLINE# queue = rabbit_manager . get_queue ( vhost , rabbit_config ) #NEWLINE# assert ( len ( queue [ 'consumer_details' ] ) == 1 ) #NEWLINE# exchange_name = 'srcservice.events' #NEWLINE# rabbit_manager . publish ( vhost , exchange_name , 'eventtype' , '"msg_1"' , properties = dict ( content_type = 'application/json' ) ) #NEWLINE# with eventlet . timeout . Timeout ( EVENTS_TIMEOUT ) : #NEWLINE# #INDENT# while ( len ( events ) == 0 ) : #NEWLINE# #INDENT# eventlet . sleep ( ) #NEWLINE# #UNINDENT# #UNINDENT# assert ( events == [ 'msg_1' ] ) #NEWLINE# container . stop ( ) #NEWLINE# queues = rabbit_manager . get_queues ( vhost ) #NEWLINE# assert ( queue_name in [ q [ 'name' ] for q in queues ] ) #NEWLINE# queue = rabbit_manager . get_queue ( vhost , queue_name ) #NEWLINE# assert ( len ( queue [ 'consumer_details' ] ) == 0 ) #NEWLINE# rabbit_manager . publish ( vhost , exchange_name , 'eventtype' , '"msg_2"' , properties = dict ( content_type = 'application/json' ) ) #NEWLINE# messages = rabbit_manager . get_messages ( vhost , queue_name , requeue = True ) #NEWLINE# assert ( [ '"msg_2"' ] == [ msg [ 'payload' ] for msg in messages ] ) #NEWLINE# ( container , ) = start_containers ( ServicePoolHandler , ( 'service-pool' , ) ) #NEWLINE# with eventlet . timeout . Timeout ( EVENTS_TIMEOUT ) : #NEWLINE# #INDENT# while ( len ( events ) < 2 ) : #NEWLINE# #INDENT# eventlet . sleep ( ) #NEWLINE# #UNINDENT# #UNINDENT# assert ( len ( events ) == 2 ) #NEWLINE# assert ( events == [ 'msg_1' , 'msg_2' ] ) #NEWLINE# container . stop ( )