所以我有以下出版商:
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.Topic;
import org.springframework.jms.core.MessageCreator;
import org.springframework.jms.core.JmsTemplate;
public class JmsTopicSender {
private JmsTemplate jmsTemplate;
private Topic topic;
public void setTopic(Topic topic) {
this.topic = topic;
}
public void simpleSend() {
this.jmsTemplate.send(this.topic, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage("hello Topic");
}
});
}
}
所以我现在坚持设置 bean 声明。我知道我需要一个 JMSTemplate:
<bean id="jms-template" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connection-factory" />
<property name="defaultDestination" ref="destination" />
</bean>
但我不知道如何设置连接工厂或目的地。spring 文档中甚至没有示例。