Search code examples
javarabbitmqcomplex-event-processingsiddhi

Syntax error in SiddhiQL, no viable alternative at input


Using siddhi-io-rabbitmq with a java library.

I tried to set the rabbitmq property "app.id" on the "@sink()", but the following error message appears:

Syntax error in SiddhiQL, no viable alternative at input '; @sink(type =rabbitmq, uri = amqp://[email protected]:5672, exchange.name = events, routing.key = route2, user.id = guest, type = event, message.id = my message id, priority = 1, delivery.mode = 2, headers = 'key1:value1','key2:value2', content.encoding = utf8, content.type = application/json, app'.

The code bellow runs only without this property:

import org.wso2.siddhi.core.SiddhiAppRuntime;
import org.wso2.siddhi.core.SiddhiManager;
import org.wso2.siddhi.core.event.Event;
import org.wso2.siddhi.core.stream.output.StreamCallback;
import org.wso2.siddhi.core.util.EventPrinter;

public class SiddhiRabbitMQError {
public static void main(String[] args) {
        String siddhiApp = 
                "@App:name('example') "

                + "@source(type ='rabbitmq', " 
                + "uri = 'amqp://guest:[email protected]:5672', "
                + "exchange.name = 'events', " 
                + "exchange.type = 'topic', "
                + "routing.key= 'route1', "
                + "queue.name = 'queue1', "
                + "queue.durable.enabled = 'true', "
                + "@map(type='json', validate.json='true', @attributes(msg1 = 'msg1', msg2 = 'msg2', msg3 = 'msg3') )) "  

                + "define stream inputStream (msg1 string, msg2 string, msg3 long); "

                + "@sink(type ='rabbitmq', "
                + "uri = 'amqp://[email protected]:5672', "
                + "exchange.name = 'events', "
                + "routing.key = 'route2', "
                + "user.id = 'guest', "
                + "type = 'event', "
                + "message.id = 'my message id', "
                + "priority = '1', "
                + "delivery.mode = '2', "
                + "headers = \"'key1:value1','key2:value2'\", "
                + "content.encoding = 'utf8', "
                + "content.type = 'application/json', "
                + "app.id = 'my app id', "
                + "@map(type='json', validate.json='true' ))"

                + "define stream countOutputStream (msg4 string, msg5 long); "

                + "@name('query1') "
                + "from inputStream#window.timeBatch(10 sec) "
                + "select msg1, count(msg1) as msg5 "
                + "group by msg1, msg2 "
                + "insert into countOutputStream; ";

        SiddhiAppRuntime countLoginRuntime = new SiddhiManager().createSiddhiAppRuntime(siddhiApp);

        countLoginRuntime.start();

        countLoginRuntime.addCallback("countOutputStream", new StreamCallback() {
            public void receive(Event[] events) {
                EventPrinter.print(events);
            }
        });
    }

}

I already read the doc in https://wso2-extensions.github.io/siddhi-io-rabbitmq/api/1.0.16/ and looked for examples or similar problems into internet, without success.

My pom.xml:

<repositories>
    <repository>
        <id>wso2.releases</id>
        <name>WSO2 Repository</name>
        <url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.wso2.extension.siddhi.io.rabbitmq</groupId>
        <artifactId>siddhi-io-rabbitmq</artifactId>
        <version>1.0.16</version>
    </dependency>

    <dependency>
        <groupId>org.wso2.siddhi</groupId>
        <artifactId>siddhi-core</artifactId>
        <version>4.1.35</version>
    </dependency>

    <dependency>
        <groupId>org.wso2.siddhi</groupId>
        <artifactId>siddhi-query-api</artifactId>
        <version>4.1.35</version>
    </dependency>

    <dependency>
        <groupId>org.wso2.siddhi</groupId>
        <artifactId>siddhi-query-compiler</artifactId>
        <version>4.1.35</version>
    </dependency>

    <dependency>
        <groupId>org.wso2.extension.siddhi.map.json</groupId>
        <artifactId>siddhi-map-json</artifactId>
        <version>4.0.22</version>
    </dependency>

    <dependency>
        <groupId>org.wso2.siddhi</groupId>
        <artifactId>siddhi-annotations</artifactId>
        <version>4.1.35</version>
    </dependency>

My message broker is RabbitMQ 3.7.4 with Erlang 20.1.7.

If someone could help me I very appreciate.

Regards.


Solution

  • There seems to be a defect when parsing app.id property name of the @sink annotation element. If you can get rid of that property name, the app should work.

    Anyway, I've reported the issue in Siddhi repository [1]. So you can track the status of the defect there.

    [1] https://github.com/wso2/siddhi/issues/848