common/src/main/java/org/beiter/michael/authn/jaas/common/messageq/MessageHelper.java
public static void postMessage(final MessageQ messageQ, final String domain, final String username,
                                   final Events event, final String error)
            throws LoginException {

        // "messageQ" may be null, not validating here (see below)
        Validate.notBlank(domain, "The validated character sequence 'domain' is null or empty");
        Validate.notBlank(username, "The validated character sequence 'username' is null or empty");
        Validate.notNull(event, "The validated object 'event' is null");
        Validate.notBlank(error, "The validated character sequence 'error' is null or empty");

        // if message queues are disabled, the messageQ object will not have been initialized
        if (messageQ == null) {
            // string concatenation is only executed if log level is actually enabled
            if (LOG.isDebugEnabled()) {
                LOG.debug("Messages queues have been disabled, not creating event '"
                        + event.getValue() + "' for '" + username + "@" + domain + "'");
            }
        } else {
            try {
                messageQ.create(event, domain, username);
            } catch (MessageQException e) {
                LOG.warn(error, e);
                throw Util.newLoginException(error, e);
            }
        }
    }
public static void postMessage(final MessageQ messageQ, final String domain, final String username,
                                   final Events event, final String error)
            throws LoginException {

        // "messageQ" may be null, not validating here (see below)
        Validate.notBlank(domain, "The validated character sequence 'domain' is null or empty");
        Validate.notBlank(username, "The validated character sequence 'username' is null or empty");
        Validate.notNull(event, "The validated object 'event' is null");
        Validate.notBlank(error, "The validated character sequence 'error' is null or empty");

        // if message queues are disabled, the messageQ object will not have been initialized
        if (messageQ == null) {
            // string concatenation is only executed if log level is actually enabled
            if (LOG.isDebugEnabled()) {
                LOG.debug("Messages queues have been disabled, not creating event '"
                        + event.getValue() + "' for '" + username + "@" + domain + "'");
            }
        } else {
            try {
                messageQ.create(event, domain, username);
            } catch (MessageQException e) {
                LOG.warn(error, e);
                throw Util.newLoginException(error, e);
            }
        }
    }
Post a message queue event (during a login workflow).
<p>
If {@code messageQ} is {@code null}, then messaging is considered disabled.

@param messageQ The message queue object to use for posting the message
@param domain   The user's domain
@param username The user's username
@param event    The event to post
@param error    The error message to be logged in the application log if the message queue post fails (i.e. no
message queue event can be created)
@throws LoginException           If posting to the message queue fails (i.e. no message can be created)
@throws NullPointerException     When the {@code domain}, {@code username}, {@code event}, or {@code error} are
{@code null}
@throws IllegalArgumentException When {@code domain}, {@code username}, or {@code error} are empty