java Tomcat 上的 Spring 3 JMS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10819742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring 3 JMS on Tomcat
提问by Paulius Matulionis
Is it possible to implement JMS messaging in tomcat? I have a spring mvc application and I need to implement JMS messaging.
是否可以在 tomcat 中实现 JMS 消息传递?我有一个 spring mvc 应用程序,我需要实现 JMS 消息传递。
I can not use glassfish. I know its very easy to do JMS messaging with message driven bean but on application server.
我不能使用玻璃鱼。我知道使用消息驱动 bean 但在应用程序服务器上执行 JMS 消息传递非常容易。
So if there is a possibility, can someone provide some examples how to create a JMS connection factory and queue for spring application?
因此,如果有可能,有人可以提供一些示例如何为 spring 应用程序创建 JMS 连接工厂和队列吗?
I have a JMS queue sender class:
我有一个 JMS 队列发送器类:
public class JmsQueueSender {
private JmsTemplate jmsTemplate;
private Queue queue;
public void setConnectionFactory(ConnectionFactory cf) { //?????????????????????
this.jmsTemplate = new JmsTemplate(cf);
}
public void setQueue(Queue queue) { //?????????????????????
this.queue = queue;
}
public void sendMessage(final Serializable object) {
jmsTemplate.send(this.queue, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
return session.createObjectMessage(object);
}
});
}
}
The main question is how to create a connection factory and queue, what objects to use. In glassfish I have been creating a JMS resource through application server admin console. How can I do this in spring application which runs in tomcat?
主要问题是如何创建连接工厂和队列,使用什么对象。在 glassfish 中,我一直在通过应用程序服务器管理控制台创建 JMS 资源。如何在运行在 tomcat 中的 spring 应用程序中执行此操作?
采纳答案by matt b
Yes, it's possible. Have you looked at the JMS chapterof the Spring manual?
是的,这是可能的。你看过Spring手册的JMS章节吗?
回答by David Blevins
You could also look at Apache TomEE Pluswhich is Tomcat + JMS and more. You can either drop that into Tomcat via the war distro or get the pre-bundled version.
您还可以查看Apache TomEE Plus,它是 Tomcat + JMS 等。您可以通过 war 发行版将其放入 Tomcat,也可以获取预捆绑版本。