Skip to content

Commit

Permalink
Fix #953 by only connecting when necessary, re-enable passive queue d…
Browse files Browse the repository at this point in the history
…eclare to get number of messages in queue (#1160)
  • Loading branch information
reidsunderland authored Aug 9, 2024
1 parent 501eb42 commit d387893
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sarracenia/moth/amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def metricsReport(self):
next_time = self.last_qDeclare + 30
now=time.time()
if next_time <= now:
#self._queueDeclare(passive=True)
self._queueDeclare(passive=True)
self.last_qDeclare=now

super().metricsReport()
Expand All @@ -253,11 +253,12 @@ def _queueDeclare(self,passive=False) -> int:

try:
# from sr_consumer.build_connection...
if not self.__connect(self.o['broker']):
logger.critical('could not connect')
if hasattr(self,'metrics'):
self.metrics['brokerQueuedMessageCount'] = -2
return -2
if not self.connection or not self.connection.connected:
if not self.__connect(self.o['broker']):
logger.critical('could not connect')
if hasattr(self,'metrics'):
self.metrics['brokerQueuedMessageCount'] = -2
return -2

#FIXME: test self.first_setup and props['reset']... delete queue...
broker_str = self.o['broker'].url.geturl().replace(
Expand Down

0 comments on commit d387893

Please sign in to comment.