从WAS Liberty读取消息并将消息写入MQ

时间:2019-07-10 21:18:13

标签: ibm-mq websphere-liberty spring-jms

我们试图使用JMS模板发送MAP(java.util),但是在客户端,我们无法读取该消息,并且在服务器启动过程中,spring boot @JMSListener会显示以下消息,这可以正常工作在WAS 7中,但在WAS Liberty 8.5.5中没有,iam还包括代码段以及我们为不同版本的服务器接收的不同消息格式。 WAS Liberty有什么变化吗?

曾经是自由主义者-7-

#include <stdlib.h>

void *bsearch(const void *key, const void *base,
              size_t nmemb, size_t size,
              int (*compar)(const void *, const void *))
{
    const unsigned char *p;
    size_t m;
    int r;

    while (nmemb > 0) {
        m = (nmemb - 1) >> 1;
        p = (const unsigned char *)base + m * size;
        if ((r = compar(key, p)) < 0) {
            nmemb = m;
        } else
        if (r > 0) {
            base = p + size;
            nmemb -= m + 1;
        } else
        if (m == 0) {
            return (void *)p;
        } else {
            /* continue search to return first matching entry */
            nmemb = m + 1;
        }
    }
    // if you want the insertion point, you can return p here
    return NULL;
}

消息是MAP

at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:116) ~[spring-messaging-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2019-07-05T13:07:14.357-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:114) ~[spring-jms-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2019-07-05T13:07:14.357-05:00 [APP/PROC/WEB/0] [OUT] ... 10 common frames omitted
2019-07-05T13:07:14.393-05:00 [APP/PROC/WEB/0] [OUT] 2019-07-05 18:07:14.370 WARN 20 --- [enerContainer-1] o.s.j.l.DefaultMessageListenerContainer : Execution of JMS message listener failed, and no ErrorHandler has been set.
2019-07-05T13:07:14.394-05:00 [APP/PROC/WEB/0] [OUT] org.springframework.jms.listener.adapter.ListenerExecutionFailedException: Listener method 'public void com.aa.amps.base.task.finalize.BaseBowUpdateListener.receiveMessage(javax.jms.MapMessage)' threw exception; nested exception is org.springframework.jms.support.converter.MessageConversionException: Could not find type id property [_type] on message [ID:414d51204d454d5154433120202020205ccc4b2725acdc4c] from destination [null]

WAS-自由消息格式

 jmsTemplate.convertAndSend(destination, message, new MessagePostProcessor() {
                    @Override
                    public Message postProcessMessage(Message message) throws JMSException {
                        message.setJMSReplyTo(null);
                        LOGGER.info("In BaseBowUpdateSender - send() message to AMPS-BASE QUEUE : {} ", message);
                        return message;
                    }
                });

下面的预期消息

JMSMessage class: jms_text
  JMSType:          null
  JMSDeliveryMode:  2
  JMSDeliveryDelay: 0
  JMSDeliveryTime:  0
  JMSExpiration:    0
  JMSPriority:      4
  JMSMessageID:     ID:414d51204d454d5154433120202020205ccc4b272634ce4d
  JMSTimestamp:     1562784513140
  JMSCorrelationID: null
  JMSDestination:   null
  JMSReplyTo:       null
  JMSRedelivered:   true
    JMSXAppID: jar                         
    JMSXDeliveryCount: 193
    JMSXUserID: apmqstc     
    JMS_IBM_Character_Set: UTF-8
    JMS_IBM_Encoding: 273
    JMS_IBM_Format: MQSTR   
    JMS_IBM_MsgType: 8
    JMS_IBM_PutApplType: 28
    JMS_IBM_PutDate: 20190710
    JMS_IBM_PutTime: 18483314
<map><elt name="trackType">03</elt><elt name="lastDefferDate">07/10/2019</elt><elt name="packageDesc ...

1 个答案:

答案 0 :(得分:1)

我的应用程序(JMS应用程序)将WebSphere MQ消息放入队列。这些消息将由jms应用程序接收。我误解了targetClientId选项,以为如果我们编写的消息是MQ则需要将targetClientId提到为“ mq”,但事实并非如此。仅当我们使用非以下方式处理消息时,才需要将targetClientId设置为MQ: jms应用程序。当我将targetClientId设置为'MQ'时,它剥离了JMS应用程序处理消息所需的RFH标头,并且在使用该应用程序时解析失败。

        <jmsQueue id="MYAPP_QUEUE" jndiName="jms/test/testq">
            <properties.wmqJms 
                baseQueueName="MYAPP.TEST.A" 
                persistence="PERS" 
                targetClient="MQ"/> -- removed this 
        </jmsQueue>