Skip to content

Commit

Permalink
Merge pull request #12 from d3rky/bugfix/LITE-17358-nack-created-mess…
Browse files Browse the repository at this point in the history
…ages

LITE-17358 nack with requeueing, add expiration for messages to 60s
  • Loading branch information
d3rky authored Feb 26, 2021
2 parents 6c4bbec + 6ad4ec7 commit 10679d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dj_cqrs/transport/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def log_consumed_denied(payload):
:param dj_cqrs.dataclasses.TransportPayload payload: Transport payload from master model.
"""
if payload.pk:
logger.info('CQRS is denied: pk = {} ({}).'.format(payload.pk, payload.cqrs_id))
logger.warning('CQRS is denied: pk = {} ({}).'.format(payload.pk, payload.cqrs_id))

@staticmethod
def log_produced(payload):
Expand Down
8 changes: 6 additions & 2 deletions dj_cqrs/transport/rabbit_mq.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _consume_message(cls, ch, method, properties, body):
ch.basic_ack(delivery_tag=method.delivery_tag)
cls.log_consumed_accepted(payload)
else:
ch.basic_nack(delivery_tag=method.delivery_tag, requeue=False)
ch.basic_nack(delivery_tag=method.delivery_tag)
cls.log_consumed_denied(payload)

@classmethod
Expand All @@ -111,7 +111,11 @@ def _produce_message(cls, channel, exchange, payload):
routing_key=routing_key,
body=ujson.dumps(payload.to_dict()),
mandatory=True,
properties=BasicProperties(content_type='text/plain', delivery_mode=2)
properties=BasicProperties(
content_type='text/plain',
delivery_mode=2, # make message persistent
expiration='60000', # milliseconds
)
)

@staticmethod
Expand Down

0 comments on commit 10679d5

Please sign in to comment.