目标
我想向一个主题发送一条信息,稍后我将处理一个客户端应用程序。为此,我使用Spring和及其JMS模块。作为消息代理,我使用本机ActiveMQ Artemis。
,这是我的设置
DemoApplication.java
@SpringBootApplication
public class DemoApplication {
private static final Logger logger = LoggerFactory.getLogger(DemoApplication.class);
public interface StarGate {
void sendHello(String helloText);
}
@Autowired
private ConnectionFactory connectionFactory;
@Bean
public IntegrationFlow mainFlow() {
return IntegrationFlows
.from(StarGate.class)
.handle(Jms.outboundAdapter(connectionFactory)
.configureJmsTemplate(jmsTemplateSpec -> jmsTemplateSpec
.deliveryPersistent(true)
.pubSubDomain(true)
.sessionTransacted(true)
.sessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE)
.explicitQosEnabled(true)
)
.destination(new ActiveMQTopic("wormhole")))
.get();
}
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(DemoApplication.class, args);
StarGate stargate = context.getBean(StarGate.class);
stargate.sendHello("Jaffa, kree!");
logger.info("Hello message sent.");
}
}application.properties
spring.artemis.mode=native
spring.artemis.host=localhost
spring.artemis.port=61616
spring.artemis.user=artemis
spring.artemis.password=simetraehcapa
spring.jms.pub-sub-domain=true
spring.jms.template.delivery-mode=persistent
spring.jms.template.qos-enabled=true
spring.jms.listener.acknowledge-mode=client
logging.level.org.springframework=INFObuild.gradle (重要部分)
springBootVersion = '2.0.2.RELEASE'
dependencies {
compile('org.springframework.boot:spring-boot-starter-artemis')
compile('org.springframework.boot:spring-boot-starter-integration')
compile('org.springframework.integration:spring-integration-jms')
testCompile('org.springframework.boot:spring-boot-starter-test')
}作为一个ActiveMQ Artemis服务器,我使用了带有默认配置的vromero/artemis (2.6.0)码头映像。
问题
在生产者端,消息似乎是成功地发送了,但是在消息broker端,消息缺少。创建了地址,但缺少队列。


将来主题的名称将是动态的,因此不允许我在broker.xml中手动创建主题。我依赖于Artemis的自动队列创建功能。
为什么在这种情况下消息发送不起作用?
Nerd注意:,我知道星门基本上是以点对点的方式通过虫洞连接的,但是为了这个问题,让我们忽略这个事实。
发布于 2018-06-14 13:57:29
当一条消息被发送到某个主题,并且对地址和队列都启用自动创建时,只有地址才会被创建,而不是队列。如果队列被自动创建并将消息放入队列中,则会违反主题的语义。只有响应订阅服务器才会创建主题地址上的订阅队列。因此,在发送消息之前,您需要一个主题订阅者,否则消息将被删除(根据主题语义)。
https://stackoverflow.com/questions/50854011
复制相似问题