rebus-org / Rebus

:bus: Simple and lean service bus implementation for .NET
https://mookid.dk/category/rebus
Other
2.33k stars 364 forks source link

Automatically move message payload to an attachment if the size exceeds a configured threshold #768

Closed mookid8000 closed 5 years ago

mookid8000 commented 5 years ago

If the size of the message payload exceeds the size limit for the configured transport, it would be neat if Rebus could automatically store the payload as an attachment, and then just send a message with an attachment ID.

This feature requires that Rebus can help with cleaning up old attachments, so this feature must be accompanied by #750 . This way, enabling this feature would require that some kind of clean-up strategy be defined, e.g. "clean up attachments that haven't been read for 72 hours", or something like that.

This would also solve the issue described here.

mookid8000 commented 5 years ago

Rebus 6 (which is currently available as version 6.0.0-b08) can do this:

Configure.With(_activator)
    .Transport(t => ...)
    .DataBus(d =>
    {
        d.SendBigMessagesAsAttachments(bodySizeThresholdBytes: 2*1024*1024);
        d.StoreInMemory(_dataStore);
    })
    .Start();

where SendBigMessagesAsAttachments is obviously what we're after here 😄