首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

七 使用ActiveMQ创建Java程序

2013-11-06 
7 使用ActiveMQ创建Java程序7 Creating Java applications with ActiveMQ7 使用ActiveMQ创建Java程序?This

7 使用ActiveMQ创建Java程序

7 Creating Java applications with ActiveMQ

7 使用ActiveMQ创建Java程序

?

This chapter covers

? Embedding ActiveMQ in Java applications

? Embedding ActiveMQ using Spring

? Creating request/reply applications

? Writing JMS clients using Spring

?

本章内容包括:

? ? 嵌入ActiveMQ到Java程序

? ? Spring中集成ActiveMQ

? ? 创建问询/应答程序

? ? 使用Spring创建JMS客户端

?

Thus far the book has concentrated on ActiveMQ as a software application. Most of

the information we’ve presented has concerned the internal structure of ActiveMQ

and how its components can be configured. But apart from basic JMS examples,

using ActiveMQ in your applications hasn’t been discussed. This chapter is dedicated

to explaining how to create applications with ActiveMQ.

?

到目前位置,ActiveMQ被当成应用软件来看待.我们关注的大部分信息都是关于ActiveMQ的内部结构

以及如何配置ActiveMQ组件的.但是,除了那两个基本的JMS例子,我们尚未讨论过在你自己的程序中

使用ActiveMQ.因而,本章将讨论如何使用ActiveMQ创建应用程序.

?

One of the things you might want to do with ActiveMQ is to embed it into your

application. Since ActiveMQ is written in Java, it can naturally be integrated in

another Java application. As you’ll see, you can configure the broker using either

Java code or XML (via the Spring Framework). A fully configured broker can serve

clients from the same application (using the VM protocol) as well as clients from

remote applications to exchange messages over the network. This scenario is

depicted in figure 7.1.

?

将ActiveMQ嵌入到你的应用程序可能是你要做的.因为ActiveMQ是用Java写的,ActiveMQ天生的具有集成到

其他Java程序中的能力.你将看到,你可以使用Java代码或者XML文件(通过Spring矿建)来配置代理.配置好

的代理可以为应用程序自身服务(通过VM协议)也可以为远程应用程序的客户端服务以便通过网络交换消息.

图7.1描述了这一场景.

?

The first section of this chapter will explore various techniques available for embedding

ActiveMQ in your Java applications. The second section will explain how to

embed ActiveMQ using Spring. You’ll see how to configure ActiveMQ using both pure

Spring XML and custom namespaces, as well as the standard ActiveMQ XML via

Apache XBean (http://mng.bz/EAfX). This will be followed by a discussion of some

advanced programming techniques that include ActiveMQ. This is a vast topic and

we’ll dig into two common use cases. We’ll also take a look at how to create a request/

reply system using JMS and ActiveMQ. We’ll discuss advantages of such a system over

the traditional client-server architecture.

?

本章第一节节将介绍各种可用的技术用来将ActiveMQ嵌入到Java程序中,第二节的内容将介绍如何使用Spring来

嵌入ActiveMQ.你将看到如何使用Spring的配置文件和自定义命令空间以及使用Apache XBean(http://mng.bz/EAfX)

的标准ActiveMQ XML文件来配置ActiveMQ.接着,我们会讨论一些ActiveMQ相关的高级编程技术.这里我们会

通过两个基本的用例来讨论这个广阔的话题.我们还将看到如何使用JMS和ActiveMQ创建一个问询/应答系统

并讨论使用ActiveMQ消息的系统比传统的CS架构系统的优越性.

?

Finally, you’ll learn about using Spring JMS to simplify the creation of JMS clients

with ActiveMQ. Using the stock portfolio sample application, we’ll use Spring JMS to

set up connections, consumers, and producers in a quick manner. To begin, let’s discuss

embedding ActiveMQ in your applications. There’s no single correct way to

embed ActiveMQ. The method you choose will probably depend on your application

design.

?

最后,你将学习如何利用Spring JMS来简化通过ActiveMQ创建JMS客户端的过程.使用stock portfolio

例子,我们可以使用Spring JMS快速设置连接,消息消费者和消息生产者.现在,让我从讨论在你自己

的应用程序中嵌入ActiveMQ开始.没有所谓的正确的嵌入ActiveMQ的方式,你需要根据你程序的架构

来选择使用何种方式嵌入ActiveMQ.

?

热点排行