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 ff069cb862
commit e060e28c28
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 # We know we have a match, and we can just return if we don't have to figure out the key
return True 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. # Loop over the receives' correlation keys - if any of the keys fully match, then we match.
for expected_values in self.correlation_keys.values(): for expected_values in self.correlation_keys.values():
if self.payload_matches_expected_values( if self.payload_matches_expected_values(

View File

@ -1,6 +1,6 @@
"""Message_service.""" """Message_service."""
from spiffworkflow_backend.models.db import db 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_instance import MessageStatuses
from spiffworkflow_backend.models.message_triggerable_process_model import ( from spiffworkflow_backend.models.message_triggerable_process_model import (
MessageTriggerableProcessModel, MessageTriggerableProcessModel,
@ -42,7 +42,8 @@ class MessageService:
# Find available messages that might match # Find available messages that might match
available_receive_messages = MessageInstanceModel.query.filter_by( 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() ).all()
message_instance_receive: MessageInstanceModel | None = None message_instance_receive: MessageInstanceModel | None = None
try: try:

View File

@ -112,12 +112,13 @@ export interface MessageInstance {
process_model_identifier: string; process_model_identifier: string;
process_model_display_name: string; process_model_display_name: string;
process_instance_id: number; process_instance_id: number;
message_identifier: string; name: string;
message_type: string; message_type: string;
failure_cause: string; failure_cause: string;
status: string; status: string;
created_at_in_seconds: number; created_at_in_seconds: number;
message_correlations?: MessageCorrelations; message_correlations?: MessageCorrelations;
correlation_keys: any;
} }
export interface ReportFilter { export interface ReportFilter {

View File

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