我有一个使用javax.jms *类的java程序将消息发布到MQ主题(MQv7.5),很少有消息进入DLQ,DLQ Header中有以下详细信息,
格式'无格式' 原因' 3023' - > 3023 0x00000bcf MQRCCF_MD_FORMAT_ERROR
消息中的标题信息:
DeadLetter Header Information Encoding 'Default Encoding' Character Set 'ibm1208' Format 'No Format' Reason '3023' Destination Queue Manager 'QMGRSTCRT1' Destination Queue ' ' Put Appl Name 'WebSphere MQ Client for Java' Put Appl Type 'Java' Date/Time '20150127-19271043' RFH Header Information Encoding 'Default Encoding' Character Set 'ibm1208' Flags '0' Format 'No Format' Name Value Pair 'UNIQUE_CONNECTION_ID', '414D512045414D51534331202020202054B921242739A302 MQPSCommand Publish MQPSTopic CUSTOMER_EVENT MQPSPubOpts NoReg ' MQMD Put Date 'Tue Jan 07 13:38:44 CST 2015' Message ID: '414D512045414D51534331202020202054B9212427896148' Correlation ID: '414D512045414D515343312020202020542907882CEF7E04' Group ID: '000000000000000000000000000000000000000000000000' Account Token: '0000000000000000000000000000000000000000000000000000000000000000' AppID Data: ' ' App Origin Data: ' ' Backout Count: '0' Character Set: 'ibm1208' Expiry: '14' Format: 'RFH version 1' Encoding: 'Default Encoding' Feedback: 'None' Message Flags: 'None' Offset: '0' Sequence Number: '1' Type: 'Datagram' Persistence: 'Not Persistent' Priority: '4' Put Appl Name: 'QMGRSTCRT1 ' Put Appl Type: '26' Reply To Queue Manager: 'QMGRSTCRT1 ' Reply To Queue Name: ' ' Report: 'Default Report Options, New Msg ID, Copy Msg ID to Correlation ID, Dead Letter Q' User ID: 'tempid ' Version: '2' Content Type: 'writestring' JMS properties JMSDeliveryMode 2 JMSDestination topic://CUSTOMER_EVENT JMSTimestamp 1422387524491 mcd.Msd jms_object JMSExpiration 1422391124491
添加与DLQ消息对应的Qmgr日志..
AMQ5882: WebSphere MQ Publish/Subscribe broker has written a message to the dead-letter queue. EXPLANATION: The broker has written a message to the dead-letter queue (SYSTEM.DEADLETTER.QUEUE ) for reason '3023:MQRCCF_MD_FORMAT_ERROR'. Note. To save log space, after the first occurrence of this message for stream (TEST.PUBSUB ), it will only be written periodically. ACTION: If the message was not deliberately written to the dead-letter queue, for example by a message broker exit, determine why the message was written to the dead-letter queue, and resolve the problem that is preventing the message from being sent to its destination.
程序中使用的代码段
private TopicConnection topicConnection = null;
private TopicSession topicSession = null;
private TopicPublisher topicPub = null ;
private TopicSubscriber topicSub = null ;
protected void createTopicPub(String clientID,long msgLifeTime)抛出JMSException { closeTopicPub();
if (topicSession == null)
createTopicConnectionWithClientID(clientID);
Topic the_topic = (Topic)topicSession.createTopic(topicName);
topicPub = topicSession.createPub(the_topic);
topicPub.setDeliveryMode(DeliveryMode.PERSISTENT);
topicPub.setPriority(4);
//SET the time to expire the message
topicPub.setTimeToLive(msgLife);
topicConnection.start();
}
public void sendMessage(String msg) throws JMSException {
TextMessage message = null ;
if (topicPub == null) {
throw new JMSException("TopicPub is null");
}
message = topicSession.createTextMessage(msg);
topicPub.publish(message);
log.debug("Message sent");
}
private void createTopicConnWithClientID(String clientID) throws JMSException {
closeTopicConnection();
MQTopicConnectionFactory topicCF = new MQTopicConnectionFactory();
topicCF.setHostName(hostName);
topicCF.setPort(portNumber);
topicCF.setQueueManager(queueManager);
topicCF.setChannel(channel);
topicCF.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
// create connection and session
topicConnection = topicCF.createTopicConnection();
topicConnection.setClientID(clientID);
topicSession = topicConnection.createTopicSession(transactional,Session.AUTO_ACKNOWLEDGE);
}
导致MD格式错误的原因是什么?需要更正的地方在哪里?
答案 0 :(得分:4)
此错误代码MQRCCF_MD_FORMAT_ERROR
表示邮件的MQMD格式字段的值不是MQFMT_ADMIN
。
IBM MQ的各个部分期望获得Format = MQFMT_ADMIN
的消息: -
根据提供的AMQERR01.LOG错误消息,我们可以看到相关功能是排队的发布/订阅代理。
由于您使用的是V7.5,因此您不需要使用排队的pub / sub,您可以直接使用这些主题。你说你的应用程序是Java,但不要提及它是否是JMS。使用排队的pub / sub与直接使用主题是在JMS的封面下进行的,因此您可能不知道自己正在这样做。检查PROVIDERVERSION
是否设置为7而不是6.