From 12a9e8aaaf7f533e95e6e6a52ab3c305e54e19d1 Mon Sep 17 00:00:00 2001 From: Rudi Schlatte Date: Wed, 28 Feb 2024 17:16:34 +0100 Subject: [PATCH] Try to fix filename of incoming app message We want to have -app-message-.json, but before we try to parse the file. Try to fish the application-id out of the message subject or, failing that, of the "application" property. Change-Id: Ibe2f517ff213a0726a10ecebe407f8cb9e5d0de4 --- .../eu/nebulouscloud/optimiser/controller/ExnConnector.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/optimiser-controller/src/main/java/eu/nebulouscloud/optimiser/controller/ExnConnector.java b/optimiser-controller/src/main/java/eu/nebulouscloud/optimiser/controller/ExnConnector.java index b8bce1e..2f523a7 100644 --- a/optimiser-controller/src/main/java/eu/nebulouscloud/optimiser/controller/ExnConnector.java +++ b/optimiser-controller/src/main/java/eu/nebulouscloud/optimiser/controller/ExnConnector.java @@ -167,6 +167,8 @@ public class ExnConnector { public void onMessage(String key, String address, Map body, Message message, Context context) { try { String app_id = message.subject(); + if (app_id == null) app_id = message.property("application").toString(); // should be string already, but don't want to cast + // if app_id is still null, the filename will look a bit funky but it's not a problem log.info("App creation message received", keyValue("appId", app_id)); JsonNode appMessage = mapper.valueToTree(body); Main.logFile("app-message-" + app_id + ".json", appMessage);