protonmsg: allow users to specify router-specific topic prefixes
Prior to this change, Koji would always send messages with a hard-coded topic:// prefix. This works fine for ActiveMQ 5 and Artemis, but RabbitMQ does not support that syntax. Instead, RabbitMQ brokers expect clients to use topic addresses with a "/topic/" prefix. The RFE for RabbitMQ to support "topic://" prefixes is https://github.com/rabbitmq/rabbitmq-server/issues/2583 In the meantime, allow users to specify "topic://" or "/topic/" explicitly in their configuration. For backwards-compatibility, if the user chose neither "topic://" nor "/topic/", prepend the "topic://" string, preserving the plugin's existing behavior. (Note: ActiveMQ 5 advertises its expected topic:// prefix in the initial connection properties, so we could read that value dynamically, but RabbitMQ and Artemis do not send an expected topic prefix connection properties, so we just make the user choose explicitly here.)
This commit is contained in:
parent
dc47bcc8cc
commit
dbacf1f985
4 changed files with 41 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import absolute_import
|
|||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
import pytest
|
||||
|
||||
import protonmsg
|
||||
import mock
|
||||
|
|
@ -488,3 +489,17 @@ send_timeout = 60
|
|||
self.assertEqual(event.container.schedule.return_value.cancel.call_count, 2)
|
||||
self.assertTrue(self.handler.connect_task is None)
|
||||
self.assertTrue(self.handler.timeout_task is None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('topic_prefix,expected', (
|
||||
('koji', 'topic://koji'),
|
||||
('brew', 'topic://brew'),
|
||||
('topic://koji', 'topic://koji'),
|
||||
('/topic/koji', '/topic/koji'),
|
||||
))
|
||||
def test_topic_prefix(topic_prefix, expected):
|
||||
conf = ConfigParser()
|
||||
conf.add_section('broker')
|
||||
conf.set('broker', 'topic_prefix', topic_prefix)
|
||||
handler = protonmsg.TimeoutHandler('amqp://broker1.example.com:5672', [], conf)
|
||||
assert handler.topic_prefix == expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue