Interceptor problem - Unable to get address from message
lowecg2004 Jul 13, 2010 7:21 PMHello,
I have an interceptor defined where I want to run some debug logging. The first message is captured fine, but
subsequent messages do not have an address so my code ignores them:
public boolean intercept(final Packet packet, final RemotingConnection connection) throws HornetQException { try { if (packet instanceof SessionSendMessage) { final SessionSendMessage realPacket = (SessionSendMessage) packet; final Message msg = realPacket.getMessage(); if (msg instanceof ServerMessage) { // ******* FIRST TIME OKAY, BUT IS NULL ON SUBSEQUENT VISITS final String queue = (msg.getAddress() == null) ? null : msg.getAddress().toString(); if (queue != null) { // Record all messages heading for the command, response // and session queues. if (queue.startsWith("jms.queue.lgp") || queue.startsWith("jms.queue.session")) { logMessage(msg); } } else { System.err.println("No queue: " + msg.getPropertyNames() + " - logme = " + msg.getStringProperty("logme") + ", msg = " + msg + " remote address = " + connection.getRemoteAddress()); } } } } catch (final Exception cause) { System.err.println("[INTERCEPTOR] Caught exception " + cause); } return true; }The messages ARE going through and I'm getting responses from my client app, however I get the "no queue" message because there is no address on the SessionSendMessage object. Interestingly where "no queue" is printed, the "logme" property prints a value which is assigned to the message when it is sent.
I'm using the same session, queue and producer objects on each send.
Is this expected behaviour and, if so, how can I reliably determine the message destination queue from within the interceptor?
Environment wise I'm sending the message from a Seam component. The HornetQ server is 2.1.0 Final and embedded within Jboss 5.1.0 - just a dev environment (Win 7, 64bit OS, 32bit 1.6_21 JVM) and no-clustering. The JMS client is an external process connecting directly to JBoss via JNDI.
Cheers,
Chris.