简体   繁体   English

如何将反应流连接到 quarkus / smallrye 中的 AMQP 代理

[英]How to connect a reactive stream to an AMQP broker in quarkus / smallrye

I am attempting to migrate my Artimis-MQ clients to quarkus microservices.我正在尝试将我的 Artimis-MQ 客户端迁移到 quarkus 微服务。 I consistently get a "Stream not connected" error when attempted to send a message.尝试发送消息时,我始终收到“流未连接”错误。

I attempted to follow the suggestions in the answer (using microprofile-reactive-messaging): Quarkus with ActiveMQ?我试图遵循答案中的建议(使用 microprofile-reactive-messaging): Quarkus with ActiveMQ?

in my build.gradle:在我的 build.gradle 中:

dependencies {
    // ...
    implementation enforcedPlatform("io.quarkus:quarkus-bom:0.15.0")
    implementation 'io.quarkus:quarkus-resteasy'
    implementation 'io.quarkus:quarkus-resteasy-jsonb'
    implementation 'io.quarkus:quarkus-smallrye-metrics'
    implementation 'io.quarkus:quarkus-smallrye-health'
    implementation 'io.quarkus:quarkus-smallrye-reactive-messaging'
    implementation 'io.quarkus:quarkus-vertx'

    implementation 'io.smallrye.reactive:smallrye-reactive-messaging-amqp:0.0.8'
}

sample rest endpoint, forwarding a message to AMQP示例休息端点,将消息转发到 AMQP

@Path("/send")
public class MessageResource {
    @Inject
    @Stream("emitter-topic")
    Emitter<String> topic;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String send(@QueryParam("msg") final String msg) {
        final String message = Objects.requireNonNullElse(msg, "").isBlank() ? "no message" : msg;
        topic.send(message);
        return "sent: " + message;
    }
}

in src/main/resources/application.properties :src/main/resources/application.properties

smallrye.messaging.source.emitter-topic.type=io.smallrye.reactive.messaging.amqp.Amqp
smallrye.messaging.source.emitter-topic.address=test-amqp
smallrye.messaging.source.emitter-topic.containerId=test-clientid
smallrye.messaging.source.emitter-topic.host=localhost
smallrye.messaging.source.emitter-topic.port=5672

I continuously see the "Illegal state exception".我不断看到“非法状态异常”。 I can tell from the logs that smallrye find the amqp connector, but never actually initializes the connection.我可以从日志中看出 smallrye 找到了 amqp 连接器,但实际上从未初始化连接。

2019-06-02 12:19:50,055 INFO  [io.sma.rea.mes.ext.MediatorManager] (main) Deployment done... start processing
2019-06-02 12:19:50,101 INFO  [io.sma.rea.mes.imp.ConfiguredStreamFactory] (main) Found incoming connectors: [class io.smallrye.reactive.messaging.amqp.Amqp]
2019-06-02 12:19:50,102 INFO  [io.sma.rea.mes.imp.ConfiguredStreamFactory] (main) Found outgoing connectors: [class io.smallrye.reactive.messaging.amqp.Amqp]
2019-06-02 12:19:50,103 INFO  [io.sma.rea.mes.imp.ConfiguredStreamFactory] (main) Stream manager initializing...
2019-06-02 12:19:50,106 INFO  [io.sma.rea.mes.imp.LegacyConfiguredStreamFactory] (main) Stream manager initializing...
2019-06-02 12:19:50,125 INFO  [io.sma.rea.mes.ext.MediatorManager] (main) Initializing mediators
2019-06-02 12:19:50,127 INFO  [io.sma.rea.mes.ext.MediatorManager] (main) Connecting mediators
2019-06-02 12:19:50,136 INFO  [io.quarkus] (main) Quarkus 0.15.0 started in 1.487s. Listening on: http://[::]:8080
2019-06-02 12:19:50,137 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jsonb, smallrye-health, smallrye-metrics, smallrye-reactive-messaging, smallrye-reactive-streams-operators, vertx]
2019-06-02 12:20:01,964 ERROR [io.und.request] (executor-thread-1) UT005023: Exception handling request to /send: org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalStateException: Stream not yet connected
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:209)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:234)
        at io.quarkus.resteasy.runtime.ResteasyFilter$ResteasyResponseWrapper.sendError(ResteasyFilter.java:72)
        at io.undertow.servlet.handlers.DefaultServlet.doGet(DefaultServlet.java:175)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:686)

Ok, i figured out my problem.好的,我想出了我的问题。 In application.properties , i had source and sink backwards.application.properties ,我source和向后sink Describing emitter-topic as a sink, rather than source resolved the issue.emitter-topic描述为接收器而不是源解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Quarkus/SmallRye Reactive Messaging/Kafka 连接多个集群 - Quarkus/SmallRye Reactive Messaging/Kafka connect with multiple clusters 如何转换返回列表的方法<String>进入 Reactive Stream smallrye 兵变? - How to convert a method returning List<String> into Reactive Stream smallrye mutiny? ServerInterceptor gRPC 在 Quarkus 中没有捕捉到 SmallRye Mutiny Reactive 的异常 - ServerInterceptor gRPC not catching exceptions with SmallRye Mutiny Reactive in Quarkus 如何在 quarkus-smallrye-opentracing 中禁用 remoteReporter - how disable remoteReporter in quarkus-smallrye-opentracing 使用 Apache Camel/Smallrye/reactive 流 - 如何跨 JVM 将“发布者”连接到“订阅者”? - Using Apache Camel/Smallrye/reactive streams - how can I connect a "publisher" to a "subscriber" across JVMs? 如何调试 Quarkus/SmallRye 客户端请求 - How do I debug a Quarkus/SmallRye client request Quarkus + Kafka + Smallrye 异常处理 - Quarkus + Kafka + Smallrye exception handling 嵌入式AMQP Java Broker - Embedded AMQP Java Broker 如何使用spring-amqp关闭与Rabbit MQ代理的连接 - How to close connection with Rabbit MQ broker using spring-amqp Quarkus 响应式客户端真的是响应式的吗? - Is Quarkus reactive client really reactive?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM