powered by Jive Software

Why does my PacketInterceptor gets called 3 times for each message?

This is my PacketInterceptor:

public abstract class AbstractMessageListener implements PacketInterceptor
{        private static final Logger LOGGER = LoggerFactory.getLogger(AbstractMessageListener.class);     private XMPPServer mServer = XMPPServer.getInstance();     @Override
    public void interceptPacket(Packet pPacket, Session pSession, boolean pIncoming, boolean pProcessed)
    {
        // only check for incoming packets in output queue
        if(!pIncoming && pProcessed)
        {
            return;
        }         // check for message packet to local user
        if(pPacket instanceof Message && mServer.isLocal(pPacket.getTo()))
        {
            Message m = (Message)pPacket;
            if(LOGGER.isTraceEnabled())
            {
                LOGGER.trace("received message: {}", m);
            }
            onMessage(m);
        }
    }     protected abstract void onMessage(Message pMessage);
}

So I would expect it to receive each message exactly one time. But instead this is what I see in the logs:

2013.08.05 23:00:22 de.mypackage.openfire.AbstractMessageListener - received message:

ja doch, schon

2013.08.05 23:00:22 de.mypackage.openfire.AbstractMessageListener - received message:

ja doch, schon

2013.08.05 23:00:22 org.jivesoftware.openfire.nio.ClientConnectionHandler - [/127.0.0.1:55504] Filtered Write: org.apache.mina.filter.support.SSLHandler@1179ae1

2013.08.05 23:00:22 org.jivesoftware.openfire.nio.ClientConnectionHandler - [/127.0.0.1:55504] encrypt: HeapBuffer[pos=0 lim=240 cap=4096: 3C 6D 65 73 73 61 67 65 20 66 72 6F 6D 3D 22 6B 65 76 69 6E 66 69 73 63 68 65 72 40 6A 61 62 62 65 72 2E 63 63 63 2E 64 65 2F 31 30 38 30 36 35 37 33 31 37 31 33 37 35 37 31 37 33 34 34 32 33 33 36 34 38 22 20 74 6F 3D 22 63 68 72 69 73 6C 69 65 62 61 65 72 40 78 6D 70 70 2E 63 68 72 69 73 6C 69 65 62 61 65 72 2E 64 65 2F 4C 61 70 74 6F 70 22 20 74 79 70 65 3D 22 63 68 61 74 22 20 69 64 3D 22 70 75 72 70 6C 65 38 35 37 31 34 35 34 31 22 3E 3C 61 63 74 69 76 65 20 78 6D 6C 6E 73 3D 22 68 74 74 70 3A 2F 2F 6A 61 62 62 65 72 2E 6F 72 67 2F 70 72 6F 74 6F 63 6F 6C 2F 63 68 61 74 73 74 61 74 65 73 22 2F 3E 3C 62 6F 64 79 3E 6A 61 20 64 6F 63 68 2C 20 73 63 68 6F 6E 3C 2F 62 6F 64 79 3E 3C 2F 6D 65 73 73 61 67 65 3E]

2013.08.05 23:00:22 org.jivesoftware.openfire.nio.ClientConnectionHandler - [/127.0.0.1:55504] Wrap res:Status = OK HandshakeStatus = NOT_HANDSHAKING

bytesConsumed = 240 bytesProduced = 314

2013.08.05 23:00:22 org.jivesoftware.openfire.nio.ClientConnectionHandler - [/127.0.0.1:55504] encrypted buf: HeapBuffer[pos=0 lim=314 cap=314: 17 03 01 00 20 4B D2 FD C8 D1 87 AF 6A F1 58 DE 13 55 A0 E5 A7 68 D9 0F DD 0D 51 C3 E0 7F FD 42 65 4D E7 8D BC 17 03 01 01 10 EF 5C 95 95 76 FC DA 60 FB A8 F4 64 47 8A 05 01 EE 04 6D 93 B9 05 FE 29 A7 4B 06 EE 51 ED 0B 02 BF B8 D8 55 58 D4 19 6A 16 98 16 FB 6A 92 A7 04 C7 17 89 66 A8 5E D0 CE 7E 1B EE 1F 1B 68 38 6C D0 08 16 B1 FF 9D 9A 72 11 E3 65 53 0B 64 53 9B 3C F8 B8 5D 43 88 7F 20 EA 43 EB 56 60 80 5D D4 B8 E6 FF E4 00 E1 66 FE 25 90 24 46 7A A0 2B 56 21 9C 02 1E 66 53 FF C8 94 5C 89 F9 2D 90 1B 4D 15 F5 DB 02 40 E0 77 44 3B CA 10 4C 6A 46 48 90 29 F1 DD AD 81 AB CF 33 BA 30 03 C9 37 8E AF 0F 92 D4 2A AD AF DE C1 3A 3A F7 B2 99 97 74 3C 3A 68 8F F1 4B F7 38 78 64 5C 9A 34 07 74 6F AE E2 0C 91 FD C0 AF 6C AE CF B2 E0 0E 7F 07 02 48 60 6A 01 54 8F 88 36 DF 05 E6 00 83 78 BE 06 61 B5 08 05 4A 08 E4 CD 07 E4 A7 6E 1D 53 31 96 E9 5E E1 9F EF 90 E4 7F 50 ED 45 99 81 BF 86 66 32 66 FF F7 E9 DF 09 8D 99 A6 40 AE 71 3B 2F 7A DC DB]

2013.08.05 23:00:22 org.apache.mina.filter.executor.ExecutorFilter - Launching thread for /127.0.0.1:55504

2013.08.05 23:00:22 de.mypackage.openfire.AbstractMessageListener - received message:

ja doch, schon

As you migth have noticed. This messages was send from another network, but it should this should not happen, rigth?

What am I do wrong?

Never mind. The if is wrong. I should go to sleep

// only check for incoming packets in output queue **if**(!pIncoming && pProcessed) { **return**; }