Reputation: 83
I am building an application which reveives message from a Message Queue , Process it and and send the generated response to another 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.
I have fetched CorrelationID and Message ID using the below code.
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. 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.
Thanks in Advance.
Upvotes: 1
Views: 3158
Reputation: 83
Found the answer. I used instanceof keyword.
if(Requestmessage instanceof TextMessage )
{
//
}
if(Requestmessage instanceof BytesMessage)
{
//
}
if(Requestmessage instanceof ObjectMessage)
{
//
}
if(Requestmessage instanceof StreamMessage)
{
//
}
Upvotes: 3