public Message<?> receive(MessageSelector selector) {
        Object[] array = this.queue.toArray();
        for (Object o : array) {
            Message<?> message = (Message<?>) o;
            if (selector.accept(message) && this.queue.remove(message)) {
                return message;
            }
        }
        
        return null;
    }
public Message < ? > receive ( MessageSelector selector ) { Object [ ] array = this . queue . toArray ( ) ; for ( Object o : array ) { Message < ? > message = ( Message < ? > ) o ; if ( selector . accept ( message ) && this . queue . remove ( message ) ) { return message ; } } return null ; }
Supports selective consumption of messages on the channel. The first message
to be accepted by given message selector is returned as result.

@param selector
@return