Spring 如何指示JMSTemplate.receive()应使用DurableSubscriber

Spring 如何指示JMSTemplate.receive()应使用DurableSubscriber,spring,jms,spring-jms,ems,Spring,Jms,Spring Jms,Ems,我希望在不使用xml配置的情况下执行此操作。我正在玩弄SpringJMS,看看它是否满足我的需求。是否有使用 JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory); jmsTemplate.receive() 因此,它相当于纯JMS调用: MessageConsumer consumer = session.createDurableSubscriber(topic, "durable name"); Message mes

我希望在不使用xml配置的情况下执行此操作。我正在玩弄SpringJMS,看看它是否满足我的需求。是否有使用

JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
jmsTemplate.receive() 
因此,它相当于纯JMS调用:

MessageConsumer consumer = session.createDurableSubscriber(topic, "durable name");
Message message = consumer.receive();

不需要通过xml进行配置?

试试这个,但是您打算如何调用它

有关更多信息,请查看

  //Create connection facotry ..in this case JndiObjectFactoryBean because i am looking up a JNDI
  org.springframework.jndi.JndiObjectFactoryBean connectionFactory = new JndiObjectFactoryBean();
  connectionFactory.setJndiName(jndiName);
  connectionFactory.setJndiTemplate(jndiTemplate);

  org.springframework.jms.core.JmsTemplate template = new org.springframework.jms.core.JmsTemplate();
  template.setConnectionFactory(connectionFactory)
  template.setPubSubDomain(false);

  Message message = template.receive();