Code Monkey home page Code Monkey logo

qpid-bow's Introduction

qpid-bow

image

image

Documentation Status

Qpid Bow is a higher level client framework for Python 3.6+ to communicate with AMQP/Qpid servers combined with a set of CLI tools to manage a Qpid server.

With its CLI tools Qpid Bow provides the missing tooling you always wanted to administrate or debug your Qpid-based AMQP stack. Providing you with the power to manage queues and exchanges, setup and save routing using YAML files and various other tools.

As a framework Qpid Bow can provide you with a higher level interface on top of the low level Qpid Proton library to integrate with AMQP/Qpid queues, exchanges and Remote Procedure Call (RPC) functionality:

  • Simple, callback based receiver, supporting listening for multiple queues.
  • RPC calls with automatic temporary queues and callbacks.
  • Queue based sender.
  • Included Qpid management code for queue/exchange creation.
  • Support to run under Python's asyncio event loop with async def callbacks.

Requirements

Installation

Qpid Bow is available from PyPI:

$ pip install qpid-bow

Or add qpid-bow to your application's requirements using requirements.txt / setup.py / Pipfile.

Testing

Qpid Bow's unit tests need to connect to an actual Apache Qpid server for all tests to succeed. By default the tests assume a server exists on localhost.

To specify the server address to use for tests use the environment variable: AMQP_TEST_SERVERS

Available tools

Queue

  • qb queue create - Create queues.
  • qb queue delete - Delete queues.
  • qb queue purge - Purge messages from a queue.
  • qb queue reroute - Reroute messages from a queue to an exchange.
  • qb queue stats - Print queue usage statistics and active number of messages.

Message

  • qb message receive - Receive messages from a queue or an exchange.
  • qb message send - Send messages to a queue or an exchange.

Route

  • qb route dump - View & save exchange -> queue routing.
  • qb route config - Setup exchange -> queue routing from a saved file.

Connection

  • qb connection kill - Kill connections from the server.

Session

  • qb session outgoing - List outgoing sessions from the server.

Configuration & Environment variables

Several options exist to configure Qpid Bow. In order of preference:

Pass in arguments One can always override the used server URL using arguments:

  • For the CLI tools, use the --broker-url command line argument.
  • For the library pass in the keyword argument server_url.

Configure using a dict When using Qpid Bow as a library, one can pass in config using a dict to: qpid_bow.config.configure

The dict can contain the following entries:

  • amqp_url - Comma-separated list of main and failover servers to connect to.
  • username - Username to use when no username is provided in the URL.
  • password - Password to use when no password is provided in the URL.

Environment variables The easiest way to configure Qpid Bow's tools and library is to use environment variables. These variables can be added to your shell's profile and will automatically get picked up.

  • AMQP_SERVERS - Comma-separated list of main and failover servers to connect to.
  • AMQP_TEST_SERVERS - Same as AMQP_SERVERS, used solely for unittests.

example: AMQP_SERVERS=amqp://user:[email protected]:5672,amqp://user:[email protected]:5672

qpid-bow's People

Contributors

condemil avatar maruno avatar matyaskuti avatar mboelens91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qpid-bow's Issues

Async receive always succeeds

success = asyncio.ensure_future(
self.handle_async_message(event), loop=loop)
else:
success = self.handle_message(event)
if success:
self.accept(event.delivery)
else:
self.reject(event.delivery)

AFAICT, this always returns a Future and will always test as successful.

It would help significantly if you could test qpid-bow against qpid-proton 0.27.1

This is the last version prior to completely rewriting the IO in Python rather than using C as the pinned 0.24 version does.

Doing this will enable us to know if qpid-bow is using any symbols that are no longer exported by the library. And we can take some action to fix this.

Due to some last minute breakage, the 0.28 release (the version after the IO rewrite) is known not to work with external loops - This is PROTON-2051

Non-async recieve?

Is there a non-async, basic, recieve() method? I am not in a good position to add another event loop the the program I am modifying, am just looking to poll for message(s) from AQMP queues.

Reading the code it looks like Receiver.receive(timeout) should run the event for timeout's duration and return, which would be fine. But it does not receive messages when I run it.

async def consumer(message: Message) -> bool:
   print(f'Received message: {message.body}')
   return True

class QpidClient:
   def __init__(self, queue_name : str, reply_queue_name : str, server_address = '127.0.0.1'):
      if queue_name is None or len(queue_name) == 0 or reply_queue_name is None or len(reply_queue_name) == 0:
         raise Exception('QpidClient: queue_name and reply_queue_name must be strings.')
      self.server_url = server_address
      self.queue_name = queue_name
      self.timeout = timedelta(seconds=5)
      self.reply_sender = Sender(server_url=server_address)
      self.reply_queue_name = reply_queue_name
      if not self.try_create_queues():
         raise Exception('QpidClient: could not create queues ', self.queue_name, ' and ', reply_queue_name)

   def try_create_queues(self):
      rtn = True
      try:
         create_queue(self.queue_name,       priorities=10, server_url=self.server_url)
      except QMF2ObjectExists:
         print('Queue already exists:', self.queue_name)
         # pass  # Queue already exists
      except QMF2Exception:
         print("QMF2 error during queue creation")
         rtn = False
      try:
         create_queue(self.reply_queue_name, priorities=10, server_url=self.server_url)
      except QMF2ObjectExists:
         print('Queue already exists:', self.reply_queue_name)
         # pass  # Queue already exists
      except QMF2Exception:
         print("QMF2 error during queue creation")
         rtn = False
      return rtn

   def send_messages(self, message_to_send = []):
      sender = Sender(self.queue_name, self.server_url)
      messages = []
      for msg in message_to_send:
         message = create_message(msg)
         message.address = self.queue_name
         message.reply_to = self.reply_queue_name
         messages.append(message)
         print('message', msg)
      sender.queue(messages)
      sender.send()

   # This should? spend timeout seconds trying to get messages.
   def recv_messages_async(self, messages_recieved = [], message_count_limit=1):
      # >>>> These three lines receive all the queued messages, but then execution is blocked in loop.run_forever()
      #receiver.run()
      #loop = asyncio.get_event_loop()
      #loop.run_forever()

      # >>>> These two lines receive nothing even when there are enqueued messages.
      receiver = Receiver(consumer, self.queue_name, self.server_url, container_class=AsyncioContainer)
      receiver.receive( timeout=timedelta(0, 1, 0, 0, 0, 0, 0,) )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.