From e060e28c2857a276cd51a992c87116303a7b9aa7 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 27 Feb 2023 14:01:21 -0500 Subject: [PATCH] Needed an additional check for empty correlation keys - which on a RECEIVE message, should always match anything. When finding messages to match a send, assure they are RECIEVE messages. Fix some of the json output for messages sent to the front end --- .../models/message_instance.py | 5 +++ .../services/message_service.py | 5 +-- spiffworkflow-frontend/src/interfaces.ts | 3 +- .../src/routes/MessageInstanceList.tsx | 31 ++++++++++--------- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/message_instance.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/message_instance.py index 6443f1495..3c278b925 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/message_instance.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/message_instance.py @@ -100,6 +100,11 @@ class MessageInstanceModel(SpiffworkflowBaseDBModel): # We know we have a match, and we can just return if we don't have to figure out the key return True + if self.correlation_keys == {}: + # Then there is nothing more to match on -- we accept any message with the given name. + return True + + # Loop over the receives' correlation keys - if any of the keys fully match, then we match. for expected_values in self.correlation_keys.values(): if self.payload_matches_expected_values( diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/message_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/message_service.py index 0d0060bc2..ddd4f4979 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/message_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/message_service.py @@ -1,6 +1,6 @@ """Message_service.""" from spiffworkflow_backend.models.db import db -from spiffworkflow_backend.models.message_instance import MessageInstanceModel +from spiffworkflow_backend.models.message_instance import MessageInstanceModel, MessageTypes from spiffworkflow_backend.models.message_instance import MessageStatuses from spiffworkflow_backend.models.message_triggerable_process_model import ( MessageTriggerableProcessModel, @@ -42,7 +42,8 @@ class MessageService: # Find available messages that might match available_receive_messages = MessageInstanceModel.query.filter_by( - name=message_instance_send.name, status=MessageStatuses.ready.value + name=message_instance_send.name, status=MessageStatuses.ready.value, + message_type=MessageTypes.receive.value ).all() message_instance_receive: MessageInstanceModel | None = None try: diff --git a/spiffworkflow-frontend/src/interfaces.ts b/spiffworkflow-frontend/src/interfaces.ts index f86a7bb5e..4c28376cf 100644 --- a/spiffworkflow-frontend/src/interfaces.ts +++ b/spiffworkflow-frontend/src/interfaces.ts @@ -112,12 +112,13 @@ export interface MessageInstance { process_model_identifier: string; process_model_display_name: string; process_instance_id: number; - message_identifier: string; + name: string; message_type: string; failure_cause: string; status: string; created_at_in_seconds: number; message_correlations?: MessageCorrelations; + correlation_keys: any; } export interface ReportFilter { diff --git a/spiffworkflow-frontend/src/routes/MessageInstanceList.tsx b/spiffworkflow-frontend/src/routes/MessageInstanceList.tsx index a9ec6b69f..c1a1658ec 100644 --- a/spiffworkflow-frontend/src/routes/MessageInstanceList.tsx +++ b/spiffworkflow-frontend/src/routes/MessageInstanceList.tsx @@ -64,14 +64,14 @@ export default function MessageInstanceList() { open={!!messageInstanceForModal} passiveModal onRequestClose={handleCorrelationDisplayClose} - modalHeading={`Message ${messageInstanceForModal.id} (${messageInstanceForModal.message_identifier}) ${messageInstanceForModal.message_type} data:`} + modalHeading={`Message ${messageInstanceForModal.id} (${messageInstanceForModal.name}) ${messageInstanceForModal.message_type} data:`} modalLabel="Details" > {failureCausePre}

Correlations:

             {JSON.stringify(
-              messageInstanceForModal.message_correlations,
+              messageInstanceForModal.correlation_keys,
               null,
               2
             )}
@@ -95,21 +95,24 @@ export default function MessageInstanceList() {
           
         );
       }
+      let processLink = External Call
+      let instanceLink = 
+      if (row.process_instance_id != null) {
+        processLink = FormatProcessModelDisplayName(row)
+        instanceLink =
+          
+            {row.process_instance_id}
+          
+      }
       return (
         
           {row.id}
-          {FormatProcessModelDisplayName(row)}
-          
-            
-              {row.process_instance_id}
-            
-          
-          {row.message_identifier}
+          {processLink}
+          {instanceLink}
+          {row.name}
           {row.message_type}