Within a Before Publish event handler, you can prevent the message from being published by returning request.abort(). Returning request.ok() allows the message to be published.

// in before publish event handler
export default (request) => {
    // isPreventPublish is some condition that your code would determine 
    // whether the message should be published or not
    if (isPreventPublish) {
        return request.abort();

    // all is well, proceed with publishing the message
    return request.ok();

See Also: