Preprocessor plugin not being notified

Robert Larsen
Added almost 5 years ago


I am developing a preprocessor for logging direct IM messages between users (is a preprocessor the right choice?).

It compiles and I can see in the log that it is instanciated and initialized, but it never sees any packets.

I have updated '--sm-plugins' with a '+CegoIMLogger' which should enable it however it is not.

The code is attached and I have the follwing in the log:

2014-03-18 12:58:26.700 [main]             CegoIMLogger.<init>()              INFO:     Constructed: CegoIMLogger
2014-03-18 12:58:26.700 [main]             CegoIMLogger.supElementNamePaths()  INFO:    () : [[Ljava.lang.String;@7d882f01
2014-03-18 12:58:26.700 [main]             CegoIMLogger.supNamespaces()       INFO:     Asked for supNamespaces
2014-03-18 12:58:26.747 [main]             CegoIMLogger.init()                INFO:     In init {sm-jid=sess-man@robert-workstation, collection=im, mongodb-url=mongodb://localhost/chatlog}

Have I forgotten something?

Replies (4)

Added by Wojciech Kapcia TigaseTeam almost 5 years ago

You have following code:

        String[][] res = new String[][] {
            { "message", "body" }

so only messages with body element will be passed to your plugin. Are you sure you are sending such stanzas?

As for type of plugin. Pre-processors operate within session manager thread and they have no internal queue for processing hence if you expect that the logging may require more processing then, in order to avoid performance impact on session manager, it would be better to make the plugin a Processor.

Added by Robert Larsen almost 5 years ago

Yes, I sent this:

<message to=""
  <body xmlns="cego:chat:im">
</message> wasn't logged.

I've changed to using a processor instead just to be on the safe side.

Still, I get no message in the log:

2014-03-18 13:36:16.049 [main]             CegoIMLogger.<init>()              INFO:     Constructed: CegoIMLogger
2014-03-18 13:36:16.049 [main]             CegoIMLogger.supElementNamePaths()  INFO:    () : [[Ljava.lang.String;@7333994d
2014-03-18 13:36:16.049 [main]             CegoIMLogger.supNamespaces()       INFO:     Asked for supNamespaces
2014-03-18 13:36:16.091 [main]             CegoIMLogger.concurrentQueuesNo()  INFO:     () : 4
2014-03-18 13:36:16.092 [main]             CegoIMLogger.getComponentInfo()    INFO:     () : default-handler :: componentInfo{Title=Tigase XMPP Server, Version=5.2.0-b3447/48635d0a (2014-02-12/17:29:15), Class=tigase.server.xmppsession.SessionManager$DefaultHandlerProc}
2014-03-18 13:36:16.092 [main]             CegoIMLogger.init()                INFO:     In init {sm-jid=sess-man@robert-workstation, collection=im, mongodb-url=mongodb://localhost/chatlog}

Added by Artur Hefczyc TigaseTeam almost 5 years ago

For the preprocessor it does not matter what the plugin returns from supElementNamePaths method call or any other method. Everything which goes through SessionManager goes through preprocessors.

This partially answers your question: is a preprocessor the right choice?. The answer is: No it is not a right choice..

Because preprocessor intercepts all XMPP packets and you are only interested in certain packets type you are wasting resources intercepting packets you are not interested in. The only reason to make your plugin a preprocessor would be if you want to block or modify the packet before it is processed by the rest of plugins.

In your case, I suggest you base your code on existing tigase.xmpp.impl.Message plugin. It does exactly what you want it to do. You just have to replace existing process method body with your own code.

Now the question is, if your plugin loaded correctly and if preprocessor handles ALL packets going through SessionManager, why your code does not show anything? It is impossible to say for sure as we have too little logs but most likely your Message packet does not get to either SessionManager or is blocked before even preprocessor can handle it. It maybe blocked for a number of reasons, for example, the user connection is not authenticated or the user session is not established....

You have to look in Tigase's logs carefully to see your message incoming to ConnectionManager and then what happens next to the message.

Added by Robert Larsen almost 5 years ago

Thanks for your reply. Very useful.

I control both sender and receiver and the message turned up at the receiving end so sessions were established.

I changed to basing my class on the Message class and for some reason now I do get the messages...which makes no sense to me. I must have messed something else up.

Thanks for the help.