def __init__(self, broker, **kw): self.set_broker(broker) self.socket = connect(self.host, self.port) if self.url.scheme == URL.AMQPS: self.socket = ssl(self.socket) self.connection = Connection(sock=self.socket, username=self.user, password=self.password) self.connection.start() log.info("Connected to AMQP Broker %s" % self.host) self.session = self.connection.session(str(uuid4()))
class TestBase010(unittest.TestCase): """ Base class for Qpid test cases. using the final 0-10 spec """ DEFAULT_USERNAME = "******" DEFAULT_PASSWORD = "******" DEFAULT_PORT = 5672 DEFAULT_PORT_TLS = 5671 def configure(self, config): self.config = config self.broker = config.broker self.defines = self.config.defines def setUp(self): self.conn = self.connect() self.session = self.conn.session("test-session", timeout=10) self.qmf = None self.test_queue_name = self.id() def startQmf(self, handler=None): self.qmf = qmf.console.Session(handler) self.qmf_broker = self.qmf.addBroker(str(self.broker)) def startBrokerAccess(self): """ New-style management access to the broker. Can be used in lieu of startQmf. """ if 'broker_conn' not in self.__dict__: self.broker_conn = qpid.messaging.Connection(str(self.broker)) self.broker_conn.open() self.broker_access = BrokerAgent(self.broker_conn) def connect(self, host=None, port=None): url = self.broker if url.scheme == URL.AMQPS: default_port = self.DEFAULT_PORT_TLS else: default_port = self.DEFAULT_PORT try: sock = connect(host or url.host, port or url.port or default_port) except socket.error, e: raise Skipped(e) if url.scheme == URL.AMQPS: sock = ssl(sock) conn = Connection(sock, username=url.user or self.DEFAULT_USERNAME, password=url.password or self.DEFAULT_PASSWORD) try: conn.start(timeout=10) except VersionError, e: raise Skipped(e)
def __init__(self, hub, config): self.config = config self.set_broker(self.config.get('amqp_broker')) self.socket = connect(self.host, self.port) if self.url.scheme == URL.AMQPS: self.socket = ssl(self.socket) self.connection = Connection(sock=self.socket, username=self.user, password=self.password) self.connection.start() log.info("Connected to AMQP Broker %s" % self.host) self.session = self.connection.session(str(uuid4())) self.local_queues = [] super(QpidAMQPHubExtension, self).__init__()
def start(self): """ Enable AMQP queueing. This method puts up the event processor and sets it to "active". """ self.log.debug("enabling AMQP queueing") # Evaluate username user = self.config.get("amqp.id", default=None) if not user: user = self.env.uuid password = self.config.get("amqp.key") # Create initial broker connection url = "%s:%s" % (self.url['host'], self.url['port']) self._conn = Connection.establish(url, reconnect=self.reconnect, username=user, password=password, transport=self.url['transport'], reconnect_interval=self.reconnect_interval, reconnect_limit=self.reconnect_limit) # Do automatic broker failover if requested if self.config.get('amqp.failover', False): auto_fetch_reconnect_urls(self._conn) # Create event exchange socket = connect(self.url['host'], self.url['port']) if self.url['scheme'][-1] == 's': socket = ssl(socket) user = self.config.get("amqp.id", default=None) if not user: user = self.env.uuid connection = DirectConnection(sock=socket, username=user, password=self.config.get("amqp.key")) connection.start() session = connection.session(str(uuid4())) # pylint: disable=E1103 session.exchange_declare(exchange=self.env.domain, type="xml") connection.close() # Create event provider self._eventProvider = EventProvider(self.env, self.getConnection())
class TestBase010(unittest.TestCase): """ Base class for Qpid test cases. using the final 0-10 spec """ def configure(self, config): self.config = config self.broker = config.broker self.defines = self.config.defines def setUp(self): self.conn = self.connect() self.session = self.conn.session("test-session", timeout=10) self.qmf = None def startQmf(self, handler=None): self.qmf = qmf.console.Session(handler) self.qmf_broker = self.qmf.addBroker(str(self.broker)) def connect(self, host=None, port=None): url = self.broker if url.scheme == URL.AMQPS: default_port = 5671 else: default_port = 5672 try: sock = connect(host or url.host, port or url.port or default_port) except socket.error, e: raise Skipped(e) if url.scheme == URL.AMQPS: sock = ssl(sock) conn = Connection(sock, username=url.user or "guest", password=url.password or "guest") try: conn.start(timeout=10) except VersionError, e: raise Skipped(e)