简体   繁体   English

在JMS中获取消息类型-IBM MQ

[英]Get the Message Type in JMS - IBM MQ

I am building an application which reveives message from a Message Queue , Process it and and send the generated response to another queue. 我正在构建一个应用程序,该应用程序从Message Queue中获取消息,对其进行处理,然后将生成的响应发送到另一个队列。 I have successfully built the same. 我已经成功地建立了相同的。

But, before sending the msg I must get the Correlation ID, Message ID and Message Type from it, So that I will be able to set these in my generated response msg as well. 但是,在发送消息之前,我必须从中获取相关ID,消息ID和消息类型,以便我也能够在生成的响应消息中进行设置。

I have fetched CorrelationID and Message ID using the below code. 我已经使用以下代码获取了CorrelationID和Message ID。

               Message Requestmessage = ReceiveMessage(queueName);
               String correlationID = Requestmessage.getJMSCorrelationID();
               String messageID = Requestmessage.getJMSMessageID();

How will I get the Message Type. 我将如何获得消息类型。 There are 5 types of Messages as far as I understood. 据我了解,消息有5种类型。 1. Text Message 2. Byte Message 3. Stream Message 4. Object Message 5. Map Message All I need is, to find out which type my "Requestmessage" belongs to. 1.文本消息2.字节消息3.流消息4.对象消息5.映射消息我所需要的只是找出“请求消息”属于哪种类型。

Thanks in Advance. 提前致谢。

Found the answer. 找到了答案。 I used instanceof keyword. 我使用instanceof关键字。

        if(Requestmessage instanceof TextMessage )
        {
             //
        }

        if(Requestmessage instanceof BytesMessage)
        {
            //
        }
        if(Requestmessage instanceof ObjectMessage)
        {
            //          
        }
        if(Requestmessage instanceof StreamMessage)
        {
            //
        }

geJMSType() may be the method you are looking for. geJMSType()可能是您正在寻找的方法。 Did you go through the API docs in the info centre? 您是否在信息中心浏览过API文档?
http://pic.dhe.ibm.com/infocenter/wmqv7/v7r5/index.jsp?topic=%2Fcom.ibm.mq.javadoc.doc%2FWMQJMSClasses%2Fcom%2Fibm%2Fjms%2FJMSMessage.html http://pic.dhe.ibm.com/infocenter/wmqv7/v7r5/index.jsp?topic=%2Fcom.ibm.mq.javadoc.doc%2FWMQJMSClasses%2Fcom%2Fibm%2Fjms%2FJMSMessage.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM