Results 1 to 4 of 4

Thread: selector-expression from custom method

  1. #1
    Join Date
    Aug 2007
    Location
    Boston
    Posts
    20

    Default selector-expression from custom method

    Hi,

    I am using recipient list router to route messages to different channels like below:
    I want to inject selector_expression value from another bean (selectorExpressionEvaluator). How can I do that?

    Here is my SI:
    Code:
                           'recipient-list-router'(
    				'input-channel':'inputChannel'
    				)
    			{
    				recipient (
    					'channel':'channelToTransformer',
    					'selector-expression':"if(0==0)"
    					)
    				recipient (
    					'channel':'mailChannel',
    					'selector-expression':""
    					)
    			}
    Bean:
    Code:
    class selectorExpressionEvaluator{
     
    boolean validateMessage(Message message){
    // code which checks header/property values against valid values listed in xml and returns true/false
    }
    }
    If I can call this method, will it be called every time router receives message? or will it be called only once during app start-up?
    Idea is - we should be able to change the channel message selector during run time. Any other suggestions?

    Please help.
    Thank you
    Keerthi.
    Last edited by keerthib; Jun 9th, 2011 at 04:57 PM.

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,853

    Default

    I don't know if I'm following the use-case exactly, but here are a couple ideas that might help. SpEL expressions can reference a bean via the @ symbol: expression="@foo.bar(payload, headers.x)" - AND you can always use a Router or Filter that has a <groovy:script ../> sub-element. The groovy script can be dynamic (see: http://static.springsource.org/sprin...single/#groovy). We also support something similar for SpEL with the <expression> sub-element (see: http://static.springsource.org/sprin...lter-namespace and scroll down to the example that has an 'expression' sub-element).

    Hope that helps.
    -Mark

  3. #3
    Join Date
    Aug 2007
    Location
    Boston
    Posts
    20

    Default

    Hi Mark,

    Thank you for that. I am exactly looking for this syntax - @foo.bar() and I just found it in here : https://jira.springsource.org/browse/INT-578
    My bean extends MessageSelector, so I am assuming that I don't have to call @myBean.accept(message) and giving this should be enough - expression = "@myBean"
    I am trying that anyways.

    Thank you.
    keerthi

  4. #4
    Join Date
    Aug 2007
    Location
    Boston
    Posts
    20

    Default

    Hi,

    I tried doing this but message is directly going to transformer even though expression is returning false by default! Where am I going wrong?!
    Code:
    outgoingEventFilter(com.event.filter.OutgoingEventFilter)
    recipient (
    	'channel':'outChannel',
    	'selector-expression':"@outgoingEventFilter.accept(payload)"
    )
    
    class OutgoingEventFilter implements MessageSelector{	
    	@Override
    	public boolean accept(Message<Object> message) {
    		return false
    	}
    	public boolean accept(String payload){
    		return false
    	}	
    }
    Even if I give direct FALSE, message is going to outChannel?!

    Code:
    def doWithSpring = {
     integration{
      'recipient-list-router'(id:'listenerRouter','input-channel':'inChannel')
      {
       recipient('selector-expression':"false",'channel':'outChannel')
      }
     }
    }
    Last edited by keerthib; Jun 24th, 2011 at 09:36 AM.

Posting Permissions

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