Example 11.2 outlines how to implement a message by
extending the DefaultMessage class.
Example 11.2. Custom Message Implementation
import org.apache.camel.Exchange; import org.apache.camel.impl.DefaultMessage; public classCustomMessageextends DefaultMessage {public
CustomMessage() {// Create message with default properties... } @Override public String toString() {
// Return a stringified message... } @Override public
CustomMessagenewInstance() {return new
CustomMessage( ... ); } @Override protected Object createBody() {// Return message body (lazy creation). } @Override protected void populateInitialHeaders(Map<String, Object> map) {
// Initialize headers from underlying message (lazy creation). } @Override protected void populateInitialAttachments(Map<String, DataHandler> map) {
// Initialize attachments from underlying message (lazy creation). } }
Implements a custom message class, | |
Typically, you need a default constructor that creates a message with default properties. | |
Override the | |
The | |
The | |
The | |
The |















