Exemple #1
0
 def should_raise_nc_when_sending(self):
     mystomp = Stomp('localhost', 99999)
     try:
         mystomp.send({"body": "Vandelay Industries"})
     except stompy.NotConnectedError, err:
         assert True # Should raise not connected
         return
Exemple #2
0
 def setup(self):
     super(WhenConnecting, self).setup()
     self.host = 'localhost'
     self.port = 61613
     self.stomp = Stomp(self.host, self.port)
     self.sock = self.stomp.sock
     self.frame = self.stomp.frame
     self.stomp.connected = True
Exemple #3
0
 def setup(self):
     super(WhenUsingTransactions, self).setup()
     self.host = 'localhost'
     self.port = 61613
     self.stomp = Stomp(self.host, self.port)
     self.frame = self.stomp.frame
     self.sock = self.stomp.sock
     self.stomp.connected = True
     self.headers = {'transaction': 'nose_123'}
Exemple #4
0
 def setup(self):
     super(WhenProducingMessages, self).setup()
     self.host = 'localhost'
     self.port = 61613
     self.stomp = Stomp(self.host, self.port)
     self.frame = self.stomp.frame
     self.sock = self.stomp.sock
     self.stomp.connected = True
     self.headers = {'destination': '/queue/nose_test',
                     'body': 'test'}
Exemple #5
0
 def should_fail_connect_with_timeout(self):
     import socket
     socket.setdefaulttimeout(.5)
     self.stomp = Stomp('10.10.0.0', 99999)
     self.failUnlessRaises(self.stomp.ConnectionTimeoutError,
         self.stomp.connect)
Exemple #6
0
 def should_fail_connect(self):
     self.stomp = Stomp('localhost', 99999)
     self.failUnlessRaises(self.stomp.ConnectionError, self.stomp.connect)
Exemple #7
0
 def should_set_disconnected_even_when_nc(self):
     mystomp = Stomp('localhost', 99999)
     mystomp.disconnect()
     assert not mystomp.connected
Exemple #8
0
 def should_fail_to_send(self):
     mystomp = Stomp('localhost', 99999)
     self.failUnlessRaises(stompy.NotConnectedError, mystomp.send,
                           {"body": "f"})
Exemple #9
0
 def should_set_sub(self):
     mystomp = Stomp('localhost', 99999)
     mystomp._subscribed_to['/queue/nose_test'] = True
     assert mystomp.subscribed is not None
Exemple #10
0
                      help='produce or consume NUMBER messages')

    options, args = parser.parse_args()

    if not options.host:
        print("Host name is required!")
        parser.print_help()
        sys.exit(1)
    if not options.port:
        print("Port is required!")
        parser.print_help()
        sys.exit(1)
    if not options.queue:
        print("Queue name is required!")
        parser.print_help()
        sys.exit(1)

    try:
        stomp = Stomp(options.host, options.port)
        # optional connect keyword args "username" and "password" like so:
        # stomp.connect(username="******", password="******")
        stomp.connect()
    except:
        print("Cannot connect")
        raise

    if options.produce:
        produce(options.queue, options.number)
    elif options.consume:
        consume(options.queue, options.number, options.callback)