Java 保存原始邮件以用于

Java 保存原始邮件以用于,java,groovy,apache-camel,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.bo

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

   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????))

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

您只需在Bean或处理器内部调用
exchange.getUnitOfWork().getOriginalInMessage()
,建议在此页面上评估代码