Example usage for org.springframework.integration.support MessageBuilder setErrorChannel

List of usage examples for org.springframework.integration.support MessageBuilder setErrorChannel

Introduction

In this page you can find the example usage for org.springframework.integration.support MessageBuilder setErrorChannel.

Prototype

@Override
    public MessageBuilder<T> setErrorChannel(MessageChannel errorChannel) 

Source Link

Usage

From source file:nz.co.senanque.messaging.springintegration.MessageSenderImpl.java

public boolean send(T graph, long correlationId) {

    Object payload = graph;//from www . java  2s. c o  m

    if (m_marshaller != null) {
        Result result = m_resultFactory.createResult(graph);
        if (result == null) {
            throw new MessagingException("Unable to marshal payload, ResultFactory returned null.");
        }
        try {
            m_marshaller.marshal(graph, result);
        } catch (Exception e) {
            throw new WorkflowException("Failed to marshal payload", e);
        }
        Document doc = (Document) m_resultTransformer.transformResult(result);
        payload = doc;
    }

    MessageBuilder<?> messageBuilder = MessageBuilder.withPayload(payload);
    if (getReplyChannel() != null) {
        messageBuilder.setReplyChannel(getReplyChannel());
    }
    if (getErrorChannel() != null) {
        messageBuilder.setErrorChannel(getErrorChannel());
    }
    if (getMessagePriority() != null) {
        messageBuilder.setPriority(getMessagePriority());
    }
    messageBuilder.setCorrelationId(correlationId);
    Message<?> ret = messageBuilder.build();
    return getChannel().send(messageBuilder.build());
}