1b) Annotation your JAXB beans to enable MTOM - 8.0

Talend ESB Service Developer Guide

Version
8.0
Language
English
Product
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Module
Talend ESB
Talend Runtime
Content
Design and Development
Installation and Upgrade
Last publication date
2023-11-06

If you're doing code first, you need to add an annotation to your POJO to tell JAXB that the field is a candidate for MTOM optimization. Lets say we have a Picture class with has Title and ImageData fields, then it might look like this:

@XmlType
public class Picture {
   private String title;

   @XmlMimeType("application/octet-stream")
   private DataHandler imageData;

   public String getTitle() { return title; }
   public void setTitle(String title) { this.title = title; }

   public DataHandler getImageData() { return imageData; }
   public void setImageData(DataHandler imageData) 
      { this.imageData = imageData; }
}

Note the use of 'application/octet-stream'. According to the standard, you should be able to use any MIME type you like, in order to specify the actual content of the attachment. However, due to a defect in the JAX-B reference implementation, this won't work.