编写没有“public static void main”的 JMS Publisher

发布于 2024-08-24 20:41:11 字数 916 浏览 5 评论 0原文

我在网上看到的每个示例,例如 http://www.codeproject.com /KB/docview/jms_to_jms_bridge_activem.aspx,使用 public static void main 方法创建发布者和订阅者。我认为这不适用于我的网络应用程序。

我正在学习 JMS,并且已经设置 Apache ActiveMQ 在 JBoss 5 和 Tomcat 6 上运行(没有任何故障)。

我正在编写一个需要异步发送电子邮件的消息传递 JMS 服务。

我已经编写了一个接收消息的 JMS 订阅者(该类继承 MessageListener)。

我的问题很简单:

  • 我如何编写一个发布者,以便我的 Web 应用程序可以调用它?它必须在某个地方发布吗?我的想法是创建一个带有无属性构造函数(在其中)的发布者,并从 JNDI 池(在构造函数中)获取 MessageQueue Factory 等。我的想法正确吗?
  • 如何为我的订阅者订阅队列接收器? (到目前为止,订阅者还没有构造函数,如果我写了一个构造函数,我总是订阅队列接收者吗?)

感谢您的帮助,如果我的术语不符合标准,抱歉,有太多的java术语我有时会迷路(也许java GPS就可以了!:-))

PS:有没有教程解释如何编写“更好”(更好可以意味着任何东西,但就我而言一切都与高要求请求中的性能有关)我可以在应用程序服务器(例如 JBoss 或 Glassfish)上运行的 JMS 发布者和订阅者?不要忘记 JMS 应用程序需要“保证”正常运行时间,因为许多应用程序都会使用它。

Every example I've seen on the web, e.g. http://www.codeproject.com/KB/docview/jms_to_jms_bridge_activem.aspx, creates a publisher and subscriber with a public static void main method. I don't think that'll work for my web application.

I'm learning JMS and I've setup Apache ActiveMQ to run on JBoss 5 and Tomcat 6 (with no glitches).

I'm writing a messaging JMS service that needs to send email asynchronously.

I've already written a JMS subscriber that receives the message (the class inherits MessageListener).

My question is simple:

  • How do I write a publisher that will so that my web applications can call it? Does it have to be published somewhere? My thought is to create a publisher with a no-attribute constructor (in there) and get the MessageQueue Factory, etc. from the JNDI pool (in the constructor). Is my idea correct?
  • How do I subscribe my subscriber to the Queue Receiver? (So far, the subscriber has no constructor, and if I write a constructor, do I always subscribe myself to the Queue receiver?)

Thanks for your help, sorry if my terminology is not up to scratch, there are too many java terminologies that I get lost sometimes (maybe a java GPS will do! :-) )

PS: Is there a tutorial out there that explains how to write a "better" (better can mean anything, but in my case it's all about performance in high demand requests) JMS Publisher and Subscriber that I can run on Application Server such as JBoss or Glassfish? Don't forget that the JMS application will needs a "guarantee" uptime as many applications will use this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文