Skip to content

Large Message Support

Ian Yates edited this page May 2, 2015 · 4 revisions

Azure Service Bus brokered messages have a maximum size of 256KB. This means you shouldn't be able to send or publish messages larger than this.

To work around this, Nimbus has what we call Large Message Storage. If configured, in the event of the message payload being too large, Nimbus will serialize the body of the message to another location and send the message with a pointer to the message body.

Currently we support a shared file system and Azure Blob Storage as message stores.

To configure storage, install the Nimbus.LargeMessages.FileSystem or Nimbus.LargeMessages.Azure packages.

Next step is configuration of the storage.

var largeMessageBodyStorage = new FileSystemStorageBuilder().Configure()
    .WithStorageDirectory(largeMessageBodyTempPath)
    .WithLogger(c.Resolve<ILogger>())
    .Build()

or for Azure

var largeMessageBodyStorage = new BlobStorageBuilder().Configure()
    .UsingStorageAccountConnectionString(CommonResources.BlobStorageConnectionString)
    .WithLogger(logger)
    .Build();

Then as part of your BusBuilder configuration, add this line.

.WithLargeMessageStorage(c => c.WithLargeMessageBodyStore(largeMessageBodyStorage)
    .WithMaxSmallMessageSize(64*1024)
    .WithMaxLargeMessageSize(10*1048576))

Of course, you can also do this with an IoC container.

builder.Register(c => new FileSystemStorageBuilder().Configure()
    .WithStorageDirectory(largeMessageBodyTempPath)
    .WithLogger(c.Resolve<ILogger>())
.Build())
.As<ILargeMessageBodyStore>()
.SingleInstance();

and

.WithLargeMessageStorage(sc => sc.WithLargeMessageBodyStore(c.Resolve<ILargeMessageBodyStore>())
    .WithMaxSmallMessageSize(50*1024)
    .WithMaxLargeMessageSize(1024*1024))