Announcement Announcement Module
Collapse
No announcement yet.
Email Whitelist Handling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Email Whitelist Handling

    hi all

    i have to extend my spring integration configuration with a email whitelist handling. emails should only be sent to receipients defined in a file. what's the best way or spring integration component to do that? later i also have to implement the same for sms, faxes and so on.

    regards
    angela

  • #2
    You can use a custom filter...

    Code:
    public class MailFilter {
    
    	public boolean filter(@Header(MailHeaders.TO) String mailTo) {
    		return isInWhiteList(mailTo);
    	}
    
    	private boolean isInWhiteList(String mailTo) {
    		...
    	}
    }
    Code:
    <int:filter input-channel="foo" output-channel="toMail">
    	<bean class="foo.MailFilter" />
    </int:filter>
    Last edited by Gary Russell; Oct 29th, 2012, 10:53 AM.

    Comment


    • #3
      thanks for the answer!

      i will try that...would it be also a good approach to implement one filter for all whitelist handling (email, fax, sms)? then reading the whitelists there and setting the new messageheaders?

      something like that?


      @
      PHP Code:
      Named("outgoingMessageFilter")
      public class OutgoingMessageFilter implements MessageSelector {

              /**
           * Implement a whitelist handling for all outgoing messages!
           * 
           * @see org.springframework.integration.core.MessageSelector#accept(org.springframework.integration.Message)
           */
          @Override
          public boolean accept(Message<?> message) {
              MessageHeaders headers = message.getHeaders();
              List<String> emailSubscribers = headers.get(CustomHeaders.EMAIL_SUBSCRIBERS, List.class);

              //handle and set new emails subscribers
              
              List<String> faxSubscribers = headers.get(CustomHeaders.FAX_SUBSCRIBERS, List.class);
              //handle and set new fax subscribers
              
              List<String> iphonePushSubscribers = headers.get(CustomHeaders.IPHONEPUSH_SUBSCRIBERS, List.class);
              //handle and set new iphone push subscribers
              
              return false;
          }
      }
      regards
      angela

      Comment


      • #4
        That would work too, but you could avoid tying your code to the framework by using a POJO and a SpEL expression to pull the lists out of the headers; something like

        Code:
        <filter ... expression="@myPojoSelector.select(headers['mailSubs'], headers['faxSubs'], headers['iphonePushSubs'])" ... />

        Comment

        Working...
        X