Results 1 to 4 of 4

Thread: Email Whitelist Handling

  1. #1
    Join Date
    Apr 2010
    Posts
    8

    Lightbulb 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. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,036

    Default

    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 at 10:53 AM.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Apr 2010
    Posts
    8

    Default

    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

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,036

    Default

    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'])" ... />
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •