def publish(self, exchange, routing_key, body, # pylint: disable=R0913
properties=None, mandatory=False, immediate=False):
"""Publish to the channel with the given exchange, routing key, and
body. Unlike the legacy `BlockingChannel.basic_publish`, this method
provides more information about failures via exceptions.
:raises UnroutableError: raised when a message published in
publisher-acknowledgments mode (see
`BlockingChannel.confirm_delivery`) is returned via `Basic.Return`
followed by `Basic.Ack`.
:raises NackError: raised when a message published in
publisher-acknowledgements mode is Nack'ed by the broker. See
`BlockingChannel.confirm_delivery`.
"""
if self._delivery_confirmation:
# In publisher-acknowledgments mode
with self._message_confirmation_result:
self._impl.basic_publish(exchange=exchange,
routing_key=routing_key,
body=body,
properties=properties,
mandatory=mandatory,
immediate=immediate)
self._flush_output(self._message_confirmation_result.is_ready)
conf_method = (self._message_confirmation_result.value
.method_frame
.method)
if isinstance(conf_method, pika.spec.Basic.Nack):
# Broker was unable to process the message due to internal
# error
LOGGER.warn(
"Message was Nack'ed by broker: nack=%r; channel=%s; "
"exchange=%s; routing_key=%s; mandatory=%r; "
"immediate=%r", conf_method, self.channel_number,
exchange, routing_key, mandatory, immediate)
if self._puback_return is not None:
returned_messages = [self._puback_return]
self._puback_return = None
else:
returned_messages = []
raise exceptions.NackError(returned_messages)
else:
assert isinstance(conf_method, pika.spec.Basic.Ack), (
conf_method)
if self._puback_return is not None:
# Unroutable message was returned
messages = [self._puback_return]
self._puback_return = None
raise exceptions.UnroutableError(messages)
else:
# In non-publisher-acknowledgments mode
self._impl.basic_publish(exchange=exchange,
routing_key=routing_key,
body=body,
properties=properties,
mandatory=mandatory,
immediate=immediate)
self._flush_output()
as it is blocking connection and _flush_output function call ensure to wait for the return, so I think it is sync call here. Which means after we send the message to an delayed exchange, broker side did not return either NACK or UNROUTE exception, which I assume it means the broker get the message? Then how come the delayed exchange did not get the message then?
Thanks