2016-11-14 34 views
1

駱駝路線:如何在駱駝處理器中調用unmarshal()?

from(source)   
    .idempotentConsumer(simple("${in.header.CamelFilePath}"), redisIdempotentRepository) 
    .process(pgpDecryptionProcessor) 
    .to(destination); 

PGPDecryptionProcessor:

public class PGPDecryptionProcessor implements Processor { 

    @Autowired 
    private PGPEncryptionManager pgpEncryptionManager; 

    @Override 
    public void process(Exchange exchange) throws Exception { 
    //do something to check whether it is encrypted 
    //get corrsponding dataformat for decryption 
    processDefinition.unmarshal(dataFormat); //How do i get processDefinition here 
    } 
    } 
} 

我需要調用ProcessDefinition.unmarshal(dataformat)。如何獲得處理方法中的ProcessDefinition對象?

回答

2

您可以直接調用DATAFORMAT的解組與ExchangeExchange.getIn().getBody(InputStream.class)作爲另一個PARAM:

dataformat.unmarshal(exchange, exachange.getIn().getBody(InputStream.class)); 

你並不需要調用ProcessDefinition.unmarshal(); ProcessDefinition只定義了要使用哪種數據格式,最後當您的消息進入時會發生什麼情況,Dataformat.unmarshal()方法使用ExchangeBody InputStream調用。