private Message receiveSelected ( TestContext context , String selectorString ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Setting message selector: '" + selectorString + "'" ) ; } Endpoint messageEndpoint = getOrCreateEndpoint ( context ) ; Consumer consumer = messageEndpoint . createConsumer ( ) ; if ( consumer instanceof SelectiveConsumer ) { if ( receiveTimeout > 0 ) { return ( ( SelectiveConsumer ) messageEndpoint . createConsumer ( ) ) . receive ( context . replaceDynamicContentInString ( selectorString ) , context , receiveTimeout ) ; } else { return ( ( SelectiveConsumer ) messageEndpoint . createConsumer ( ) ) . receive ( context . replaceDynamicContentInString ( selectorString ) , context , messageEndpoint . getEndpointConfiguration ( ) . getTimeout ( ) ) ; } } else { log . warn ( String . format ( "Unable to receive selective with consumer implementation: '%s'" , consumer . getClass ( ) ) ) ; return receive ( context ) ; } }
Receives the message with the respective message receiver implementation also using a message selector .