Announcement Announcement Module
Collapse
No announcement yet.
selector-expression from custom method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 05:57 PM.

  • #2
    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

    Comment


    • #3
      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

      Comment


      • #4
        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, 10:36 AM.

        Comment

        Working...
        X