保存原始邮件使用TO

时间:2014-06-20 09:54:07

标签: java groovy apache-camel

我是骆驼世界的新人。我写了一些代码,看起来很难看:

   from('component:params')
        .process(someValidator())
        .process{
            def producerTemplate = lookup('template', ProducerTemplate.class)
            // I create NEW exchange because I need original in.body data in next routers
            def exchange = new DefaultExchange(context)
            exchange.in.body = someTransformation(it.in.body)
            def result = producerTemplate.send(SOMEWHERE, exchange)
            if (result.exception) throw result.exception
        }
        .process(someActionWithOriginalExchange(it.body.in))

我在这里创建了补充交换课程。我不认为这是个好主意。 但是当我尝试重写它时,使用“转换”和“到”我遇到了一些问题:

    from('component:params')
        .process(someValidator())
        .process{// or maybe transform, I guess it doesn't matter here
            it.in.body = someTransformation(it.in.body)
        }
        .to(SOMEWHERE)
        .process(someActionWithOriginalExchange(??? how can I get original exchange????))

我不明白如何保存原始邮件正文?

1 个答案:

答案 0 :(得分:1)

你可以在Bean或处理器中调用exchange.getUnitOfWork().getOriginalInMessage()