[ https://issues.apache.org/jira/browse/DISPATCH-89?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16327872#comment-16327872 ]
ASF GitHub Bot commented on DISPATCH-89: ---------------------------------------- Github user ganeshmurthy commented on a diff in the pull request: https://github.com/apache/qpid-dispatch/pull/244#discussion_r161897073 --- Diff: tests/system_tests_exchange_bindings.py --- @@ -0,0 +1,676 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +import ast +import unittest2 as unittest +from threading import Thread +from time import sleep +from subprocess import PIPE, STDOUT + +try: + import Queue as Queue # 2.7 +except ImportError: + import queue as Queue # 3.x + +from system_test import TestCase, Qdrouterd, main_module, TIMEOUT, Process +from proton import Message, Timeout +from proton.reactor import AtMostOnce, AtLeastOnce +from proton.utils import BlockingConnection, SendException + +# TIMEOUT=5 +_EXCHANGE_TYPE = "org.apache.qpid.dispatch.router.config.exchange" +_BINDING_TYPE = "org.apache.qpid.dispatch.router.config.binding" + + +class _AsyncReceiver(object): + def __init__(self, address, source, credit=100, timeout=0.1): + super(_AsyncReceiver, self).__init__() + self.conn = BlockingConnection(address) + self.rcvr = self.conn.create_receiver(address=source, credit=credit) + self.thread = Thread(target=self._poll) + self.queue = Queue.Queue() + self._run = True + self._timeout = timeout + self.thread.start() + + def _poll(self): + while self._run: + try: + msg = self.rcvr.receive(timeout=self._timeout) + except Timeout: + continue + try: + self.rcvr.accept() + except IndexError: + # PROTON-1743 + pass + self.queue.put(msg) + self.rcvr.close() + self.conn.close() + + def stop(self): + self._run = False + self.thread.join(timeout=TIMEOUT) + + +class ExchangeBindingsTest(TestCase): + """ + Tests the exchange/bindings of the dispatch router. + """ + def _create_router(self, name, config): + + config = [ + ('router', {'mode': 'standalone', 'id': 'QDR.%s'%name}), + ('listener', {'role': 'normal', 'host': '0.0.0.0', + 'port': self.tester.get_port(), + 'saslMechanisms':'ANONYMOUS'}) + ] + config + return self.tester.qdrouterd(name, Qdrouterd.Config(config)) + + def run_qdmanage(self, router, cmd, input=None, expect=Process.EXIT_OK): + p = self.popen( + ['qdmanage'] + cmd.split(' ') + + ['--bus', router.addresses[0], '--indent=-1', '--timeout', str(TIMEOUT)], + stdin=PIPE, stdout=PIPE, stderr=STDOUT, expect=expect) + out = p.communicate(input)[0] + try: + p.teardown() + except Exception, e: + raise Exception("%s\n%s" % (e, out)) + return out + + def _validate_entity(self, name, kind, entities, expected): + for entity in entities: + if "name" in entity and entity["name"] == name: + for k,v in expected.items(): + self.assertTrue(k in entity) + self.assertEqual(v, entity[k]) + return; --- End diff -- No semi colon here > Model the legacy topic exchange behavior of qpidd > ------------------------------------------------- > > Key: DISPATCH-89 > URL: https://issues.apache.org/jira/browse/DISPATCH-89 > Project: Qpid Dispatch > Issue Type: New Feature > Components: Routing Engine > Affects Versions: 0.2 > Reporter: Ken Giusti > Assignee: Ken Giusti > Priority: Major > > With Qpidd, a user can define a binding from an Exchange to a target queue. > The binding uses a key that is compared to a message's subject field. If the > key matches, the message is routed to the target queue for that binding. > It should be possible to emulate this behavior using the dispatch router. > Example: > User defines a mappings from a target address (the 'exchange') to a different > target address(es) (the 'queue'). These mappings (the 'bindings') are driven > by a pattern match against the inbound message's subject field. > Messages arriving at the router from any link whose target address has > bindings defined are not immediately routed. Prior to routing, the message's > subject field is extracted and compared against each binding defined for the > target. A list of new target addresses is created containing the target > address from each binding that satisfied the pattern match. The message is > then routed to each new target address. > The pattern syntax should be the same 'dotted string' notation from qpidd, > including '*' and "#' wildcarding. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org