2016-11-14 1 views
1

Camel Route:Wie kann man unmarshal() im Camel Prozessor aufrufen?

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 
    } 
    } 
} 

Ich brauche ProcessDefinition.unmarshal(dataformat) zu nennen. Wie kann ich das ProcessDefinition Objekt innerhalb der Prozessmethode erhalten?

Antwort

2

Sie können direkt Abstellungs des Datenformats mit Exchange und Exchange.getIn().getBody(InputStream.class) als eine andere param nennen:

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

Sie brauchen nicht die ProcessDefinition.unmarshal() zu nennen; ProcessDefinition definiert nur, welches Datenformat zu verwenden ist und schließlich, wenn Ihre Nachricht eingeht, wird die Dataformat.unmarshal()-Methode mit Exchange und Body InputStream aufgerufen.