当前位置: 首页 > 知识库问答 >
问题:

Quakus:java.lang.IllegalStateExctive:未找到该频道的订户

贝钧
2023-03-14

我使用Quarkus,我有一个缓慢运行的命令过程:

@ApplicationScoped
public class SlowApplication {

private static final Logger LOGGER = Logger.getLogger(SlowApplication.class.getName());

@Inject @Channel("texto") public Emitter<String> emitter;

public Integer slowProcess(int num) {
    for (int n=0;n<num;n++) {
        LOGGER.info("Start Num: "+n);
        try {
            Thread.sleep(250);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        emitter.send("Number is: "+n);
        LOGGER.info("End Num: "+n);
    }
    return num;
}

我想通过使用REST API从流程中得到更新:

@Path("/test")
@ApplicationScoped
public class MainWeb {

@Inject
SlowApplication app;

@Inject
Bridge bridge;

@Inject @Channel("texto-sent") public Multi<String> textos;

@GET
@Produces(MediaType.TEXT_HTML)
public String hello() {
    return "hello";
}

@GET
@Produces(MediaType.TEXT_HTML)
@Path("/custom")
public Uni<String> custom() {
    return Uni.createFrom().item(app.slowProcess(4)).onItem().transform(n -> String.format("Finished %s", n));
}

@GET
@Produces(MediaType.TEXT_HTML)
@Path("/stream")
public Multi<String> stream() {
    return textos;
}

}

@ApplicationScoped
public class Bridge {
private static final Logger LOGGER = Logger.getLogger(Bridge.class.getName());

@Outgoing("texto-sent")
@Incoming("texto")
public String receive(String str) {
    LOGGER.infof("Received " + str);
    return "Received " + str;
}

到达时,我遇到以下错误:

emitter.send("Number is: "+n);

java.lang.非法状态异常: SRMSG00027:没有找到该频道的订户

链接到Github代码(包括pom和依赖版本)

知道为什么不识别@传入("tex")吗?

完全错误:

java.lang.IllegalStateException: SRMSG00027: No subscriber found for the channel texto
    at io.smallrye.reactive.messaging.extension.AbstractEmitter.verify(AbstractEmitter.java:157)
    at io.smallrye.reactive.messaging.extension.AbstractEmitter.emit(AbstractEmitter.java:139)
    at io.smallrye.reactive.messaging.extension.EmitterImpl.send(EmitterImpl.java:29)
    at org.jds.sandbox.createUni.SlowApplication.slowProcess(SlowApplication.java:25)
    at org.jds.sandbox.createUni.SlowApplication_Subclass.slowProcess$$superaccessor1(SlowApplication_Subclass.zig:204)
    at org.jds.sandbox.createUni.SlowApplication_Subclass$$function$$1.apply(SlowApplication_Subclass$$function$$1.zig:35)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
    at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:63)
    at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
    at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
    at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
    at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
    at org.jds.sandbox.createUni.SlowApplication_Subclass.slowProcess(SlowApplication_Subclass.zig:161)
    at org.jds.sandbox.createUni.SlowApplication_ClientProxy.slowProcess(SlowApplication_ClientProxy.zig:128)
    at org.jds.sandbox.createUni.MainWeb.custom(MainWeb.java:37)
    at org.jds.sandbox.createUni.MainWeb_Subclass.custom$$superaccessor1(MainWeb_Subclass.zig:237)
    at org.jds.sandbox.createUni.MainWeb_Subclass$$function$$1.apply(MainWeb_Subclass$$function$$1.zig:29)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
    at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:63)
    at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
    at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
    at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
    at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
    at org.jds.sandbox.createUni.MainWeb_Subclass.custom(MainWeb_Subclass.zig:195)
    at org.jds.sandbox.createUni.MainWeb_ClientProxy.custom(MainWeb_ClientProxy.zig:213)
    at org.jds.sandbox.createUni.MainWeb$quarkusrestinvoker$custom_0989e6157a2c7c5acc3973ff53d46eb621670726.invoke(MainWeb$quarkusrestinvoker$custom_0989e6157a2c7c5acc3973ff53d46eb621670726.zig:33)
    at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
    at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:7)
    at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:122)
    at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:47)
    at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:17)
    at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:7)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
    at io.quarkus.vertx.http.runtime.StaticResourcesRecorder.lambda$start$1(StaticResourcesRecorder.java:65)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:101)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
    at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:206)
    at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:327)
    at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
    at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:835)

共有1个答案

晁开宇
2023-03-14

解决这个问题的方法是:

  • 使用MutinyEmitter代替Emitter

SlowApplication的新代码:

    @ApplicationScoped
public class SlowApplication {
    
    private static final Logger LOGGER = Logger.getLogger(SlowApplication.class.getName());
    
@Inject @Channel("texto") public MutinyEmitter<String> emitter;

public Integer slowProcess(int num) {
    for (int n=0;n<num;n++) {
        LOGGER.info("Start Num: "+n);
        try {
            Thread.sleep(250);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        emitter.sendAndForget("Number is: "+n);
        LOGGER.info("End Num: "+n);
    }
    return num;
}

我还将MainWeb方法中的流更改为:

@GET
@Path("/stream")
@Produces(MediaType.SERVER_SENT_EVENTS)
@SseElementType("text/html")
public Multi<String> stream() {
    return textos;
}

注意:我更新到了1.13.7版。根据克莱门特的建议最终确定。

 类似资料:
  • 我刚开始和内蒂一起工作。我已经有了一个服务器,我正在为一个客户端写代码。 在客户端,我用下面的代码为ClientBootstrap对象设置了一个新的PipelineFactory 其中ResponseHandler()是我扩展SimpleChannelHandler的类。 我想找到频道ID。我做到了。 但它会抛出IllelgalStateException并表示我无法调用getPipeline()

  • 我有一个Django Vue。我正在尝试连接到django频道的js聊天应用程序。 要访问任何聊天室,您只需访问: http://localhost:8080/rooms/"id"/ 我的javascript连接如下所示: 我的consumers.py: 我的routing.py: 我的项目routing.py: 问题是,我无法连接到websocket,我的django服务器说: [失败实例:回溯

  • 我正在做一个项目,在与我的队友合并代码之前,package sms_autofill运行正常,但在代码合并后,我已经运行了Flatter clean,但它仍然显示两个错误,如下所示: 和 我的代码: 颤振博士-v: pubspec。亚马尔: 我不知道它有什么问题,我已经尝试在互联网上搜索,似乎没有与之相关的解决方案。

  • 我正在尝试修复glassfish警告:上下文路径与bundle不同,但至少通过IDE无法创建glassfish-web.xml文件: 找不到此项目的部署配置。无法正确设置部署描述符版本。

  • 我花了很多时间来解决我的这个问题,阅读文档多次,谷歌在这里和那里:SO,Laracast,Larachat等,但仍然无法让Laravel回声订阅推动者存在频道,它没有显示任何错误在控制台选项卡 公共和私人频道工作正常,用户可以订阅,用户可以监听/触发事件 注意:在创建这篇文章之前,我有一些与我的当前问题相关的搜索问题,它们都没有答案 一些和我类似的问题: https://laravelquesti