Search in sources :

Example 1 with SpringIntegrationMessage

use of org.apache.camel.component.spring.integration.SpringIntegrationMessage in project camel by apache.

the class SpringIntegrationConverter method toSpringMessage.

@Converter
public static org.springframework.messaging.Message<?> toSpringMessage(final org.apache.camel.Message camelMessage) throws Exception {
    if (camelMessage instanceof SpringIntegrationMessage) {
        SpringIntegrationMessage siMessage = (SpringIntegrationMessage) camelMessage;
        org.springframework.messaging.Message<?> message = siMessage.getMessage();
        if (message != null) {
            return message;
        }
    }
    // Create a new spring message and copy the attributes and body from the camel message
    MessageHeaders messageHeaders = new MessageHeaders(camelMessage.getHeaders());
    return new GenericMessage<Object>(camelMessage.getBody(), messageHeaders);
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) MessageHeaders(org.springframework.messaging.MessageHeaders) SpringIntegrationMessage(org.apache.camel.component.spring.integration.SpringIntegrationMessage) Converter(org.apache.camel.Converter)

Aggregations

Converter (org.apache.camel.Converter)1 SpringIntegrationMessage (org.apache.camel.component.spring.integration.SpringIntegrationMessage)1 MessageHeaders (org.springframework.messaging.MessageHeaders)1 GenericMessage (org.springframework.messaging.support.GenericMessage)1