jmsTemplate convertAndSend方法不将消息推送到队列

时间:2019-06-06 10:45:59

标签: activemq spring-jms tibco

我是Spring和JMS的新手。我将解释有关尝试和发现的信息,这些信息可以帮助您确定实际问题。如果您很无聊,可以在问题底部找到实际日志:)

这是我的问题摘要

我正在将消息发送到Tibco队列。消费者部分已经实施。但是,当我尝试使用jmsTemplate.convertAndSend推送消息时,它不起作用。

我的SpringBootApplication类包含下面的Bean

 public Jaxb2Marshaller marshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setPackagesToScan("something", "java.lang");
    return marshaller;
}

@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(JmsErrorHandler errorHandler) {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory());
    factory.setDestinationResolver();
    factory.setErrorHandler(errorHandler);
    factory.setMessageConverter(messageConverter());
    return factory;
}

private MessageConverter messageConverter() {
    MarshallingMessageConverter converter = new MarshallingMessageConverter();
    converter.setMarshaller(marshaller());
    converter.setUnmarshaller(marshaller());
    return converter;
}

private ConnectionFactory connectionFactory() {
  log.info("tibcoConnection details "+ tibcoConnection);
  TibjmsConnectionFactory connectionFactory = new TibjmsConnectionFactory(tibcoConnection.getUrl());
    connectionFactory.setUserName(tibcoConnection.getUserName());
    connectionFactory.setUserPassword(tibcoConnection.getPassword());
    return connectionFactory;
}

我的尝试

我删除DefaultJmsListenerContainerFactory并仅添加@Bean ConnectionFactory,然后我的消息开始推送到队列(我创建了一个虚拟消费者并插入了虚拟消息以触发消费者)。但是当我尝试使用实际队列而不是我创建的虚拟队列时,在消费者中出现了异常。 S0显然需要DefaultJmsListenerContainerFactory(我的感觉是这样)

另一个观察结果

启动我的应用程序时,我可以看到tibco连接已建立

tibcoConnection详细信息TibcoConnection(url = tcp:// SOMEIP,userName = USERNAME,password =)

这是调用jmsTemplate.convertAndSend方法且无法发送到队列时的日志(在SpringBootApplication calss中未更改任何内容)

15:59:11.344 [DefaultMessageListenerContainer-1] INFO  o.a.activemq.broker.BrokerService - Using Persistence Adapter: MemoryPersistenceAdapter
15:59:11.398 [JMX connector] INFO  o.a.a.broker.jmx.ManagementContext - JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
15:59:11.514 [DefaultMessageListenerContainer-1] INFO  o.a.activemq.broker.BrokerService - Apache ActiveMQ 5.15.9 (localhost, ID:LT0095370-57773-1559816951377-0:1) is starting
15:59:11.521 [DefaultMessageListenerContainer-1] INFO  o.a.activemq.broker.BrokerService - Apache ActiveMQ 5.15.9 (localhost, ID:LT0095370-57773-1559816951377-0:1) started
15:59:11.521 [DefaultMessageListenerContainer-1] INFO  o.a.activemq.broker.BrokerService - For help or more information please see: http://activemq.apache.org
15:59:11.576 [DefaultMessageListenerContainer-1] INFO  o.a.a.broker.TransportConnector - Connector vm://localhost started

没有例外。

0 个答案:

没有答案