2017-09-08 1 views
0

Je reçois l'erreur `La corrélation nulle n'est pas autorisée. Peut-être que la CorrelationStrategy échoue?Spring Integration La corrélation nulle n'est pas autorisée. Peut-être que la CorrelationStrategy échoue?

Ce fil de discussion a semblé le résoudre avec quelque chose comme le suivant, mais cette approche ne fonctionne pas pour moi, http://forum.spring.io/forum/spring-projects/integration/102054-aggregator-correlation-strategy-failing. D'après ce que je comprends, l'adaptateur de canal de transmission en continu entrant place FILE_NAME en tant que valeur d'en-tête, et j'aimerais y participer.

<int-ftp:inbound-streaming-channel-adapter 
    auto-startup="true" id="ftpListener" channel="ftpChannel" 
    session-factory="ftpSessionFactory" remote-directory="/export/home/udyj" 
    filename-pattern="test1.txt"> 
    <integration:poller fixed-rate="5000" 
     max-messages-per-poll="-1" /> 
</int-ftp:inbound-streaming-channel-adapter> 

<int-ftp:inbound-streaming-channel-adapter 
    auto-startup="true" id="ftpListener2" channel="ftpChannel" 
    session-factory="ftpSessionFactory" remote-directory="/export/home/udyj" 
    filename-pattern="test2.txt"> 
    <integration:poller fixed-rate="5000" 
     max-messages-per-poll="-1" /> 
</int-ftp:inbound-streaming-channel-adapter> 

<bean id="correlationStrategy" 
    class="org.springframework.integration.aggregator.HeaderAttributeCorrelationStrategy"> 
    <constructor-arg value="FILE_NAME.substring(0,3)" /> 
</bean> 
<integration:aggregator id="nuggetAggregator" 
    input-channel="ftpChannel" output-channel="sendMQDistributionChannel" 
    correlation-strategy="correlationStrategy"> 
</integration:aggregator> 

Répondre

1

Regardez, vous dites HeaderAttributeCorrelationStrategy, qu'attendez certainement un nom d'en-tête pour obtenir. mais en même temps, vous spécifiez le nom de l'en-tête comme FILE_NAME.substring(0,3) qui ressemble plus à une expression. Et vous obtenez null parce qu'il n'y a vraiment pas un tel en-tête.

Si vous voulez évaluer une expression, pensez à utiliser à la place ExpressionEvaluatingCorrelationStrategy:

<bean id="correlationStrategy" 
    class="org.springframework.integration.aggregator.ExpressionEvaluatingCorrelationStrategy"> 
    <constructor-arg value="headers.file_name.substring(0,3)" /> 
</bean>