Back to index

rabbitmq-server  2.8.4
reliability.py
Go to the documentation of this file.
00001 import base
00002 import stomp
00003 import unittest
00004 import time
00005 
00006 class TestReliability(base.BaseTest):
00007 
00008     def test_send_and_disconnect(self):
00009         ''' Test close socket after send does not lose messages '''
00010         d = "/queue/reliability"
00011         pub_conn = self.create_connection()
00012         try:
00013             msg = "0" * (128)
00014 
00015             count = 10000
00016 
00017             listener = base.WaitableListener()
00018             listener.reset(count)
00019             self.conn.set_listener('', listener)
00020             self.conn.subscribe(destination=d)
00021 
00022             for x in range(0, count):
00023                 pub_conn.send(msg + str(x), destination=d)
00024             time.sleep(2.0)
00025             pub_conn.close_socket()
00026 
00027             if listener.await(30):
00028                 self.assertEquals(count, len(listener.messages))
00029             else:
00030                 listener.print_state("Final state of listener:")
00031                 self.fail("Did not receive %s messages in time" % count)
00032         finally:
00033             if pub_conn.is_connected():
00034                 pub_conn.disconnect()