Attachments

Attachments

Attachments are arbitrary payloads that can be included with a message. They are stored and retrieved from a queue, just like a message, and can be manipulated via the MessageContext object.

For example, the File Reader device supports reading multiple associated files and including them as attachments along with the primary file.

image-20250910-182859.png

Attachments are displayed in the queue device.

image-20250910-183319.png

Attachments are exposed via the IMessageContext interface.

image-20250910-183625.png

Here is some sample code showing attachment usage:

public override async Task ProcessMessageAsync(IMessageContext context, CancellationToken token) { var hl7 = context.GetAsHL7Message(); // working with the attachments collection context.Attachments.Clear(); // remove any existing attachments context.Attachments.Add("Att1", "This is a textual attachment"); // add string data context.Attachments.Add("Att2", System.IO.File.ReadAllBytes(@"C:\test\initial install\install.log"), true); // add binary data context.Attachments.AddFile("Att3", @"C:\test\initial install\install_000_Integrator.UpdaterA.log", true); // add files directly // access attachments by key var att1 = context.Attachments["Att1"].GetString(); var att2 = context.Attachments["Att2"].GetBytes(); context.Attachments.Add("Summary", $"{att1}, byte length = {att2.Length}"); }

This code shows as follows in the queue UI:

image-20250910-194650.png

Attachments are saved to the database when the primary message is stored in a queue. If you want to update an existing attachments collection in the source queue, you should call IMessageContext.Attachments.Save()