使用AMQP向Solace Broker发消息报错:队列未找到(Quarkus+SmallRye-AMQP)
问题:使用SmallRye AMQP的Quarkus应用发布消息时触发Queue Not Found错误
我们有一个基于Quarkus、使用SmallRye AMQP连接器的应用,编写了如下代码向指定主题发布消息:
@ApplicationScoped public class InsightLifecycleObserver { public static final String INSIGHTS_DELETED_TOPIC = "insightscentral/insight/deleted"; @Inject @Channel(INSIGHTS_DELETED_TOPIC) @OnOverflow(value = Strategy.NONE) Emitter<byte[]> insightsEmitter; void onInsightRemoved(@Observes(during = AFTER_SUCCESS) InsightDeletedEvent event) { final var tenantId = tenantResolver.getTenantId(); try { var insightLifeCycleEvent = convertToLifeCycleEvent(event); var eventEnvelope = EventEnvelope.builder() .withId(UUID.randomUUID()) .withData( PojoCloudEventData.wrap(insightLifeCycleEvent, objectMapper::writeValueAsBytes)) .build(); // send the event to the Insights topic insightsEmitter .send(eventEnvelope.serialize()) .whenComplete( (result, throwable) -> { if (throwable != null) { LOGGER.error("Failed to emit InsightDeleted event", throwable); metricsService.incrementErrorMessageCounter( MessageType.INSIGHT_DELETED_EVENT, tenantId); } else { LOGGER.debug( "Published InsightDeleted event for insight with id: {} and sri: {}", event.insight().id(), event.insight().sri()); metricsService.incrementMessageCounter( MessageType.INSIGHT_DELETED_EVENT, tenantId); } }); } catch (Exception e) { LOGGER.error("Failed to publish InsightDeleted event", e); metricsService.incrementErrorMessageCounter(MessageType.INSIGHT_DELETED_EVENT, tenantId); } } }
调用该钩子方法时出现如下异常:
io.vertx.core.impl.NoStackTraceThrowable: message rejected (REJECTED): Error{condition=amqp:not-allowed, description='SMF AD ack response error', info={solace.response_code=400, solace.response_text=Queue Not Found}}
问题原因与解决方法
核心原因
从错误信息里的solace.response_text=Queue Not Found可以直接定位:你的应用实际是在尝试向队列发送消息,而非代码中指定的主题,而Solace Broker上不存在这个名称的队列。
具体排查与修复步骤
修正Quarkus配置文件(application.properties)
SmallRye AMQP默认的地址类型是queue,如果不显式指定,会把你代码里的主题名称当作队列名来用。必须给出站通道添加主题类型配置:# 针对insightscentral/insight/deleted主题的出站配置 mp.messaging.outgoing.insightscentral/insight/deleted.connector=smallrye-amqp mp.messaging.outgoing.insightscentral/insight/deleted.address=insightscentral/insight/deleted # 关键配置:指定地址类型为主题 mp.messaging.outgoing.insightscentral/insight/deleted.address-type=topic # Solace额外配置(如果需要):指定虚拟VPN mp.messaging.outgoing.insightscentral/insight/deleted.amqp.virtual-host=your-solace-vpn-name注意配置项的前缀
mp.messaging.outgoing.后面必须跟代码中@Channel指定的主题名称,大小写、路径分隔符要完全一致。检查Solace Broker权限与配置
- 确认应用使用的AMQP账号拥有发布到该主题的权限(Solace控制台中可配置主题权限)
- 如果Solace启用了主题分区或显式路由,确保该主题已被允许路由
- 避免混淆SMF和AMQP的配置逻辑:Solace的AMQP接口对主题和队列的处理是分开的,不要用SMF的队列配置套用到AMQP主题发布上
验证消息发送目标
可以在代码中添加日志,打印eventEnvelope的目标地址信息,确认序列化后的消息没有被错误地指定为队列目标;也可以通过Solace Broker的监控工具查看被拒绝消息的目标地址,验证是否和预期主题一致。
内容的提问来源于stack exchange,提问作者elmodeer
相关产品推荐
相关产品推荐

