Home | Trees | Indices | Help |
---|
|
1 # 2 # Licensed to the Apache Software Foundation (ASF) under one 3 # or more contributor license agreements. See the NOTICE file 4 # distributed with this work for additional information 5 # regarding copyright ownership. The ASF licenses this file 6 # to you under the Apache License, Version 2.0 (the 7 # "License"); you may not use this file except in compliance 8 # with the License. You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, 13 # software distributed under the License is distributed on an 14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 # KIND, either express or implied. See the License for the 16 # specific language governing permissions and limitations 17 # under the License. 18 # 19 20 """ 21 Add-on utilities for the L{qpid.messaging} API. 22 """ 23 24 from qpid.messaging import * 25 from logging import getLogger 26 from threading import Thread 27 28 log = getLogger("qpid.messaging.util") 2931 ssn = conn.session("auto-fetch-reconnect-urls") 32 rcv = ssn.receiver("amq.failover") 33 rcv.capacity = 10 34 35 def main(): 36 while True: 37 try: 38 msg = rcv.fetch() 39 except LinkClosed: 40 return 41 set_reconnect_urls(conn, msg) 42 ssn.acknowledge(msg, sync=False)43 44 thread = Thread(name="auto-fetch-reconnect-urls", target=main) 45 thread.setDaemon(True) 46 thread.start() 47 4850 reconnect_urls = [] 51 urls = msg.properties["amq.failover"] 52 for u in urls: 53 if u.startswith("amqp:"): 54 for p in u[5:].split(","): 55 parts = p.split(":") 56 host, port = parts[1:3] 57 reconnect_urls.append("%s:%s" % (host, port)) 58 conn.reconnect_urls = reconnect_urls 59 log.warn("set reconnect_urls for conn %s: %s", conn, reconnect_urls)60 61 __all__ = ["auto_fetch_reconnect_urls", "set_reconnect_urls"] 62
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Apr 28 12:29:15 2011 | http://epydoc.sourceforge.net |