Concepts

XMPP agents come in two flavours - packet producers and packet consumers. A packet producer is called at regular intervals (typically each iteration of the agent connection refresh loop) and produces XMPP packets (eg PubSub publish requests) that are sent to the XMPP server. The contract is that each packet is produced quickly and that the producer is essentially stateless. A packet consumer is the oposite - it reacts to incoming packets and is also assumed to be essentially stateless. A consumer is a combination of a smack PacketFilter and PacketListener.

A special case of a packet consumer is an event consumer. An event consumer is called when PubSub events are received.

Naturally a packet consumer can also send packets and vice-versa but only in the context of a dialog with another XMPP client (for instance a human with a jabber client). Note that it cannot be assumed that an agent is running in a separate thread - separate threads must be started by the agent in order to avoid dead-locks and to maintain dialog state.