• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python stompest.Stomp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stompest.Stomp的典型用法代码示例。如果您正苦于以下问题:Python Stomp类的具体用法?Python Stomp怎么用?Python Stomp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Stomp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: readCSV

def readCSV():
    config = StompConfig('tcp://%s:%d' % (host, port), login=user, passcode=password, version='1.1')
    client = Stomp(config)
    yield client.connect(host='mybroker')

    count = 0
    start = time.time()

    with open(desiredCSV, 'r') as readFile:
        csv_reader = csv.reader(readFile)
        for row in csv_reader:
            if row[4] != 'C' and row[4] != 'G':

                try:
                    cursor.execute(sql.SQL("insert into {} values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)").format(sql.Identifier('getactivemq')), row)
                    db_conn.commit()
                except:
                    print "cannot insert into table"

            elif row[4] == 'C' or row[4] == 'G':
                rowDictionary = {"rowData" : row}
                jsonData = json.dumps(rowDictionary)
                client.send(destination='atcg', body=jsonData, headers={'persistent': 'false'})

            else:
                print 'Error reading 5th column'
    diff = time.time() - start
    print 'Sent %s frames in %f seconds' % (count, diff)

    yield client.disconnect(receipt='bye')
开发者ID:emmanuelstroem,项目名称:getactivemq,代码行数:30,代码来源:stomp_activemq.py


示例2: run

 def run(self):
     config = StompConfig('tcp://%s:%d' % (host, port), login=user, passcode=password, version='1.1')
     client = Stomp(config)
     yield client.connect(host='mybroker')
     
     self.count = 0
     self.start = time.time()
     client.subscribe(destination, self.handleFrame, headers={'ack': 'auto', 'id': 'required-for-STOMP-1.1'}, ack=False)
开发者ID:AlexAdamenko,项目名称:SWATask3,代码行数:8,代码来源:listener.py


示例3: test_not_connected

 def test_not_connected(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri='tcp://localhost:%d' % port)
     client = Stomp(config)
     try:
         yield client.send('/queue/fake')
     except (StompConnectionError, AlreadyCancelled):
         pass
开发者ID:IngoScholtes,项目名称:stompest,代码行数:8,代码来源:async_client_test.py


示例4: test_not_connected

 def test_not_connected(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri="tcp://localhost:%d" % port)
     client = Stomp(config)
     try:
         yield client.send("/queue/fake")
     except StompConnectionError:
         pass
开发者ID:hhamalai,项目名称:stompest,代码行数:8,代码来源:async_client_test.py


示例5: test_connection_timeout_after_failover

 def test_connection_timeout_after_failover(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri='failover:(tcp://nosuchhost:65535,tcp://localhost:%d)?startupMaxReconnectAttempts=2,initialReconnectDelay=0,randomize=false' % port)
     client = Stomp(config)
     try:
         yield client.connect(connectTimeout=self.TIMEOUT, connectedTimeout=self.TIMEOUT)
     except StompConnectTimeout:
         pass
     else:
         raise
开发者ID:iandriyanov,项目名称:stompest,代码行数:10,代码来源:async_client_test.py


示例6: test_stomp_protocol_error_on_connect

 def test_stomp_protocol_error_on_connect(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri='tcp://localhost:%d' % port)
     client = Stomp(config)
     try:
         yield client.connect()
     except StompProtocolError:
         pass
     else:
         raise Exception('Expected a StompProtocolError, but nothing was raised.')
开发者ID:nikipore,项目名称:stompest,代码行数:10,代码来源:async_client_test.py


示例7: test_not_connected

 def test_not_connected(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri='tcp://localhost:%d' % port)
     client = Stomp(config)
     try:
         yield client.send('/queue/fake')
     except StompConnectionError:
         pass
     else:
         raise Exception('Expected connection error, but nothing frame could be sent.')
开发者ID:nikipore,项目名称:stompest,代码行数:10,代码来源:async_client_test.py


示例8: test_connected_timeout

 def test_connected_timeout(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri='tcp://localhost:%d' % port)
     client = Stomp(config)
     try:
         yield client.connect(connectedTimeout=self.TIMEOUT)
     except StompCancelledError:
         pass
     else:
         raise Exception('Expected connected timeout, but connection was established.')
