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的各种功能的.