当前位置: 首页>>代码示例>>Python>>正文


Python Stomp.send方法代码示例

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


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

示例1: test_disconnect_connection_lost_unexpectedly

# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import send [as 别名]
    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,代码行数:27,代码来源:async_client_test.py

示例2: readCSV

# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import send [as 别名]
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,代码行数:32,代码来源:stomp_activemq.py

示例3: test_disconnect_on_stomp_protocol_error

# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import send [as 别名]
    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,代码行数:15,代码来源:async_client_test.py

示例4: run

# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import send [as 别名]
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,代码行数:18,代码来源:publisher.py

示例5: test_not_connected

# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import send [as 别名]
 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,代码行数:10,代码来源:async_client_test.py

示例6: run

# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import send [as 别名]
 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,代码行数:10,代码来源:producer.py

示例7: test_not_connected

# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import send [as 别名]
 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,代码行数:10,代码来源:async_client_test.py

示例8: test_failover_on_connection_lost

# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import send [as 别名]
    def test_failover_on_connection_lost(self):
        ports = tuple(c.getHost().port for c in self.connections)
        config = StompConfig(uri='failover:(tcp://localhost:%d,tcp://localhost:%d)?startupMaxReconnectAttempts=0,initialReconnectDelay=0,randomize=false,maxReconnectAttempts=1' % ports)
        client = Stomp(config)

        yield client.connect()
        self.connections[0].stopListening()
        client.send('/queue/fake', 'shutdown')
        try:
            client = yield client.disconnected
        except StompConnectionError:
            yield client.connect()
        client.send('/queue/fake', 'fake message')

        try:
            yield client.disconnected
        except StompProtocolError:
            pass
开发者ID:irdetoakinavci,项目名称:AMQMessageProducer,代码行数:20,代码来源:async_client_test.py

示例9: test_disconnect_connection_lost_unexpectedly

# 需要导入模块: from stompest import Stomp [as 别名]
# 或者: from stompest.Stomp import send [as 别名]
    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', self._on_message, headers={'id': 4711}, 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:irdetoakinavci,项目名称:AMQMessageProducer,代码行数:23,代码来源:async_client_test.py


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