user2280005
user2280005

Reputation: 21

ActiveMQ - Object cannot be recognized when receive from JMS remote host

I am setting up a JMS request reply on two JBoss servers. In the client, i use camel-jms and Fuse route to create the call.

.setExchangePattern(ExchangePattern.InOut)
.to(camelContext.getEndpoint(JMS_BEANID, JmsQueueEndpoint.class))

Basically it will create temporary queue and send to the server. In the server I create implementation of MessageListener to listen to the message.

From debugging view message.getJMSReplyTo() returns an instance of ActiveMQTemporaryQueue. However, when I try to check message.getJMSReplyTo() instanceof ActiveMQTemporaryQueue it returns false. I try to create ActiveMQTemporaryQueue myself the check returns true as expected, e.g.:

public void onMessage(Message message) {
    Destination replyTo = message.getJMSReplyTo();
    if (replyTo instanceof ActiveMQTemporaryQueue) {
        // false, although the debugger show it is ActiveMQTemporaryQueue object
    }
    Destination test = new ActiveMQTemporaryQueue("localhost", "testQueue", (ActiveMQSession)session);
    if (test instanceof ActiveMQTemporaryQueue) {
        // true
    }
}

The client and the server are in two different Maven projects (two different war, deployed onto different servers, same workspace).

I don't know what is happening. Do you have any suggestions?

Upvotes: 0

Views: 151

Answers (1)

Justin Bertram
Justin Bertram

Reputation: 35162

My guess is that this is a classloading issue of some kind, but it's hard to tell with the information you've provided.

That said, I strongly recommend that you do not use any implementation objects in your code (i.e. ActiveMQTemporaryQueue). If all you're trying to do is a request/reply then there is absolutely no need to use any implementation objects. If you need to know if the value returned by getJMSReplyTo() is a temporary queue then you can simply use replyTo instanceof javax.jms.TemporaryQueue. If you do that I think your issue will be resolved.

Upvotes: 1

Related Questions