SiddhiQL中的语法错误,在输入时没有可行的替代方案

时间:2018-06-18 19:47:37

标签: java rabbitmq complex-event-processing siddhi

将siddhi-io-rabbitmq与java库结合使用。

我试图设置rabbitmq属性" app.id"在" @sink()"上,但会出现以下错误消息:

  

SiddhiQL中的语法错误,在输入时没有可行的选择&#39 ;; @sink(type = rabbitmq,uri = amqp://guest.guest@192.168.99.100:5672,exchange.name = events,routing.key = route2,user.id = guest,type = event,message.id = my邮件ID,优先级= 1,delivery.mode = 2,headers =' key1:value1',' key2:value2',content.encoding = utf8,content.type = application / json ,app'。

以下代码仅在没有此属性的情况下运行:

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:guest@192.168.99.100: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://guest.guest@192.168.99.100: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);
            }
        });
    }

}

我已经阅读了https://wso2-extensions.github.io/siddhi-io-rabbitmq/api/1.0.16/中的文档,并在互联网上查找了示例或类似问题,但没有成功。

我的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>

我的消息代理是带有Erlang 20.1.7的RabbitMQ 3.7.4。

如果有人能帮助我,我非常感激。

问候。

1 个答案:

答案 0 :(得分:1)

在解析app.id注释元素的@sink属性名称时似乎存在缺陷。如果您可以摆脱该属性名称,则该应用程序应该可以运行。

无论如何,我已经在Siddhi存储库[1]中报告了该问题。这样您就可以在那里跟踪缺陷的状态。

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