简体   繁体   English

JMS和ActiveMQ

[英]JMS and ActiveMQ

I need to write a server that listens (Consumer) on message queue and sends the data it reads to a database, and also another server which publish information (Producer) to this queue. 我需要编写一个用于在消息队列上侦听(消费者)并将其读取的数据发送到数据库的服务器,以及另一个将信息发布(生产者)到此队列的服务器。

I am following this official spring reference on Spring+JMS. 我正在关注Spring + JMS上的这个官方Spring参考

I don't understand the following: 我不了解以下内容:

  1. What is the relationship between JMS and ActiveMQ? JMS和ActiveMQ有什么关系?
  2. Which one of them is actually implementing the message queue? 其中哪一个实际上在实现消息队列?
  3. on the example I see: 在示例中,我看到:

     FileSystemUtils.deleteRecursively(new File("activemq-data")); 

    as a means to delete the queue. 作为删除队列的一种手段。

    Is the data of the queue maintained inside a file? 队列中的数据是否保存在文件中?

  4. If the queue is maintained of the file system, how can I scale my JMS server to more than one computer (server) 如果维护文件系统的队列,如何将我的JMS服务器扩展到多台计算机(服务器)上

Thanks! 谢谢!

JMS is only an API specification, not an implementation. JMS只是API规范,不是实现。 You need a piece of software that implements the JMS API if you want to do something with message queues. 如果要对消息队列进行操作,则需要一个实现JMS API的软件。

ActiveMQ is a message broker which implements the JMS API. ActiveMQ是一个消息代理,它实现了JMS API。 Besides ActiveMQ there are many other products that implement the JMS API. 除了ActiveMQ之外,还有许多其他实现JMS API的产品。

The idea is that your software uses the JMS API without specifically tying it to a particular implementation, so that in principle you could replace ActiveMQ by another product that implements JMS without changing anything in your program. 这个想法是,您的软件使用JMS API时不会特别将其绑定到特定的实现,因此,原则上您可以用实现JMS的另一种产品替换ActiveMQ,而无需在程序中进行任何更改。 This principle is used a lot in software development, and in the Java EE world there are many other APIs and implementations that work this way (for example, JDBC and JDBC drivers, JPA and Hibernate, the Servlet API and Tomcat). 该原理在软件开发中被大量使用,并且在Java EE世界中,还有许多其他API和实现以这种方式工作(例如JDBC和JDBC驱动程序,JPA和Hibernate,Servlet API和Tomcat)。

So, ActiveMQ is what actually implements the message queue. 因此,ActiveMQ是实际实现消息队列的对象。

Is the data of the queue maintained inside a file? 队列中的数据是否保存在文件中?

Apparently that's what ActiveMQ does by default. 显然,这就是ActiveMQ的默认设置。

If the queue is maintained of the file system, how can I scale my JMS server to more than one computer (server) 如果维护文件系统的队列,如何将我的JMS服务器扩展到多台计算机(服务器)上

First of all, the fact that ActiveMQ stores data on the file system doesn't mean that it can't scale to more than one server. 首先,ActiveMQ在文件系统上存储数据的事实并不意味着它不能扩展到多个服务器。 In fact, ultimately all software (also databases) store their data on the file system (if the data has to be persistent). 实际上,最终所有软件(还有数据库)都将其数据存储在文件系统上(如果数据必须是持久性的)。 Read the documentation on the ActiveMQ website to learn how to scale it (it does support clustering ). 阅读ActiveMQ网站上的文档以了解如何扩展它(它确实支持群集 )。

 What is the relationship between JMS and ActiveMQ? 

The Java Message Service (JMS) API is a Java Message Oriented Middleware (MOM) API for sending messages between two or more clients. Java消息服务(JMS)API是面向Java消息的中间件(MOM)API,用于在两个或多个客户端之间发送消息。 JMS is a part of the Java Platform, Enterprise Edition, and is defined by a specification developed under the Java Community Process as JSR 914. And ActiveMQ is a third party messaging service provider by following JSR 914. JMS是Java平台企业版的一部分,由在Java社区过程下开发的规范定义为JSR914。ActiveMQ是遵循JSR 914的第三方消息服务提供商。

Which one of them is actually implementing the message queue? 其中哪一个实际上在实现消息队列?

ActiveMQ provides the messaging queue implementations. ActiveMQ提供消息传递队列实现。

For Spring and ActiveMQ integration refer this post . 对于Spring和ActiveMQ集成,请参阅此文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM