当我尝试在 Glassfish 3.1 Open MQ 上使用 JMS 发送Date
对象时,MapMessage
出现以下错误:
javax.jms.MessageFormatException: [C4017]: Invalid message format.
以下是我如何尝试发送Date
对象的代码MapMessage
:
public class JSenderMockClient {
public static void main(String[] args) {
try {
//using jndiContext to get ConnectionFactory, Queue, Session and stuff
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
MapMessage mapMessage = session.createMapMessage();
mapMessage.setObject("now", new Date());
producer.send(mapMessage);
System.out.println("MapMessage \"now\" sent..");
} catch (Throwable ex) {
//just in case stuff
} finally {
//closing session and connection
}
}
}
有人可以帮我理解为什么我会得到这个例外吗?
谢谢。