payload attacher

Payload Atatcher

Version: 17.07

Supported Since: 17.01

What is a Payload Attacher?

UltraESB-X message has four main parts. They are payload, headers, properties and attachments. Attachments can be used to carry any additional information with the message. Note that attachment is set to the message and not to the message context. Therefore once the life cycle of the message ends, attachments' life cycle also ends. Basically when a message is sent out using an Egress Connector or when the flow ends with one of Flow End elements (see Successful Flow End and Exceptional Flow End), the message’s life cycle ends and same is applied to the attachments of the message. Attachment does not get automatically sent out when the message is sent out through an Egress Connector. It has to be manually processed to send it out either through a Custom Processing element which sets the payload by processing attachments or through an Egress Connector that supports sending out attachments.

A Payload Attacher is a processing element which can be used set the message payload as an attachment. When setting payload as an attachment, XMessageFormat of the payload will be preserved. Note that message headers will be set as headers in the attachment during payload attaching operation.

In order to use this processing element, you must first select the Attachment Processor dependency from the processor list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the Attachment Processor dependency.

Alternatively, you can add the following dependency to the maven pom.xml manually.

attachment remover outports

Out Ports


The message will be sent to this outport if the payload attachment is successful

On Exception

The message will be sent to this outport if the processing element failed in payload attachment operation


Attachment Name*


Attachment Name parameter is used to give a name to the attachment so that the name can be used to refer the attachment later in the flow.

For an example if this attachment needs to be accessed in a Custom Processing Element, Attachment Name parameter value must be used as the method argument key when calling XMessage API method getAttachment(String key).

@Processor(displayName = "AttachmentAggregator", type = ProcessorType.CUSTOM)
public class SetResponseCode extends AbstractSequencedProcessingElement {

    protected ExecutionResult sequencedProcess(XMessageContext xMessageContext) {
        XAttachment attachment = xMessageContext.getMessage().getAttachment("csv_file").get();

        // relevant processing code

        return ExecutionResult.SUCCESS;

Following place holders can also be used when giving the attachment name. Values for the place holders will be extracted from the message context.

  • @{variable.<variable_name>} - to get value from a variable

  • @{} - to get the message id

Few examples are as follows.

  • attachment-@{} - appending message id

  • attachment_@{variable.my_var} - appending value of variable my_var

  • attachment_@{variable.my_var}_@{} - appending value of variable my_var and message id

  • csv_attachment - simply a string value without the use of any place holder

Further following place holder can be used to get the current timestamp.

  • @{current.timestamp} - this will use the default timestamp pattern yyMMddHHmmssZ

  • @{current.timestamp.<timestamp_pattern>} - this will use the given timestamp pattern. Note that timestamp pattern given here should be a pattern compatible with SimpleDateFormat.

Attachment Name is case sensitive (like all Java Variables). Therefore Attachment Name "my_attachment" will not be considered same to the Attachment Name "My_Attachment".

Attachment name must be unique to the flow. If same attachment name is used in more than one Payload Attacher elements or in a File Attacher element, there is a possible risk of one attachment being replaced by another attachment.

Sample Use Case

In this use case we have a flow which starts with SFTP Listener and ends with SFTP Sender. In the middle we have a Payload Attacher element which is used to set the message payload as an attachment, a DB Processor which will query a database and set the results as message payload and a Custom Processing Element which will prepare the payload by aggregating current payload (result set of the database query execution) and the attachment. Complete flow for the use case is shown below.

payload attacher flow

The configuration for the Payload Attacher element is shown below.

payload attacher conf
In this topic
In this topic
Contact Us