我想在不使用xml配置的情况下执行此操作。我正在玩Spring JMS,看看它是否满足我的需求。无论如何使用
进行同步接收JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
jmsTemplate.receive()
因此它等同于纯JMS调用:
MessageConsumer consumer = session.createDurableSubscriber(topic, "durable name");
Message message = consumer.receive();
无需通过xml配置?
答案 0 :(得分:0)
试试这个,但你打算怎么称呼呢?
//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();