Search in sources :

Example 1 with SqlParser

use of com.rabbitmq.jms.parse.sql.SqlParser in project rabbitmq-jms-client by rabbitmq.

the class RMQSession method bindSelectorQueue.

private void bindSelectorQueue(RMQDestination dest, String jmsSelector, String queueName, String selectionExchange) throws InvalidSelectorException, IOException {
    SqlCompiler compiler = new SqlCompiler(new SqlEvaluator(new SqlParser(new SqlTokenStream(jmsSelector)), JMS_TYPE_IDENTS));
    if (compiler.compileOk()) {
        Map<String, Object> args = new HashMap<String, Object>(5);
        args.put(RJMS_COMPILED_SELECTOR_ARG, (Object) compiler.compile());
        args.put(RJMS_VERSION_ARG, (Object) RJMS_CLIENT_VERSION);
        // bind the queue to the topic selector exchange with the jmsSelector expression as argument
        this.channel.queueBind(queueName, selectionExchange, dest.getAmqpRoutingKey(), args);
    } else {
        throw new RMQJMSSelectorException(String.format("Selector expression failure: \"%s\".", jmsSelector));
    }
}
Also used : SqlTokenStream(com.rabbitmq.jms.parse.sql.SqlTokenStream) SqlCompiler(com.rabbitmq.jms.parse.sql.SqlCompiler) HashMap(java.util.HashMap) RMQJMSSelectorException(com.rabbitmq.jms.util.RMQJMSSelectorException) SqlParser(com.rabbitmq.jms.parse.sql.SqlParser) SqlEvaluator(com.rabbitmq.jms.parse.sql.SqlEvaluator)

Aggregations

SqlCompiler (com.rabbitmq.jms.parse.sql.SqlCompiler)1 SqlEvaluator (com.rabbitmq.jms.parse.sql.SqlEvaluator)1 SqlParser (com.rabbitmq.jms.parse.sql.SqlParser)1 SqlTokenStream (com.rabbitmq.jms.parse.sql.SqlTokenStream)1 RMQJMSSelectorException (com.rabbitmq.jms.util.RMQJMSSelectorException)1 HashMap (java.util.HashMap)1