Skip to content

Display correct headers for a message when using the search API #663

@boblangley

Description

@boblangley

Retrieving message headers uses the ServiceControl search API:

function getMessageHeaders(messageId) {
var url = uri.join(scConfig.service_control_url, 'messages', 'search', messageId);
return $http.get(url).then(function(response) {
return {
data: response.data
};
});
}

The search API returns more than one message if they each contain the searched-for message id.

Previously, when headers were retrieved, only the first message returned was used:

serviceControlService.getMessageHeaders(message.message_id).then(function (msg) {
message.messageHeaders = msg.data[0].headers;
}, function () {

This caused ServicePulse to display the incorrect headers for a given message, causing confusion.

Normally this wasn't a problem for a user, however in scenarios where the MessageFailed event was subscribed to, and itself fails, the original failed message and the MessageFailed event message could cause this scenario to happen. The MessageFailed event contains a property that indicates the id of the failed message, which is why it was returned in the search results and can be mistakenly used.

Details of change

In the search results, the correct message header is now displayed for each message.

Steps to reproduce

  1. Alter the ServiceControl events sample to turn on auditing in the EndpointsMonitor endpoint
  2. Run the sample
  • This will attempt to process a SimpleMessage message, which will fail.
  • The failed message will go to the error queue and will get picked up by ServiceControl
  • ServiceControl will publish a MessageFailed event that contains the original message id in it's message body
  • The EndpointsMonitor endpoint will process the MessageFailed event and send a copy to ServiceControl
  • ServiceControl will read this audited message and add it to the database
  • Now there are two messages in the database with the same Id but only one of them is the original failed message
  1. Open ServicePulse and navigate to the failed messages screen
  2. Find the failed message and open the headers tab.
  • The wrong headers are displayed. If you followed the steps above, the easiest way to see this is that the message type is MessageFailed and not SimpleMessage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions