powered by Jive Software

Consume only special messages

Hi all,

I would like to know if it is possible to decide when consume a menssage from a xmmp server ?

Let me try to explain better… Imagine that i developed a bot to read all messages that the body of the message start with" MESSAGETOBOTONLY: " if i do the usual method to read a message


public void processMessage(Chat chat, Message message) {

if (message.getType() == Message.Type.chat) { … }

} "

All messages i received will be consumed and lost… What i want is just to consume messages that start with: " MESSAGETOBOTONLY: "

best regards,

Don’t abuse magic strings within a messages body element to indicate a special message type.

If you want to control a bot then use IQ packets or add an extra extension to the message type packet to indicate that this message serves a special purpose. Then you could add a packetListener with a packetFilter to get notified if these types of xmpp stanzas are received.

Define a new IQ and use the packetListener was my first idea but i falied in it

Could you please give some example in how filter and create a package with a special IQ ?

thanks !