Doesn't work for me in 3.0, and that's because it's not part of the session until $app->redirect() occurs. My preference is to kill the message when it occurs, if possible, or remove it from the queue immediately after it occurs if I have no control over it (ahem, PHPMailer)
I can see that messages are there by $app->getMessageQueue(); - so I know they exist in $app->_messageQueue, which is protected.
This is how I finally accomplished it. Using Reflection, I can alter protected properties. This function was written for removing a specific message, for which you know the exact message content. You could easily adapt this to set the value to an empty array and kill the entire queue. Pass it an application object, and the error message and voila!
function _killMessage($app,$error) {
$appReflection = new ReflectionClass(get_class($app));
$_messageQueue = $appReflection->getProperty('_messageQueue');
$_messageQueue->setAccessible(true);
$messages = $_messageQueue->getValue($app);
foreach($messages as $key=>$message) {
if($message['message'] == $error) {
unset($messages[$key]);
}
}
$_messageQueue->setValue($app,$messages);
}