开发者ID:nikipore,项目名称:stompest,代码行数:10,代码来源:async_client_test.py


示例9: test_connection_timeout

 def test_connection_timeout(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri="tcp://localhost:%d" % port)
     client = Stomp(config)
     try:
         yield client.connect(connectTimeout=self.TIMEOUT, connectedTimeout=self.TIMEOUT)
     except StompConnectTimeout:
         pass
     else:
         raise
开发者ID:hhamalai,项目名称:stompest,代码行数:10,代码来源:async_client_test.py


示例10: test_stomp_protocol_error_on_connect

 def test_stomp_protocol_error_on_connect(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri="tcp://localhost:%d" % port)
     client = Stomp(config)
     try:
         yield client.connect()
     except StompProtocolError:
         pass
     else:
         raise
开发者ID:hhamalai,项目名称:stompest,代码行数:10,代码来源:async_client_test.py


示例11: run

 def run(self):
     client = Stomp(self.config)
     yield client.connect()
     headers = {
         # client-individual mode is necessary for concurrent processing
         # (requires ActiveMQ >= 5.2)
         StompSpec.ACK_HEADER: StompSpec.ACK_CLIENT_INDIVIDUAL,
         # the maximal number of messages the broker will let you work on at the same time
         'activemq.prefetchSize': '100',
     }
     client.subscribe(self.QUEUE, headers, listener=SubscriptionListener(self.consume, errorDestination=self.ERROR_QUEUE))
开发者ID:nikipore,项目名称:stompest,代码行数:11,代码来源:consumer.py


示例12: test_disconnect_on_stomp_protocol_error

    def test_disconnect_on_stomp_protocol_error(self):
        port = self.connections[0].getHost().port
        config = StompConfig(uri="tcp://localhost:%d" % port)
        client = Stomp(config)

        yield client.connect()
        client.send("/queue/fake", "fake message")
        try:
            yield client.disconnected
        except StompProtocolError:
            pass
        else:
            raise
开发者ID:hhamalai,项目名称:stompest,代码行数:13,代码来源:async_client_test.py


示例13: test_disconnect_on_stomp_protocol_error

    def test_disconnect_on_stomp_protocol_error(self):
        port = self.connections[0].getHost().port
        config = StompConfig(uri='tcp://localhost:%d' % port)
        client = Stomp(config)

        yield client.connect()
        client.send('/queue/fake', b'fake message')
        try:
            yield client.disconnected
        except StompProtocolError as e:
            self.assertTrue(isinstance(e.frame, StompFrame))
        else:
            raise Exception('Expected a StompProtocolError, but nothing was raised.')
开发者ID:nikipore,项目名称:stompest,代码行数:13,代码来源:async_client_test.py


示例14: test_replay_after_failover

    def test_replay_after_failover(self):
        ports = tuple(c.getHost().port for c in self.connections)
        config = StompConfig(uri='failover:(tcp://localhost:%d)?startupMaxReconnectAttempts=0,initialReconnectDelay=0,maxReconnectAttempts=1' % ports)
        client = Stomp(config)
        try:
            client.subscribe('/queue/bla', self._on_message) # client is not connected, so it won't accept subscriptions
        except StompConnectionError:
            pass
        else:
            raise

        self.assertEquals(client.session._subscriptions, {}) # check that no subscriptions have been accepted
        yield client.connect()

        self.shutdown = True # the callback handler will kill the broker connection ... 
        client.subscribe('/queue/bla', self._on_message)
        try:
            client = yield client.disconnected # the callback handler has killed the broker connection
        except StompConnectionError:
            pass
        else:
            raise

        self.shutdown = False # the callback handler will not kill the broker connection, but callback self._got_message
        self._got_message = defer.Deferred()

        yield client.connect()
        self.assertNotEquals(client.session._subscriptions, []) # the subscriptions have been replayed ...

        result = yield self._got_message
        self.assertEquals(result, None) # ... and the message comes back

        yield client.disconnect()
        self.assertEquals(list(client.session.replay()), []) # after a clean disconnect, the subscriptions are forgotten.
开发者ID:irdetoakinavci,项目名称:AMQMessageProducer,代码行数:34,代码来源:async_client_test.py


示例15: test_disconnect_timeout

 def test_disconnect_timeout(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri='tcp://localhost:%d' % port, version='1.1')
     client = Stomp(config)
     yield client.connect()
     self._got_message = defer.Deferred()
     client.subscribe('/queue/bla', self._on_message, headers={'id': 4711}, ack=False) # we're acking the frames ourselves
     yield self._got_message
     try:
         yield client.disconnect(timeout=0.02)
     except StompCancelledError:
         pass
     else:
         raise
     self.wait.callback(None)
开发者ID:irdetoakinavci,项目名称:AMQMessageProducer,代码行数:15,代码来源:async_client_test.py


示例16: run

def run():
    config = StompConfig('tcp://%s:%d' % (host, port), login=user, passcode=password, version='1.1')
    client = Stomp(config)
    yield client.connect(host='mybroker')

    count = 0
    start = time.time()
    
    for _ in xrange(messages):
        client.send(destination=destination, body=data, headers={'persistent': 'false'})
        count += 1

    diff = time.time() - start
    print 'Sent %s frames in %f seconds' % (count, diff)
  
    yield client.disconnect(receipt='bye')
开发者ID:developercyrus,项目名称:jta-jms-atomikos-snippets,代码行数:16,代码来源:publisher.py


示例17: test_disconnect_timeout

 def test_disconnect_timeout(self):
     port = self.connections[0].getHost().port
     config = StompConfig(uri='tcp://localhost:%d' % port, version='1.1')
     client = Stomp(config)
     yield client.connect()
     self._got_message = defer.Deferred()
     client.subscribe('/queue/bla', headers={StompSpec.ID_HEADER: 4711}, listener=SubscriptionListener(self._on_message, ack=False)) # we're acking the frames ourselves
     yield self._got_message
     yield client.disconnect(timeout=0.02)
     try:
         yield client.disconnected
     except StompConnectionError:
         pass
     else:
         raise
     self.wait.callback(None)
开发者ID:IngoScholtes,项目名称:stompest,代码行数:16,代码来源:async_client_test.py


示例18: test_multi_subscriptions

    def test_multi_subscriptions(self):
        port = self.connections[0].getHost().port
        config = StompConfig(uri="tcp://localhost:%d" % port)
        client = Stomp(config)
        yield client.connect()

        listeners = []
        for j in range(2):
            listener = SubscriptionListener(self._on_message)
            yield client.subscribe("/queue/%d" % j, headers={"bla": j}, listener=listener)
            listeners.append(listener)

        for (j, listener) in enumerate(listeners):
            self.assertEquals(listener._headers["bla"], j)

        yield client.disconnect()
        yield client.disconnected
开发者ID:hhamalai,项目名称:stompest,代码行数:17,代码来源:async_client_test.py


示例19: run

 def run(self, _):
     client = Stomp(self.config)
     yield client.connect()
     client.add(ReceiptListener(1.0))
     for j in range(10):
         yield client.send(self.QUEUE, json.dumps({'count': j}).encode(), receipt='message-%d' % j)
     client.disconnect(receipt='bye')
     yield client.disconnected # graceful disconnect: waits until all receipts have arrived
开发者ID:nikipore,项目名称:stompest,代码行数:8,代码来源:producer.py


示例20: test_disconnect_connection_lost_unexpectedly

    def test_disconnect_connection_lost_unexpectedly(self):
        port = self.connections[0].getHost().port
        config = StompConfig(uri="tcp://localhost:%d" % port, version="1.1")
        client = Stomp(config)

        yield client.connect()

        self._got_message = defer.Deferred()
        client.subscribe(
            "/queue/bla",
            headers={StompSpec.ID_HEADER: 4711},
            listener=SubscriptionListener(self._on_message, ack=False),
        )  # we're acking the frames ourselves
        yield self._got_message

        disconnected = client.disconnected
        client.send("/queue/fake", "shutdown")  # tell the broker to drop the connection
        try:
            yield disconnected
        except StompConnectionError:
            pass
        else:
            raise

        self.wait.callback(None)
开发者ID:hhamalai,项目名称:stompest,代码行数:25,代码来源:async_client_test.py



注:本文中的stompest.Stomp类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python protocol.StompParser类代码示例发布时间:2022-05-27
下一篇:
Python utils.merge_headers函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap