allow setting ttl in protonmsg
This commit is contained in:
parent
fa0c558912
commit
8a472ed94e
3 changed files with 7 additions and 1 deletions
|
|
@ -11,6 +11,8 @@ send_timeout = 60
|
|||
# if field is longer (json.dumps), ignore it
|
||||
# default value is 0 - unlimited size
|
||||
extra_limit = 0
|
||||
# message ttl can be specified in seconds, default is no ttl
|
||||
# ttl = 86400
|
||||
|
||||
[queue]
|
||||
# enable persistent database queue
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ class TimeoutHandler(MessagingHandler):
|
|||
return 'topic://' + koji_topic_prefix
|
||||
|
||||
def send_msgs(self, event):
|
||||
ttl = self.conf.getfloat('message', 'ttl', fallback=None)
|
||||
for msg in self.msgs:
|
||||
# address is like "topic://koji.package.add"
|
||||
address = self.topic_prefix + '.' + msg['address']
|
||||
|
|
@ -104,6 +105,9 @@ class TimeoutHandler(MessagingHandler):
|
|||
self.log.debug('created new sender for %s', address)
|
||||
self.senders[address] = sender
|
||||
pmsg = Message(properties=msg['props'], body=msg['body'])
|
||||
if ttl:
|
||||
# The message class expects seconds, even though the c api uses milliseconds
|
||||
pmsg.ttl = ttl
|
||||
delivery = sender.send(pmsg)
|
||||
self.log.debug('sent message: %s', msg['props'])
|
||||
self.pending[delivery] = msg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue