将siddhi-io-rabbitmq与Java库一起使用。

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


  SiddhiQL中的语法错误,输入'上没有可行的选择; @sink(type = rabbitmq,uri = amqp://[email protected]:5672,exchange.name = events,routing.key = route2,user.id = guest,type = event,message.id = my消息ID,优先级= 1,交付方式= 2,标头='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:[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);
            }
        });
    }


}

我已经阅读了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。

如果有人可以帮助我,我会非常感激。

问候。

最佳答案

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

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

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

07-24 15:53