activemq 实战 一

This chapter covers

? Introduction to the use case for each of the book examples

? Use of Maven for compiling and running the examples

? How to use the example applications with ActiveMQ

本章内容包括:

介绍本书中所有实例的用例

使用Maven编译和运行书中实例

如何使用ActiveMQ的示例应用程序

ActiveMQ provides all the features from the JMS specification and adds many more powerful features on top of that. This is depicted in figure 3.1 and these features will be discussed through the rest of the book. In order to best demonstrate these features, two new examples have been created that are modeled after real business domains. Compared to the example that’s part of the ActiveMQ distribution, these examples lend themselves to demonstrating the features in ActiveMQ in a more complete and easy manner.

ActiveMQ提供JMS规范中的所有功能,同时还具有很多规范之外的强大功能,如图3.1所示.这些功能将在本书

的剩余部分中讨论.为了说明这些功能,书中创建了两个基于真实业务场景的实例.

相对于ActiveMQ版本中的自带的实例来说,书中的两个实例更能够用一种简单的方式完整的展示ActiveMQ的功能.

One of the examples is based on a stock portfolio and the other is based on a

job queue. These two examples are more extensive than the examples that come

with ActiveMQ. The use case for each of these examples is introduced briefly, followed

by a deeper discussion of how to use them. You can refer back to this chapter

at any time throughout the book if you need a refresher on the examples.

两个实例一个是基于股票,另一个是基于任务队列的.这两个实例比ActiveMQ自带的实例拥有更广泛的参考性.

在两个实例用例简洁的介绍之后,是关于如何深入使用用例的深入介绍.

你可以在阅读本书的过程中适时的回顾本章以复习这两个实例.

The stock portfolio demonstrates the publish/subscribe messaging domain.

Publishers broadcast stock price messages to many interested subscribers.

Messages are published to a JMS destination called a topic and clients with

active subscriptions receive messages. Using this model, the broker delivers messages to each

subscriber without the need to poll for messages.

Every active subscriber receives its own copy of each message published to the topic.

Publishers are decoupled from subscribers via the topic. Unless durable subscriptions are

used, subscribers must be active in order to receive messages sent by publishers to the topic.

A copy of each message on a given destination is delivered to all topic subscribers using the pub/sub domain.

stock portfolio这个实例介绍了发布/订阅消息的使用.发布者广播股票价格消息给许多感兴趣的订阅者.

消息被发布到一个被称为主题(topic)JMS目的地(destination),这样客户端的活跃的订阅者将会收到消息.

使用这个模型,代理分发消息给每一个订阅者不需要推送消息.每一个活跃的消息订阅者将收到属于他们自己

已被发布得到主题(topic)的消息拷贝.消息发布者和接收者通过主题实现解耦.除非持久订阅,否则每一个消息

接收者必须是活动的,以便接受消息发布者发送给主题的消息.通过使用发布/订阅模型,

每一个带有指定目的地的消息拷贝会被分发给所有的主题订阅者.

The job queue demonstrates the point-to-point (PTP) messaging domain. Message

producers send job messages to a JMS queue, from which message consumers receive

the job messages for processing. There’s no timing requirement for the producers

and consumers to be online at the same time with the point-to-point domain. The

queue holds messages until consumers are available to receive them. As consumers

are available, messages are delivered to all consumers, but no two consumers receive

the same message. Messages on a given destination are delivered to queue consumers

in a round-robin fashion using the PTP domain.

job queue这个实例介绍了点对点消息的使用(PTP).消息生产者发送job消息给JMS消息队列,消息

消费者从消息队列接收消息然后做相应的处理.使用点对点消息模式,消息生产者和消费者不需要同时在线.

消息队列将保存消息直到消息消费者成功的接收了消息.在消息消费者可用时,消息被分发给所有消费者,

但是两个消费者不会收到同一个消息.点对点消息发送模型,将带有指定目的地的消息通过轮询的方式分发给

队列中的消费者.

Not only is each example focused on a different messaging domain, but each is

also focused on a separate use case. Additionally, although the diagrams depicted later

in this chapter for each example look nearly the same at first glance, the important

difference between the two lies in the two messaging domains. The stock portfolio

example uses topics for pub/sub messaging, whereas the job queue example uses

queues for point-to-point messaging. The source for these examples is readily available

and can be downloaded from the Manning website via the following URL: http://

manning.com/snyder/activemq-in-action-examples-src.zip.

两个实例不仅仅使用了不同的消息发送模型,而且每一个实例各自关注独立的用例.另外,

尽管如本章稍后所示,两个例子的示意图乍看起来很相似,但是两个实例使用的消息

发送模型是不同的.stock portfolio实例使用主题实现消息的发布/订阅,而job queue的例子

使用消息队列实现点对点的消息发送和接收.这两个例子的源代码可以从下面的链接下载:

http://manning.com/snyder/activemq-in-action-examples-src.zip.

(译注:貌似现在这个连接已失效,可以同这个页面http://manning.com/snyder/,在Downloads部分下载)

In this chapter, first we’ll download Maven and install it in order to compile and

run the examples. After this is complete, we’ll review each example and demonstrate

how each one should behave. After the completion of these exercises, you’ll be familiar

enough with the examples to recognize them throughout the book and see how

they’re used to demonstrate the features in ActiveMQ.

本章中,我们首先下载并安装Maven,以便编译和运行实例代码.之后,我们将复习每一个实例并说明

每一个实例的应当如何运行.完成这些后,你对这两个实例已经很熟悉了,可以很清楚的看到在本书

中这两个实例时如何说明ActiveMQ的各种功能的.

时间: 2024-08-30 02:01:22

activemq 实战 一的相关文章

ActiveMQ实战篇之ActiveMQ实现request/reply模型(二)

ActiveMQ实战篇之ActiveMQ实现request/reply模型(二) 原文地址:https://www.cnblogs.com/bincoding/p/8254113.html

ActiveMQ实战

ActiveMQ是JMS规范的一个实现产品,即对JMS的一套接口进行了实现.所以下面我们先对JMS与ActiveMQ进行一个简单介绍,然后再介绍ActiveMQ的P2P与PubSub两种开发模式. 一.    JMS简介 JMS即Java消息服务,是J2EE的13规范之一,是一套面向消息中间件(MOM)的应用程序接口.用在两个程序之间,或分布式系统中发送消息,进行异步通信. JMS使我们能够通过消息收发服务(也可以称为,消息中介程序或路由器)从一个JMS客户机向另一个JMS客户机发送消息.消息是

ActiveMQ的作用总结(应用场景及优势)以及springboot+activeMq 实战

业务场景说明: 消息队列在大型电子商务类网站,如京东.淘宝.去哪儿等网站有着深入的应用, 队列的主要作用是消除高并发访问高峰,加快网站的响应速度. 在不使用消息队列的情况下,用户的请求数据直接写入数据库,在高并发的情况下,会对数据库造成巨大的压力,同时也使得系统响应延迟加剧. 在使用队列后,用户的请求发给队列后立即返回, (例如: 当然不能直接给用户提示订单提交成功,京东上提示:您"您提交了订单,请等待系统确认"), 再由消息队列的消费者进程从消息队列中获取数据,异步写入数据库. 由于

Spring下ActiveMQ实战

MessageQueue是分布式的系统里经常要用到的组件,一般来说,当需要把消息跨网段.跨集群的分发出去,就可以用这个.一些典型的示例就是: 1.集群A中的消息需要发送给多个机器共享: 2.集群A中消息需要主动推送,但彼此的网络不是互通的(如集群A只有过HA才能被外界访问): 当然上面的几个点,除了用MQ还有其它实现方式,但是MQ无疑是非常适合用来做这些事的.众多MQ中,ActiveMQ是比较有名气也很稳定的,它发送消息的成本非常廉价,支持Queue与Topic两种消息机制.本文主要就是讲如何在

Java消息队列--ActiveMq 实战

原文地址:http://www.cnblogs.com/jaycekon/p/6225058.html 1.下载安装ActiveMQ ActiveMQ官网下载地址:http://activemq.apache.org/download.html ActiveMQ 提供了Windows 和Linux.Unix 等几个版本,楼主这里选择了Linux 版本下进行开发. 下载完安装包,解压之后的目录: 从它的目录来说,还是很简单的: bin存放的是脚本文件 conf存放的是基本配置文件 data存放的是

ActiveMQ实战-集群

原文:http://blog.csdn.net/lifetragedy/article/details/51869032 ActiveMQ的集群 内嵌代理所引发的问题: 消息过载 管理混乱 如何解决这些问题--集群的两种方式: Master slave Broker clusters ActiveMQ的集群有两种方式: MASTER/SLAVE模式 Cluster模式 Pure Master Slave Pure master slave的工作方式: 当master broker失效的时候.Sl

Apache ActiveMQ实战(2)-集群

ActiveMQ的集群 内嵌代理所引发的问题: 消息过载 管理混乱 如何解决这些问题--集群的两种方式: Master slave Broker clusters ActiveMQ的集群有两种方式: MASTER/SLAVE模式 Cluster模式 Pure Master Slave Pure master slave的工作方式: 当master broker失效的时候.Slave broker 做出了两种不同的相应方式 启动network connectors和transport connec

Apache ActiveMQ实战(1)-基本安装配置与消息类型

ActiveMQ简介 ActiveMQ是一种开源的,实现了JMS1.1规范的,面向消息(MOM)的中间件,为应用程序提供高效的.可扩展的.稳定的和安全的企业级消息通信.ActiveMQ使用Apache提供的授权,任何人都可以对其实现代码进行修改. ActiveMQ的设计目标是提供标准的,面向消息的,能够跨越多语言和多系统的应用集成消息通信中间件.ActiveMQ实现了JMS标准并提供了很多附加的特性.这些附加的特性包括,JMX管理(java Management Extensions,即java

activemq 实战二 连接到ActiveMQ-Connecting to ActiveMQ

The main role of a JMS broker such as ActiveMQ is to provide a communication infrastructure for client applications. For that reason, ActiveMQ provides connectors, a connectivity mechanism that provides client-to-broker communications (using transpor

activemq 实战 四 传输连接器-Transport connectors 4.2

In order to exchange messages, producers and consumers (clients) need to connect to the broker. This client-to-broker communication is performed through transport connectors. ActiveMQ provides an impressive list of protocols clients can use to exchan