我正在尝试读取队列 channel 中未使用的消息。但找不到办法做到这一点。是否可以?如果是,请指出正确的文件。
目的是公开 API,以便客户端可以在 UI 上看到待处理的项目。
谢谢
最佳答案
您可以简单地引用其中一个 ServiceActivator 中的“队列 channel ”,并对消息执行任何您想要的操作:
@MessageEndpoint(value = "jobQueuer")
public class JobStartupQueuer {
@Resource
private Queue<Message> jobChannelQueue;
public boolean accept(Message<?> message) {
LOG.info("Channel size: {}", jobChannelQueue.size());
return true;
}
}
因此,jobChannelQueue 被注入(inject),因此在您的 ServiceActivator 处理方法(例如accept)中,我们可以引用队列及其内部消息。
关于java - Spring 集成: How to read the unconsumed messages in the queue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23678377/