2017-03-02 14 views
0

POP3 커넥터를 인바운드로 사용하여 메일을 읽으면 메일 흐름을 시작합니다. 우리가 읽기 전에 읽고 흐름에 전송하기위한Mulesoft의 인바운드 POP3 커넥터를 읽는 중 주제 필터

<pop3s:inbound-endpoint doc:name="Poll emails" host="${email.host}" password="${email.password}" port="${email.port}" responseTimeout="10000" user="${email.user}"/> 

그러나이받은 편지함에 전달되는 모든 이메일을 읽고, 우리는 선택으로 이메일을 제한 할 수 있습니다?

의미, POP3 커넥터에 필터를 적용하여 이메일 서버에 요청하여 Spacific 제목으로 메일을 읽을 수 있습니까? 뮬 런타임 3.8/Anypoint Studio 6.1입니다.

의견을 보내 주시겠습니까?

는 라지 감사

답변

0

가 특정 주제와 이메일을 필터링하는 방법은 :

1. 이메일 전송 특정 필터

MuleSoft 인바운드 두 가지 구현을 제공 - 전자 메일 전송 (POP3, SMTP, IMAP) :

  • org.mule.providers.email.filters.AbstractMailFilter : 다른 메일 필터로 확장해야하는 기본 필터 구현입니다.

  • org.mule.providers.email.filters.MailSubjectRegExFilter : 메일 메시지 제목에 정규 표현식을 적용합니다.

예를 들어, 다음과 같은 방식으로 MailSubjectRegExFilter을 정의 할 수 있습니다 :

<flow> 
    <pop3s:inbound-endpoint doc:name="Poll emails" host="${email.host}" password="${email.password}" port="${email.port}" responseTimeout="10000" user="${email.user}"/> 
    <custom-filter class="org.mule.transport.email.filters.MailSubjectRegExFilter" doc:name="Custom"> 
     <message-property-filter pattern="subject=mySubject" caseSensitive="true" doc:name="Message Property"/> 
    </custom-filter> 
    ... 
</flow> 

자세한 내용은 다음 MuleSoft 문서에서 찾을 수 있습니다

2.사용하여 메시지 필터 MuleSoft의 블로그 게시물 Integration Patterns: Message Filter에서

:

를 사용하여 메시지 라우터, 메시지 필터, 특별한 종류의 세트를 기반으로 채널로부터 원하지 않는 메시지를 제거하기 기준.

샘플 흐름 :

<flow name="flowWithFilter"> 
    <jms:inbound-endpoint queue="inQueue"/> 
    <message-filter onUnaccepted="DeadLetterQueueFlow" throwOnUnaccepted="false"> 
     <expression-filter evaluator="xpath" expression="/order/@type = 'book'"> 
    </message-filter> 
    <jms:outbound-endpoint queue="outQueue"/> 
</flow> 

확인 더 예 및 구성에 대한 기사.

3.사용자 정의 필터 만들기

Crear "필터"를 구현하고 해당 주체가 기준에 부합하는지 평가하는 Java 클래스. 아래 예제는 How to add a custom filter to an email inbound endpoint 문서에서 가져온 것으로 IMAP을 참조하지만 POP3와 비슷해야합니다.

XML 구성 :

<flow name="main"> 
    <imaps:inbound-endpoint connector-ref="imapsConnector" user="[email protected]" password="theAccountPassword" host="imap.gmail.com" port="993" doc:name="IMAP"> 
     <message-filter> 
      <custom-filter class="filters.MyCustomEmailFilter" /> 
     </message-filter> 
    </imaps:inbound-endpoint> 
    <logger level="INFO" message="Email matched filter, do processing..." doc:name="Logger" /> 
</flow> 

필터 클래스 :

 public class MyCustomEmailFilter implements Filter { 

    @Override 
    public boolean accept(MuleMessage message) { 
     MimeMessage emailMessage = (MimeMessage) message.getOriginalPayload(); 
     try { 
      return customEvalLogic(emailMessage); 
     } catch (MessagingException e) { 
      throw new MuleRuntimeException(e); 
     } 
    } 

    private boolean customEvalLogic(MimeMessage emailMessage) throws MessagingException { 
     return emailMessage.getSubject().contains("order");  // Please define custom email filter criteria here 
    } 

}