On Thu, Apr 28, 2022 at 9:58 PM ONeil, Jerome <jerome.on...@wabtec.com> wrote: > So that's grand. I need to control the binding with more detail, though, and > for the life of me I can't figure out how to do it. I've tried controlling > on the URL. I've tried Filters and Selectors. I have tried a variety of > different link and receiver properties (x-bindings, etc..) and other methods > scrapped up from the internet, and all I ever get for that binding is '#'. > > Can someone provide a simple example? Lets say I wanted that binding to > actually be > > bind [jerome.#] => MyTopic > > What would that look like? I am all out of clues and hope someone has one to > spare.
Attached is an example that sets the topic binding.
#!/usr/bin/env python # # 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. # from __future__ import print_function, unicode_literals from proton import Described, Message, symbol from proton.reactor import Container, Filter from proton.handlers import MessagingHandler class SubjectFilter(Filter): def __init__(self, value): super(SubjectFilter, self).__init__({symbol('subject-filter'): Described(symbol('apache.org:legacy-amqp-topic-binding:string'), value)}) class Recv(MessagingHandler): def __init__(self): super(Recv, self).__init__() def on_start(self, event): conn = event.container.connect("anonymous@localhost:5672") event.container.create_sender(conn, "amq.topic") event.container.create_receiver(conn, "amq.topic", options=SubjectFilter("red.#")) def on_sendable(self, event): for i in ['red.panda', 'blue.whale', 'green.hornet', 'yellow.submarine', 'red.squirrel']: event.link.send(Message(subject=i, body="this is a message with subject %s" % i)) event.link.close() def on_message(self, event): print(event.message.body) try: Container(Recv()).run() except KeyboardInterrupt: pass
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org For additional commands, e-mail: users-h...@qpid.apache.org