def test_dynamic_receiver_props(self): """Verify dynamic-node-properties can be requested.""" # dynamic receive link: DELETE_ON_CLOSE = 0x000000000000002b desired_props = {symbol("lifetime-policy"): DELETE_ON_CLOSE} props = {"dynamic-node-properties": desired_props} sender = self.conn1.create_sender("saddr", target_address=None, properties=props) sender.open() self.process_connections() assert self.conn2_handler.receiver_requested_ct == 1 args = self.conn2_handler.receiver_requested_args[0] dnp = args.properties.get('dynamic-node-properties') assert dnp and dnp == desired_props # dynamic send link: desired_props = {symbol("supported-dist-modes"): [symbol("move"), symbol("copy")]} props = {"dynamic-node-properties": desired_props} receiver = self.conn1.create_receiver("taddr", source_address=None, properties=props) receiver.open() self.process_connections() assert self.conn2_handler.sender_requested_ct == 1 args = self.conn2_handler.sender_requested_args[0] dnp = args.properties.get('dynamic-node-properties') assert dnp and dnp == desired_props
def on_start(self, event): self.timer = event.reactor.schedule(10.0, Timeout(self)) self.sender_conn = event.container.connect(self.sender_host) self.receiver_conn = event.container.connect(self.receiver_host) self.waypoint_conn = event.container.connect(self.waypoint_host) self.sender = event.container.create_sender(self.sender_conn, self.addr) self.receiver = event.container.create_receiver(self.receiver_conn, self.addr) self.wp_sender = event.container.create_sender(self.waypoint_conn, self.addr) self.wp_receiver = event.container.create_receiver(self.waypoint_conn, self.addr) self.wp_sender.target.capabilities.put_object(symbol("qd.waypoint")) self.wp_receiver.source.capabilities.put_object(symbol("qd.waypoint"))
def __init__(self, props={}): self.properties = {} for k in props: if isinstance(k, symbol): self.properties[k] = props[k] else: self.properties[symbol(k)] = props[k]
def on_start(self, event): self.timer = event.reactor.schedule(10.0, Timeout(self)) self.sender_conn = event.container.connect(self.sender_host) self.primary_conn = event.container.connect(self.primary_host) self.fallback_conn = event.container.connect(self.fallback_host) self.primary_receiver = event.container.create_receiver(self.primary_conn, self.addr) self.fallback_receiver = event.container.create_receiver(self.primary_conn, self.addr, name=self.addr) self.fallback_receiver.source.capabilities.put_object(symbol("qd.fallback"))
def on_start(self, event): self.timer = event.reactor.schedule(10.0, Timeout(self)) self.sender_conn = event.container.connect(self.sender_host) self.receiver_conn = event.container.connect(self.receiver_host) self.sender = event.container.create_sender(self.sender_conn, self.addr) self.receiver = event.container.create_receiver(self.receiver_conn, self.addr) for host in self.waypoint_hosts: self.waypoint_conns.append(event.container.connect(host)) ordinal = 1 for conn in self.waypoint_conns: sender = event.container.create_sender(conn, self.addr) receiver = event.container.create_receiver(conn, self.addr) sender.target.capabilities.put_object(symbol("qd.waypoint.%d" % ordinal)) receiver.source.capabilities.put_object(symbol("qd.waypoint.%d" % ordinal)) self.wp_senders.append(sender) self.wp_receivers.append(receiver) ordinal += 1
def declare_transaction(self, context, handler=None, settle_before_discharge=False): if not _get_attr(context, '_txn_ctrl'): class InternalTransactionHandler(OutgoingMessageHandler): def __init__(self): super(InternalTransactionHandler, self).__init__(auto_settle=True) def on_settled(self, event): if hasattr(event.delivery, "transaction"): event.transaction = event.delivery.transaction event.delivery.transaction.handle_outcome(event) context._txn_ctrl = self.create_sender(context, None, name='txn-ctrl', handler=InternalTransactionHandler()) context._txn_ctrl.target.type = Terminus.COORDINATOR context._txn_ctrl.target.capabilities.put_object(symbol(u'amqp:local-transactions')) return Transaction(context._txn_ctrl, handler, settle_before_discharge)
def on_sendable(self, event): if not self.sent: msg = Message() msg.address = self.address msg.id = '123455' msg.user_id = 'testuser' msg.subject = 'test-subject' msg.content_type = 'text/html; charset=utf-8' msg.correlation_id = 89 msg.creation_time = 1487772623.883 msg.group_id = "group1" msg.reply_to = 'hello_world' msg.content_encoding = 'gzip, deflate' msg.reply_to_group_id = "group0" application_properties = dict() application_properties['app-property'] = [10, 20, 30] application_properties['some-other'] = symbol("O_one") msg.properties = application_properties msg.body = u"Hello World!" event.sender.send(msg) self.sent = True
def discharge(self, failed): self.failed = failed self._discharge = self._send_ctrl(symbol(u'amqp:discharge:list'), [self.id, failed])
def declare(self): self._declare = self._send_ctrl(symbol(u'amqp:declare:list'), [None])
from __future__ import absolute_import from threading import Thread, Event from uuid import uuid4 from proton import Message, Url, Array, UNDESCRIBED, Data, symbol, ConnectionException from proton.handlers import MessagingHandler from proton.reactor import Container from proton.utils import SyncRequestResponse, BlockingConnection from .common import Test, free_tcp_port from .common import ensureCanTestExtendedSASL CONNECTION_PROPERTIES={u'connection': u'properties'} OFFERED_CAPABILITIES = Array(UNDESCRIBED, Data.SYMBOL, symbol("O_one"), symbol("O_two"), symbol("O_three")) DESIRED_CAPABILITIES = Array(UNDESCRIBED, Data.SYMBOL, symbol("D_one"), symbol("D_two"), symbol("D_three")) ANONYMOUS='ANONYMOUS' EXTERNAL='EXTERNAL' class EchoServer(MessagingHandler, Thread): """ Simple echo server that echos messages to their reply-to. Runs in a thread. Will only accept a single connection and shut down when that connection closes. """ def __init__(self, url, timeout): MessagingHandler.__init__(self) Thread.__init__(self) self.daemon = True
import jaeger_client from opentracing.ext import tags from opentracing.propagation import Format except ImportError: raise ImportError( 'proton tracing requires opentracing and jaeger_client modules') import proton from proton import Sender as ProtonSender from proton.handlers import (OutgoingMessageHandler as ProtonOutgoingMessageHandler, IncomingMessageHandler as ProtonIncomingMessageHandler) _tracer = None _trace_key = proton.symbol('x-opt-qpid-tracestate') def get_tracer(): global _tracer if _tracer is not None: return _tracer exe = sys.argv[0] if sys.argv[0] else 'interactive-session' return init_tracer(os.path.basename(exe)) def _fini_tracer(): time.sleep(1) c = opentracing.global_tracer().close() while not c.done(): time.sleep(0.5)
def apply(self, sender): sender.target.capabilities.put_object(symbol("queue"))
def test_non_unicode_selector(self): assert Selector(b"Hello").filter_set[symbol('selector')].value == u"Hello"
def __init__(self, value, name='selector'): super(Selector, self).__init__({symbol(name): Described(symbol('apache.org:selector-filter:string'), value)})
sys.exit(1) # Errors or failures present # Connect to broker to find broker type, or use --broker-type param if present if ARGS.broker_type is not None: if ARGS.broker_type == 'None': BROKER = None else: BROKER = ARGS.broker_type else: CONNECTION_PROPS = qpid_interop_test.broker_properties.get_broker_properties( ARGS.sender) if CONNECTION_PROPS is None: print 'WARNING: Unable to get connection properties - unknown broker' BROKER = 'unknown' else: BROKER = CONNECTION_PROPS[symbol(u'product')] if symbol(u'product') in CONNECTION_PROPS \ else '<product not found>' BROKER_VERSION = CONNECTION_PROPS[symbol(u'version')] if symbol(u'version') in CONNECTION_PROPS \ else '<version not found>' BROKER_PLATFORM = CONNECTION_PROPS[symbol(u'platform')] if symbol(u'platform') in CONNECTION_PROPS \ else '<platform not found>' print 'Test Broker: %s v.%s on %s' % (BROKER, BROKER_VERSION, BROKER_PLATFORM) print sys.stdout.flush() if ARGS.no_skip: BROKER = None # Will cause all tests to run TYPES = JmsMessageTypes().get_types(ARGS) # TEST_SUITE is the final suite of tests that will be run and which contains all the dynamically created
def __init__(self, value, name='selector'): super(Selector, self).__init__({ symbol(name): Described(symbol('apache.org:selector-filter:string'), value) })
def apply(self, receiver): receiver.source.capabilities.put_object(symbol("queue"))