Skip to content

Commit

Permalink
debug logging in publish_confirm to track down an RP issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rabellino-noaa committed Jun 20, 2024
1 parent 7990ec7 commit 42701b3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions python/idsse_common/idsse/common/publish_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ def publish_message(self,
Raises:
RuntimeError: if channel is uninitialized (start() not completed yet) or is closed
"""
logger.info('DEBUG: in publish_message, waiting for channel to be ready...')
self._wait_for_channel_to_be_ready()
logger.info('DEBUG: channel is ready to publish message')

# We expect a JSON message format, do a check here...
try:
Expand All @@ -125,7 +127,7 @@ def publish_message(self,
properties)
self._records.message_number += 1
self._records.deliveries[self._records.message_number] = message
logger.debug('Published message # %i to exchange %s, queue %s, routing_key %s',
logger.info('Published message # %i to exchange %s, queue %s, routing_key %s',
self._records.message_number, self._rmq_params.exchange.name,
self._rmq_params.queue.name, routing_key)
return True
Expand Down Expand Up @@ -207,16 +209,17 @@ def _wait_for_channel_to_be_ready(self) -> None:
RabbitMQ setup. This method will not return until channel is confirmed ready for use"""

# validate that PublishConfirm thread has been set up and connected to RabbitMQ
logger.info('DEBUG: in _wait_for_channel_to_be_ready')
if not (self._connection and self._connection.is_open
and self._channel and self._channel.is_open):
logger.debug('Channel is not ready to publish, calling _start() now')
logger.info('Channel is not ready to publish, calling _start() now')

# pass callback to flip is_ready flag, and block until flag changes
is_ready = Event()
self._start(callback=is_ready.set)
is_ready.wait()

logger.debug('Connection and channel setup complete, ready to publish message')
logger.info('Connection and channel setup complete, ready to publish message')

def _on_connection_open(self, connection: SelectConnection):
"""This method is called by pika once the connection to RabbitMQ has been established.
Expand Down

0 comments on commit 42701b3

Please sign in to comment.