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
This commit is contained in:
Dan 2023-02-27 14:01:21 -05:00
parent c0bbba6f85
commit 4b4bbeff25
4 changed files with 27 additions and 17 deletions

View File

@ -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(

View File

@ -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:

View File

@ -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 {

View File

@ -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}
<p>Correlations:</p>
<pre>
{JSON.stringify(
messageInstanceForModal.message_correlations,
messageInstanceForModal.correlation_keys,
null,
2
)}
@ -95,21 +95,24 @@ export default function MessageInstanceList() {
</>
);
}
let processLink = <span>External Call</span>
let instanceLink = <span></span>
if (row.process_instance_id != null) {
processLink = FormatProcessModelDisplayName(row)
instanceLink =
<Link
data-qa="process-instance-show-link"
to={`/admin/process-instances/${modifyProcessIdentifierForPathParam(
row.process_model_identifier)}/${row.process_instance_id}`}>
{row.process_instance_id}
</Link>
}
return (
<tr key={row.id}>
<td>{row.id}</td>
<td>{FormatProcessModelDisplayName(row)}</td>
<td>
<Link
data-qa="process-instance-show-link"
to={`/admin/process-instances/${modifyProcessIdentifierForPathParam(
row.process_model_identifier
)}/${row.process_instance_id}`}
>
{row.process_instance_id}
</Link>
</td>
<td>{row.message_identifier}</td>
<td>{processLink}</td>
<td>{instanceLink}</td>
<td>{row.name}</td>
<td>{row.message_type}</td>
<td>
<Button