From eb954e9ceba3b161dbb8adc73e70e2e30733ac32 Mon Sep 17 00:00:00 2001 From: Ben Dalling Date: Mon, 30 Dec 2024 19:29:53 +0000 Subject: [PATCH] fix: Changes to ensure connection to Azure Service Bus. --- router.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/router.py b/router.py index 873d031..3206a5f 100644 --- a/router.py +++ b/router.py @@ -33,6 +33,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ +import itertools import json import logging import os @@ -311,6 +312,9 @@ def decode_message(self, message: bytes) -> str: """ if isinstance(message, str): return message + elif isinstance(message, memoryview): + message = message.tobytes() + return message.decode('utf-8') def get_data(self, message: object) -> list: @@ -344,7 +348,7 @@ def get_data(self, message: object) -> list: result = jmespath.search(self.jmespath, message) if isinstance(result, list): - return result + return list(itertools.chain.from_iterable(result)) elif result is None: return [] @@ -740,7 +744,7 @@ def on_start(self, event): for url in self.connections.keys(): hostname = urlparse(url).hostname logger.debug(f'Creating a connection for {hostname}...') - connection = event.container.connect(url) + connection = event.container.connect(url, allowed_mechs='PLAIN') self.connections[url] = connection logger.info(f'Successfully created a connection for {hostname}.')