【发布时间】:2018-10-23 21:56:49
【问题描述】:
我编写了一个程序来从 Solace 队列中读取消息。我收到以下错误。
你能帮忙吗?
我的主要配置如下:
public class ReadFromQueueConfig {
@Autowired
private PrintMessageFromQueue printMessageFromQueue;
String queueName = "MY.SAMPLE.SOLACE.QUEUE";
@Bean
public CachingConnectionFactory jmsConnectionFactory() {
CachingConnectionFactory ccf = new CachingConnectionFactory();
try {
SolConnectionFactory scf = SolJmsUtility.createConnectionFactory();
scf.setHost("host");
scf.setUsername("username");
scf.setVPN("vpm");
scf.setPassword("password");
scf.setDirectTransport(false);
ccf.setTargetConnectionFactory(scf);
} catch (Exception e) {
logger.debug(e.getMessage());
}
return ccf;
}
@Bean
public IntegrationFlow handleJsmInput() {
return IntegrationFlows
.from(Jms.inboundAdapter(jmsConnectionFactory()).destination(queueName))
.handle(printMessageFromQueue)
.get();
}
}
更新: 我的主要课程:
@SpringBootApplication
@EnableIntegration
@IntegrationComponentScan
public class TestReadFromQueueApplication {
public static void main(String[] args) {
SpringApplication.run(TestReadFromQueueApplication.class, args);
}
}
【问题讨论】:
-
您并没有显示真正的问题所在。我们在您的日志中看到的是正常的应用程序启动和停止。而已。您可能只是在
main()中过早地关闭了应用程序上下文。在关闭应用程序上下文之前,您应该考虑添加一些sleep()或对最终用户输入的反应。 -
感谢您的回复。我真正想要的是让程序继续监听队列,并打印发布到它的任何消息。我应该添加什么来保持程序运行和收听消息?
标签: java error-handling spring-integration solace