本文整理汇总了Python中proton.utils.BlockingConnection.create_receiver方法的典型用法代码示例。如果您正苦于以下问题:Python BlockingConnection.create_receiver方法的具体用法?Python BlockingConnection.create_receiver怎么用?Python BlockingConnection.create_receiver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类proton.utils.BlockingConnection
的用法示例。
在下文中一共展示了BlockingConnection.create_receiver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_verify_n_receivers
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_verify_n_receivers(self):
n = 4
addr = self.address()
# connection should be ok
denied = False
try:
br1 = BlockingConnection(addr)
except ConnectionException:
denied = True
self.assertFalse(denied) # assert if connections that should open did not open
# n receivers OK
try:
r1 = br1.create_receiver(address="****YES_1of4***")
r2 = br1.create_receiver(address="****YES_20f4****")
r3 = br1.create_receiver(address="****YES_3of4****")
r4 = br1.create_receiver(address="****YES_4of4****")
except Exception:
denied = True
self.assertFalse(denied) # n receivers should have worked
# receiver n+1 should be denied
try:
r5 = br1.create_receiver("****NO****")
except Exception:
denied = True
self.assertTrue(denied) # receiver n+1 should have failed
br1.close()
示例2: test_max_sessions
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_max_sessions(self):
# Set up a connection to get the Open and a receiver to get a Begin frame in the log
bc = BlockingConnection(self.router.addresses[0])
bc.create_receiver("xxx")
bc.close()
with open('../setUpClass/MaxSessions.log', 'r') as router_log:
log_lines = router_log.read().split("\n")
open_lines = [s for s in log_lines if "-> @open" in s]
# channel-max is 10
self.assertTrue(" channel-max=9" in open_lines[0])
示例3: test_max_frame_default
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_max_frame_default(self):
# Set up a connection to get the Open and a receiver to get a Begin frame in the log
bc = BlockingConnection(self.router.addresses[0])
bc.create_receiver("xxx")
bc.close()
with open('../setUpClass/MaxFrameDefault.log', 'r') as router_log:
log_lines = router_log.read().split("\n")
open_lines = [s for s in log_lines if "-> @open" in s]
# if frame size not set then a default is used
self.assertTrue(" max-frame-size=16384" in open_lines[0])
示例4: test_max_frame_small
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_max_frame_small(self):
# Set up a connection to get the Open and a receiver to get a Begin frame in the log
bc = BlockingConnection(self.router.addresses[0])
bc.create_receiver("xxx")
bc.close()
with open('../setUpClass/MaxFrameSmall.log', 'r') as router_log:
log_lines = router_log.read().split("\n")
open_lines = [s for s in log_lines if "-> @open" in s]
# if frame size <= 512 proton set min of 512
self.assertTrue(" max-frame-size=512" in open_lines[0])
示例5: test_max_frame_max_session_zero
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_max_frame_max_session_zero(self):
# Set up a connection to get the Open and a receiver to get a Begin frame in the log
bc = BlockingConnection(self.router.addresses[0])
bc.create_receiver("xxx")
bc.close()
with open('../setUpClass/MaxFrameMaxSessionFramesZero.log', 'r') as router_log:
log_lines = router_log.read().split("\n")
open_lines = [s for s in log_lines if "-> @open" in s]
# max-frame gets set to protocol min
self.assertTrue(' max-frame-size=512,' in open_lines[0])
begin_lines = [s for s in log_lines if "-> @begin" in s]
# incoming-window is defaulted to 2^31-1
self.assertTrue(" incoming-window=2147483647," in begin_lines[0])
示例6: test_max_session_frames_default
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_max_session_frames_default(self):
# Set up a connection to get the Open and a receiver to get a Begin frame in the log
if skip_test:
return self.skipTest("Test skipped on non-64 bit architectures")
bc = BlockingConnection(self.router.addresses[0])
bc.create_receiver("xxx")
bc.close()
with open('../setUpClass/MaxSessionFramesDefault.log', 'r') as router_log:
log_lines = router_log.read().split("\n")
open_lines = [s for s in log_lines if "-> @open" in s]
# if frame size not set then a default is used
self.assertTrue(" max-frame-size=16384" in open_lines[0])
begin_lines = [s for s in log_lines if "-> @begin" in s]
# incoming-window is from the config
self.assertTrue(" incoming-window=2147483647," in begin_lines[0])
示例7: test_custom_annotations_match
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_custom_annotations_match(self):
"""
The linkRoute on Routers C and B is set to org.apache.
Creates a receiver listening on the address 'org.apache' and a sender that sends to address 'org.apache'.
Sends a message with custom annotations to org.apache via router QDR.C and makes sure that the message was successfully
routed (using full address matching) and received using pre-created links that were created as a
result of specifying addresses in the linkRoute attribute('org.apache.'). Make sure custom annotations arrived as well.
"""
hello_world_3 = "Hello World_3!"
# Connects to listener #2 on QDR.C
addr = self.routers[2].addresses[0]
blocking_connection = BlockingConnection(addr)
# Receive on org.apache
blocking_receiver = blocking_connection.create_receiver(address="org.apache")
apply_options = AtMostOnce()
# Sender to to org.apache
blocking_sender = blocking_connection.create_sender(address="org.apache", options=apply_options)
msg = Message(body=hello_world_3)
annotations = {'custom-annotation': '1/Custom_Annotation'}
msg.annotations = annotations
# Send a message
blocking_sender.send(msg)
received_message = blocking_receiver.receive()
self.assertEqual(hello_world_3, received_message.body)
self.assertEqual(received_message.annotations, annotations)
blocking_connection.close()
示例8: test_max_frame_max_session_frames__max_sessions_default
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_max_frame_max_session_frames__max_sessions_default(self):
# Set up a connection to get the Open and a receiver to get a Begin frame in the log
bc = BlockingConnection(self.router.addresses[0])
bc.create_receiver("xxx")
bc.close()
with open('../setUpClass/MaxFrameMaxSessionFrames.log', 'r') as router_log:
log_lines = router_log.read().split("\n")
open_lines = [s for s in log_lines if "-> @open" in s]
# max-frame is from the config
self.assertTrue(' max-frame-size=2048,' in open_lines[0])
# channel-max is default
self.assertTrue(" channel-max=32767" in open_lines[0])
begin_lines = [s for s in log_lines if "-> @begin" in s]
# incoming-window is from the config
self.assertTrue(" incoming-window=10," in begin_lines[0] )
示例9: test_max_frame_max_session_too_big
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_max_frame_max_session_too_big(self):
# Set up a connection to get the Open and a receiver to get a Begin frame in the log
bc = BlockingConnection(self.router.addresses[0])
bc.create_receiver("xxx")
bc.close()
with open('../setUpClass/MaxFrameMaxSessionFramesTooBig.log', 'r') as router_log:
log_lines = router_log.read().split("\n")
open_lines = [s for s in log_lines if "-> @open" in s]
# max-frame is from the config
self.assertTrue(' max-frame-size=1000000,' in open_lines[0])
begin_lines = [s for s in log_lines if "-> @begin" in s]
# incoming-window is truncated
self.assertTrue(" incoming-window=2147," in begin_lines[0])
warning_lines = [s for s in log_lines if "requested maxSessionFrames truncated from 5000000 to 2147" in s]
self.assertTrue(len(warning_lines) == 1)
示例10: run
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def run(self):
try:
ssl = SSLDomain(SSLDomain.MODE_CLIENT)
ssl.set_credentials(str(self.options.accountPublicKey), str(self.options.accountPrivateKey), str(""))
ssl.set_trusted_ca_db(str(self.options.brokerPublicKey))
ssl.set_peer_authentication(SSLDomain.VERIFY_PEER_NAME, trusted_CAs=str(self.options.brokerPublicKey))
connection = BlockingConnection(self.address, ssl_domain=ssl, heartbeat=60000)
receiver = connection.create_receiver(self.broadcast_address, credit=self.capacity)
while True:
received_message = None
try:
received_message = receiver.receive(timeout=self.options.timeout)
except Timeout, e:
print("-I- No message received for ", self.options.timeout, " seconds")
break
self.message_counter += 1
print("-I- Received broadcast message: " + received_message.body)
receiver.accept()
print("-I- " + str(self.message_counter) + " messages received")
connection.close()
开发者ID:Eurex-Clearing-Messaging-Interfaces,项目名称:Python-Code-Examples,代码行数:28,代码来源:BlockingBroadcastReceiver.py
示例11: test_forwarding_fanout
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_forwarding_fanout(self):
"""
Verify bindings that do not have a key receive all messages
"""
config = [
('exchange', {'address': 'AddressF',
'name': 'ExchangeF'}),
('binding', {'name': 'binding1',
'exchangeName': 'ExchangeF',
'bindingKey': 'pattern',
'nextHopAddress': 'nextHop1'}),
# two bindings w/o key
('binding', {'name': 'binding2',
'exchangeName': 'ExchangeF',
'nextHopAddress': 'nextHop2'}),
('binding', {'name': 'binding3',
'exchangeName': 'ExchangeF',
'nextHopAddress': 'nextHop3'})
]
for meth in ['amqp', 'mqtt']:
config[0][1]['matchMethod'] = meth
router = self._create_router('A', config)
# create clients for message transfer
conn = BlockingConnection(router.addresses[0])
sender = conn.create_sender(address="AddressF", options=AtMostOnce())
nhop1 = conn.create_receiver(address="nextHop1", credit=100)
nhop2 = conn.create_receiver(address="nextHop2", credit=100)
nhop3 = conn.create_receiver(address="nextHop3", credit=100)
# send message with subject "nope"
# should arrive at nextHop2 & 3 only
sender.send(Message(subject='nope', body='A'))
self.assertEqual('A', nhop2.receive(timeout=TIMEOUT).body)
self.assertEqual('A', nhop3.receive(timeout=TIMEOUT).body)
# send message with subject "pattern"
# forwarded to all bindings:
sender.send(Message(subject='pattern', body='B'))
self.assertEqual('B', nhop1.receive(timeout=TIMEOUT).body)
self.assertEqual('B', nhop2.receive(timeout=TIMEOUT).body)
self.assertEqual('B', nhop3.receive(timeout=TIMEOUT).body)
conn.close()
router.teardown()
示例12: test_resumable_receiver_disallowed
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_resumable_receiver_disallowed(self):
addr = self.routers[1].addresses[0]
connection = BlockingConnection(addr)
try:
receiver = connection.create_receiver(address="org.apache", options=[DurableSubscription()])
self.fail("link should have been detached")
except LinkDetached:
pass
connection.close()
示例13: test_yy_query_many_links
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_yy_query_many_links(self):
# This test will fail without the fix for DISPATCH-974
c = BlockingConnection(self.address())
count = 0
links = []
COUNT = 5000
ADDRESS_SENDER = "examples-sender"
ADDRESS_RECEIVER = "examples-receiver"
# This loop creates 5000 consumer and 5000 producer links with
# different addresses
while True:
count += 1
r = c.create_receiver(ADDRESS_RECEIVER + str(count))
links.append(r)
s = c.create_sender(ADDRESS_SENDER + str(count))
links.append(c)
if count == COUNT:
break
# Try fetching all 10,000 addresses
# This qdmanage query command would fail without the fix
# for DISPATCH-974
query_command = 'QUERY --type=org.apache.qpid.dispatch.router.address'
outs = json.loads(self.run_qdmanage(query_command))
sender_addresses = 0
receiver_addresses = 0
for out in outs:
if ADDRESS_SENDER in out['name']:
sender_addresses += 1
if ADDRESS_RECEIVER in out['name']:
receiver_addresses += 1
self.assertEqual(sender_addresses, COUNT)
self.assertEqual(receiver_addresses, COUNT)
query_command = 'QUERY --type=link'
outs = json.loads(self.run_qdmanage(query_command))
out_links = 0
in_links = 0
for out in outs:
if out.get('owningAddr'):
if ADDRESS_SENDER in out['owningAddr']:
in_links += 1
if ADDRESS_RECEIVER in out['owningAddr']:
out_links += 1
self.assertEqual(out_links, COUNT)
self.assertEqual(in_links, COUNT)
示例14: test_aaa_partial_link_route_match
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_aaa_partial_link_route_match(self):
"""
The linkRoutePattern on Routers C and B is set to org.apache.
Creates a receiver listening on the address 'org.apache.dev' and a sender that sends to address 'org.apache.dev'.
Sends a message to org.apache.dev via router QDR.C and makes sure that the message was successfully
routed (using partial address matching) and received using pre-created links that were created as a
result of specifying addresses in the linkRoutePattern attribute('org.apache.').
"""
hello_world_1 = "Hello World_1!"
# Connects to listener #2 on QDR.C
addr = self.routers[2].addresses[1]
blocking_connection = BlockingConnection(addr)
# Receive on org.apache.dev
blocking_receiver = blocking_connection.create_receiver(address="org.apache.dev")
apply_options = AtMostOnce()
# Sender to to org.apache.dev
blocking_sender = blocking_connection.create_sender(address="org.apache.dev", options=apply_options)
msg = Message(body=hello_world_1)
# Send a message
blocking_sender.send(msg)
received_message = blocking_receiver.receive()
self.assertEqual(hello_world_1, received_message.body)
# Connect to the router acting like the broker (QDR.A) and check the deliveriesIngress and deliveriesEgress
local_node = Node.connect(self.routers[0].addresses[0], timeout=TIMEOUT)
self.assertEqual(u'QDR.A', local_node.query(type='org.apache.qpid.dispatch.router',
attribute_names=['routerId']).results[0][0])
self.assertEqual(1, local_node.read(type='org.apache.qpid.dispatch.router.address',
name='router.address/M0org.apache.dev').deliveriesEgress,
"deliveriesEgress is wrong")
self.assertEqual(1, local_node.read(type='org.apache.qpid.dispatch.router.address',
name='router.address/M0org.apache.dev').deliveriesIngress,
"deliveriesIngress is wrong")
# There should be 4 links -
# 1. outbound receiver link on org.apache.dev
# 2. inbound sender link on blocking_sender
# 3. inbound link to the $management
# 4. outbound link to $management
# self.assertEqual(4, len()
self.assertEquals(4, len(local_node.query(type='org.apache.qpid.dispatch.router.link').results))
#blocking_receiver.close()
blocking_connection.close()
示例15: test_full_link_route_match
# 需要导入模块: from proton.utils import BlockingConnection [as 别名]
# 或者: from proton.utils.BlockingConnection import create_receiver [as 别名]
def test_full_link_route_match(self):
"""
The linkRoutePattern on Routers C and B is set to org.apache.
Creates a receiver listening on the address 'org.apache' and a sender that sends to address 'org.apache'.
Sends a message to org.apache via router QDR.C and makes sure that the message was successfully
routed (using full address matching) and received using pre-created links that were created as a
result of specifying addresses in the linkRoutePattern attribute('org.apache.').
"""
hello_world_3 = "Hello World_3!"
# Connects to listener #2 on QDR.C
addr = self.routers[2].addresses[1]
blocking_connection = BlockingConnection(addr)
# Receive on org.apache
blocking_receiver = blocking_connection.create_receiver(address="org.apache")
apply_options = AtMostOnce()
# Sender to to org.apache
blocking_sender = blocking_connection.create_sender(address="org.apache", options=apply_options)
msg = Message(body=hello_world_3)
# Send a message
blocking_sender.send(msg)
received_message = blocking_receiver.receive()
self.assertEqual(hello_world_3, received_message.body)
local_node = Node.connect(self.routers[0].addresses[0], timeout=TIMEOUT)
# Make sure that the router node acting as the broker (QDR.A) had one message routed through it. This confirms
# that the message was link routed
self.assertEqual(1, local_node.read(type='org.apache.qpid.dispatch.router.address',
name='router.address/M0org.apache').deliveriesEgress,
"deliveriesEgress is wrong")
self.assertEqual(1, local_node.read(type='org.apache.qpid.dispatch.router.address',
name='router.address/M0org.apache').deliveriesIngress,
"deliveriesIngress is wrong")
#blocking_receiver.close()
blocking_connection.close()