2015-01-18 3 views
0

작동하지뮬 : 표현 필터는 일부 세션 변수가 허위 또는 해당하는 경우 메시지를 필터링 할의 requirment를 갖는

flow.xml

<spring:beans> 
     <spring:bean id="serviceBean" class="com.uidai.ServiceBean"/> 
    </spring:beans> 

    <flow name="messagefilterFlow1" doc:name="messagefilterFlow1"> 
     <file:inbound-endpoint responseTimeout="10000" doc:name="File" path="D:/sample" /> 
     <invoke object-ref="serviceBean" method="enrichFilter" doc:name="Invoke" methodArguments="#[sessionVars],#[message]"/> 
     <logger level="INFO" message="#[sessionVars['filter']]" doc:name="Logger"/> 
     <!--<message-property-filter pattern="#[sessionVars['filter']]=true" caseSensitive="true" doc:name="Message Property"/>--> 
     <expression-filter expression="#[sessionVars['filter']]" doc:name="Expression"/> 
     <file:outbound-endpoint responseTimeout="10000" doc:name="File" path="D:/sample2"/> 
    </flow> 

서비스 빈 메소드

public void enrichFilter(MessagePropertyMapContext mapContext, MessageContext messageContext){ 
     mapContext.put("filter", false); 
     System.out.println("mapContext" + mapContext); 
     System.out.println("message Context:::" + messageContext); 
    } 

Reading a file from inbound and setting a session variable in spring bean method. Wanted to filter the message on basis of filter value so that if filter value is true outbound file is not written and message is filtered. Even if filter value is true or false a lock is hold on file by inbound endpoint and processing stops. 

답변

0

내가 할 수있는 3.5.2에서 재생산.

return muleContext.getExpressionManager().evaluateBoolean(expr, message, nullReturnsTrue, !nullReturnsTrue); 라인이 항상 false을 반환하는 이유를 알아 보려면 accept() 메서드의 ExpressionFilter.class에 중단 점을 넣는 것이 좋습니다.

더 적은 양의 마법을 활용할 수있는 또 다른 제안은 필터 표현을 반환하거나 필터 상호 작용을 구현 한 다음 custom-filter 요소를 사용하여 자바 필터를 구현하는 것입니다.

+0

expression이 "# [header : filter = true]"인 경우 아웃 바운드 속성에서만 작동하며 메시지가 필터링 된 파일 인 경우에도 세션에서 작동하지 않습니다. 파일에 대한 인바운드 보류 잠금과 잠금을 해제하지 않습니다. catch 필터 예외 전략에서 처리 할 수 ​​있도록 메시지가 필터링 될 때 예외가 발생하지 않습니다. –

+0

메시지 필터에서 식 필터를 래핑 한 후 문제가 해결되었습니다.