We have developed some time ago a notification mechanism on mailbox
events. This piece of software is based on the RFC 5423 - Internet
Message Store Events - that defines a number of event types and event
parameters.
Cyrus's processes (imapd, pop3d, lmtpd) and CLI send events to notifyd
daemon. We have added a new stomp connector to notifyd daemon to
spread these events in an activemq queue. Our set of Cyrus servers
currently generates around 4000 events/sec in the busy hour.


=> Today we support these subset of event types :
 - MessageExpunge
 - MessageNew
 - MessageRead
 - FlagsSet
 - FlagsClear
 - MailboxCreate
 - MailboxDelete
 - MailboxRename

And this additional non standard type :
 - MessageCopy

We support these subset of event parameters :
 - mailboxID
 - messages
 - timestamp
 - uidnext
 - uidset
 - flagNames
 - oldMailboxID

And these additionnal non standard parameters :
 - newMessages    // number of unseen messages
 - host                  // server hostname (Should we use
serverDomain or serverFQDN instead ?)
 - midset              // the set of MessageIDs referenced (see uidset
definition in the RFC)
 - oldUidset          // the old UID when copying a mail (see uidset
definition in the RFC)


=> We have defined lot of configuration settings (may be too much for
common usages) :
 - eventnotifier, "off", STRING : Enables event notification with the
given notification method (see notifyd). i.e mail, log, activemq
 - event_subfolder, 0, SWITCH : Enables event notification for subfolders too
 - event_exclude_folders, "", STRING : Don't send any notification for
the given folders (i.e Spam folder)
 - event_ignore_flags, "", STRING : Don't send notification on event
FlagsClear/FlagsSet for these flags (i.e \Deleted)
 - event_notifspam, 1, SWITCH : Enables event notification for email
rated as spam
 - event_XXX_params, "", STRING : Enables event notification of the
type XXX and adds non standard parameters or those that are optional
in the RFC for this event.
 - event_XXX_ctx, "", STRING : Defines one or several contexts for the
notification of type XXX. Name(s) of the queue(s) for activemq.

=> the RFC doesn't define any notification format. Today we send
key/value pairs of parameters like this : (example for new message
delivered by LMTP in folder Personal)

version=1
event=MessageNew
host=host0302
timestamp=1190272093123
mailboxID=user.mailbox1.Personal
messages=3
newMessages=2
uidnext=124
uidset=123


=> how to donate the code ?

1) be RFC compliant
- Some event types are missing, and some mandatory event parameters too.
- Discuss about our proprietary event types/parameters. There are two
options (or a mix of both) :
    -> keep it private in our source code.
    -> prefix with vnd. to be RFC compliant
- FlagsSet and FlagsClear are not well supported. In particular the
support of the keyword FLAGS to replace existing flags (OK for +FLAGS
and -FLAGS)
- Need tests and probably bugs fix on shared folders and public
folders. In particular the management of the flag \Seen.


2) possibly rename or simplify the configuration settings. Possibly
use IMAP METADATA for some settings. To be discussed.

3) provide more notification format like XML and JSON

4) redesign the code
- Most of the code is located in two new files : msgevent.h and
msgevent.c. Function calls are scattered throughout the Cyrus's code.
Most of the calls are done from a suitable location to avoid I/O
overhead. ie when the mailbox is open to get event parameter values.
However, calls should be made with the aim of eventually implementing
the RFC 5465 (The IMAP NOTIFY Extension).
- We have choose to use the Cyrus's internal form of the mailbox for
mailboxID parameter in order to be independent of the current
namespace and folder separator settings. To be discussed.
- Simplify the behavior. Do people need to define a context (queue)
per event type ? Moreover several contexts per event type (and thus
send each notification in several queues) ?
- possibly support some optional event parameters defined in the RFC

5) provide full documentation of the feature

6) and later provide more connectors to notifyd like support of AMQP protocol

I will create a new branch (based on Cyrus master) in our github for
this feature (https://github.com/worldline-messaging)

Regards,
Sébastien

Reply via email to