Contact Us 1-800-596-4880

Attachment Transformer Reference

Overview

Each Mule message consists of two parts. The header contains metadata pertaining to the message, such as the message type and the encoding protocol used to format the payload. The payload holds the data that typically gets processed by the Mule application flow, then dispatched to one or more external parties. This payload may also include a sub-section that holds any attachments (such as text, images, or applications) that travel with the message.

When an attachment is received into a flow along with it’s associated message, it is considered an Inbound Property, and it remains active (i.e., affixed to its parent message) as long as that message remains within the same flow. Note that the attachment does not automatically become part of the processed message that gets sent out of the flow by the outbound endpoint. For that to happen, you must explicitly make it an Outbound Property by reattaching it to the message with the Attachment Transformer. Alternatively, you can designate a different attachment to leave the flow along with the processed message.

The Attachment transformer can use expressions that evaluate the content of the current message as well as the current state of the Mule environment in order to make a run-time determination as to which specific attachment leaves the flow with the current message. For example, the Attachment transformer can retrieve and affix an appropriate photo for each credit application submitted by a different individual.

The Attachments transformer differs from most other transformers in that it can only be inserted as a building block into the sequence of message processors that make up your application flow and cannot be embedded within an endpoint. Also, no Global Element equivalent exists for the Attachment Transformer, so it is not possible to specify a set of configuration values once, then reference it multiple times to set up multiple Attachment Transformer instances throughout your Mule project.

Finally, the Attachment Transformer can handle a wide variety of Mime types, including text, images, and applications.

Configuration

Attachment transformer instantiation consists of the following two steps:

  1. Drag, then drop the Attachment Transformer icon from the Studio Palette to the point in your message processor sequence where you wish to install it.

    AttachmentDrop
  2. Configure the transformer by double-clicking the Attachment Transformer icon on the Message Flow canvas, then configuring the attribute fields on the various tabs of the Properties pane.

The Attachment Transformer Properties pane has two tabs, as detailed by the sections below.

General Tab

This tab allows you to set the properties listed in the following table:

Field Description

Display Name

Type a string that closely defines the role this specific Attachment transformer instance plays in your flow, such as AttachPhotoID.

Operation

Set the radio button to the operation you wish to execute. The choices are: Set Attachment, Remove Attachment, and Copy Attachments.

Name

In the text box, type a string that specifies the attachment name, either in expression or literal form.

Value

In the text box, type a string that specifies the value of the attachment, either as a literal string or as an expression.

Note:

The Value attribute displays only when you select Set Attachment as the operation this transformer will execute. If you select Remove Attachment or Copy Attachments, the Value field becomes irrelevant, and therefore does not display.

Content

Click the down arrow to the right of this field to specify the Mime format for the attachment string, such as text/plain or image/jpeg.

When you are satisfied by the values you have entered, click OK to commit your choices.

AttachmentGeneral

Documentation Tab

The Documentation tab and Description field let you enter development details about your Attachment Transformer. Each transformer has a Documentation tab.

AttachmentDocumentation
Field Description

Documentation

Enter all relevant information regarding your Attachment Transformer instance. This will display when you hover your mouse over the transformer icon on the Message Flow canvas.