为什么我的 timeToLiveFunction 从未被调用过?
Why is my timeToLiveFunction never called?
我有以下流程:
@Bean
public IntegrationFlow workerInfoJmsOut(ConnectionFactory connectionFactory, WorkerProperties properties) {
return IntegrationFlows
.from(ChannelNames.WORKER_INFO)
.handle(Jms.outboundAdapter(connectionFactory)
.timeToLiveFunction(message -> properties.getHeartbeatTtl().toMillis())
.destination(JmsQueueNames.WORKER_INFO))
.get();
}
以及以下网关:
@MessagingGateway
public interface DispatcherGateway {
@Gateway(requestChannel = ChannelNames.WORKER_INFO)
void submit(WorkerMessage message);
}
每 1 秒调用一次:
@Scheduled(fixedDelay = 1000)
public void beat() {
dispatcherGateway.submit(WorkerInfoNotice.of(...));
}
但是,timeToLiveFunction
中的断点从未命中:
我是不是理解错了什么或者为什么它从来没有命中?
spring-integration-jms:5.3.1.RELEASE
我发现我需要启用显式 QoS
@Bean
public IntegrationFlow workerInfoJmsOut(ConnectionFactory connectionFactory, WorkerProperties properties) {
return IntegrationFlows
.from(ChannelNames.WORKER_INFO)
.handle(Jms.outboundAdapter(connectionFactory)
.configureJmsTemplate(spec -> spec.explicitQosEnabled(true))
.timeToLiveFunction(message -> properties.getHeartbeatTtl().toMillis())
.destination(JmsQueueNames.WORKER_INFO))
.get();
}
我有以下流程:
@Bean
public IntegrationFlow workerInfoJmsOut(ConnectionFactory connectionFactory, WorkerProperties properties) {
return IntegrationFlows
.from(ChannelNames.WORKER_INFO)
.handle(Jms.outboundAdapter(connectionFactory)
.timeToLiveFunction(message -> properties.getHeartbeatTtl().toMillis())
.destination(JmsQueueNames.WORKER_INFO))
.get();
}
以及以下网关:
@MessagingGateway
public interface DispatcherGateway {
@Gateway(requestChannel = ChannelNames.WORKER_INFO)
void submit(WorkerMessage message);
}
每 1 秒调用一次:
@Scheduled(fixedDelay = 1000)
public void beat() {
dispatcherGateway.submit(WorkerInfoNotice.of(...));
}
但是,timeToLiveFunction
中的断点从未命中:
我是不是理解错了什么或者为什么它从来没有命中?
spring-integration-jms:5.3.1.RELEASE
我发现我需要启用显式 QoS
@Bean
public IntegrationFlow workerInfoJmsOut(ConnectionFactory connectionFactory, WorkerProperties properties) {
return IntegrationFlows
.from(ChannelNames.WORKER_INFO)
.handle(Jms.outboundAdapter(connectionFactory)
.configureJmsTemplate(spec -> spec.explicitQosEnabled(true))
.timeToLiveFunction(message -> properties.getHeartbeatTtl().toMillis())
.destination(JmsQueueNames.WORKER_INFO))
.get();
}