private DeliveryChannel channel;
public void onMessageExchange(MessageExchange exchange) throws MessagingException {
if (exchange.getRole() == MessageExchange.Role.CONSUMER) {
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
MessageExchange io = (MessageExchange) exchange.getProperty("exchange");
MessageUtil.transferOutToOut(exchange, io);
io.setProperty("exchange", exchange);
channel.send(io);
} else if (exchange.getStatus() == ExchangeStatus.DONE) {
MessageExchange io = (MessageExchange) exchange.getProperty("exchange");
io.setStatus(ExchangeStatus.DONE);
channel.send(io);
}
} else {
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
MessageExchangeFactory factory = channel.createExchangeFactory();
InOut io = factory.createInOutExchange();
MessageUtil.transferInToIn(exchange, io);
io.setService(new QName("echo"));
io.setProperty("exchange", exchange);
channel.send(io);
} else if (exchange.getStatus() == ExchangeStatus.DONE) {
// Do nothing
}
}