TransientMessage with key and count
As we put more messages in TransientMessageService
we would like to prevent having the "same message" added multiple times to the in-memory list.
If, for example the email service fails to deliver a message, we don't want a unique warning "SMTP unreachable" to be added every time it happens because it could fill the message list and other important messages would be lost.
Two new fields are added to TransientMessage
: String key
and int count
.
The key
is identifies the message type and added to the line that adds the message, for example:
transientMessageService.addAdminAlert("ES-MAPPING-" + clazz, "The ES mapping is no longer compatible for index={} of {}. The index must be regenerated.", writeIndex, clazz);
The message service first looks up an existing message by key
and if found, increments the count. If not found, the message is added with count = 1
.