Get a single message from the AMQP broker. If you want to be notified of Basic.GetEmpty, use the Channel.add_callback method adding your Basic.GetEmpty callback which should expect only one parameter, frame. Due to implementation details, this cannot be called a secon
(self,
queue: str,
callback: _OnBasicGetCallback,
auto_ack: bool = False)
| 396 | return 'ctag%i.%s' % (self.channel_number, uuid.uuid4().hex) |
| 397 | |
| 398 | def basic_get(self, |
| 399 | queue: str, |
| 400 | callback: _OnBasicGetCallback, |
| 401 | auto_ack: bool = False) -> None: |
| 402 | """Get a single message from the AMQP broker. If you want to |
| 403 | be notified of Basic.GetEmpty, use the Channel.add_callback method |
| 404 | adding your Basic.GetEmpty callback which should expect only one |
| 405 | parameter, frame. Due to implementation details, this cannot be called |
| 406 | a second time until the callback is executed. For more information on |
| 407 | basic_get and its parameters, see: |
| 408 | |
| 409 | https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.get |
| 410 | |
| 411 | :param str queue: The queue from which to get a message. Use the empty |
| 412 | string to specify the most recent server-named queue for this |
| 413 | channel |
| 414 | :param callable callback: The callback to call with a message that has |
| 415 | the signature callback(channel, method, properties, body), where: |
| 416 | - channel: pika.channel.Channel |
| 417 | - method: pika.spec.Basic.GetOk |
| 418 | - properties: pika.spec.BasicProperties |
| 419 | - body: bytes |
| 420 | :param bool auto_ack: Tell the broker to not expect a reply |
| 421 | :raises ValueError: |
| 422 | |
| 423 | """ |
| 424 | validators.require_string(queue, 'queue') |
| 425 | validators.require_callback(callback) |
| 426 | if self._on_getok_callback is not None: |
| 427 | raise exceptions.DuplicateGetOkCallback() |
| 428 | self._on_getok_callback = callback |
| 429 | |
| 430 | # pylint: disable=W0511 |
| 431 | # TODO Strangely, not using _rpc for the synchronous Basic.Get. Would |
| 432 | # need to extend _rpc to handle Basic.GetOk method, header, and body |
| 433 | # frames (or similar) |
| 434 | self._send_method(spec.Basic.Get(queue=queue, no_ack=auto_ack)) |
| 435 | |
| 436 | def basic_nack(self, |
| 437 | delivery_tag: int = 0, |