"batch" processing at the end of connection: does Haraka allow for this? #3343
-
My use case is to use Haraka to receive archivable emails and then upload them to S3 for additional processing. Assuming we have this workflow:
Now the last step can happen after the client disconnects or before; that is something that is still being discussed, but the gist is thatI want to take an action on all of the messages at once at some point. I do not see a hook for such a scenario, so my question is whether or not Haraka has a means to do this. I imagine it can be done via standard node code, but ideally, there is something that Haraka exposes to do the same. TIA |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yes. You can do this with a plugin. Your plugin would need to validate the recipient. When it does so, for the messages that want future uploading to S3, set the
Assure your plugin hooks both // myPlugin
exports.register = function () {
this.register_hook('queue', 'my_queue_function')
this.register_hook('queue_outbound', 'my_queue_function')
}
exports.my_queue_function = function (next, connection) {
// do your magic. Queue the message to disk, rabbitmq, mongodb, etc..
}
exports.hook_disconnect = function (next, connection) {
// the connection is ending, upload all the queued messages to S3
} |
Beta Was this translation helpful? Give feedback.
Yes.
You can do this with a plugin. Your plugin would need to validate the recipient. When it does so, for the messages that want future uploading to S3, set the
queue.wants
property:connection.transaction.notes.set('queue.wants', 'myPlugin')
Assure your plugin hooks both
queue
andqueue_outbound
. Then you're assured that your plugin will handle delivery. You can employ any logic you wish within the queue hook. You probably want something like this: