1 package com.atlassian.messagequeue.registry;
2
3 import com.atlassian.annotations.PublicApi;
4
5 import java.util.Map;
6
7 /**
8 * Provides a mechanism to validate or filter messages based on their attributes and context.
9 * @since 1.0.6
10 */
11 @PublicApi
12 public interface MessageValidator {
13
14 /**
15 * Is the message valid? If not then the message will not be processed by its message runner, and handleInvalidMessage will be called.
16 * @param messageContext the message context
17 * @param messageAttributes an immutable map of the message's attributes
18 * @return boolean validity of the message
19 */
20 boolean isValid(MessageContext messageContext, Map<String, String> messageAttributes);
21
22 /**
23 * handleInvalidMessage is called for any message that fails {@link #isValid(MessageContext, Map) isValid}.
24 * @param messageContext the message context
25 * @param messageAttributes an immutable map of the message's attributes
26 */
27 void handleInvalidMessage(MessageContext messageContext, Map<String, String> messageAttributes);
28 }