*/
@Override
public void onMessage(final Message message) {
// Casting and unwrapping
final ObjectMessage objectMessage;
try {
objectMessage = ObjectMessage.class.cast(message);
} catch (final ClassCastException cce) {
throw new RuntimeException("Incorrect message type sent to object message consumer; got:"
+ message.getClass().getSimpleName(), cce);
}
final MailMessageBuilder.MailMessage mailMessage;
try {
final Object obj = objectMessage.getObject();
mailMessage = MailMessageBuilder.MailMessage.class.cast(obj);
} catch (final JMSException jmse) {
throw new RuntimeException("Could not unwrap JMS Message", jmse);
} catch (final ClassCastException cce) {
throw new RuntimeException("Expected message contents of type "