Before discussing the details of connectors and their role in the overall ActiveMQ

architecture, it’s important to understand connector URIs. Uniform resource identifiers

(URIs), as a concept, aren’t new, and you’ve probably used them over and over again

without realizing it. URIs were first introduced for addressing resources on the World

Wide Web. The specification (http://mng.bz/8iPP) defines the URI as “a compact

string of characters for identifying an abstract or physical resource.” Because of the

simplicity and flexibility of the URI concept, they found their place in numerous internet

services. Web URLs and email addresses we use every day are just some common

examples of URIs in practice.

在详细介绍连接器及其在整个ActiveMQ体系中所扮演的角色之前,弄清URI的概念是非常重要的.

统一资源标识符(URI)不是一个新的概念,你可能已经用过他们好多次了,只是你还没有意识到.

URI首先在WWW网中用来定义资源.URI规范(参加http://mng.bz/8iPP)中对RUI的定义:

一串用于定位抽象资源或物理资源的紧凑字符.URI因其简单和灵活,而被广泛用于各种各样的因特网服务中.

我们天天使用的web地址和email地址就是URI的普通列子.

Without going too deep into discussing URIs, let’s briefly summarize the URI structure.

This will serve as an ideal introduction to URI usage in ActiveMQ in regard to

connectors.

Basically, every URI has the following string format:

<scheme>:<scheme-specific-part>

这里不打算深入讨论URI,而是简要介绍URI的结构,这将成为阐明URI在ActiveMQ连接器(connector)中用处的理想方法.

通常,每个URI都有如下结构:

<协议>:<协议-细节-部分>

Consider the following URI:

mailto:users@activemq.apache.org

Note that the mailto scheme is used, followed by an email address to uniquely identify

both the service we’re going to use and the particular resource within that service.

The most common form of URIs are hierarchical URIs, which take the following

form:

<scheme>://<authority><path><?query>

This kind of URI is used by web browsers to identify websites. It’s a type of URI known

as a URL (Uniform Resource Locator).

请看如下URI示例:

mailto:users@activemq.apache.org

注意,这个URI使用了mailto协议(mailto后面是是email地址),该协议既说明了我们使用的服务同时也指定了

该服务中所需的特定的资源.

格式:

<协议>://<授权认证><路径><?查询字符串>

这种URI是web浏览器使用的.它是URI的一种,即我们常说的URL(统一资源定位器).

Below is an example:

This URL uses the http scheme and contains both path and query elements which are

used to specify additional parameters.

Because of their flexibility and simplicity, URIs are used in ActiveMQ to address specific

brokers through different types of connectors. If we go back to the examples discussed

in chapter 3, you can see that the following URI was used to create a

connection to the broker:

tcp://localhost:61616

This is a typical hierarchical URI used in ActiveMQ, which translates to “create a TCP

connection to the localhost on port 61616.”

ActiveMQ connectors using this kind of simple hierarchical URI pattern are sometimes

referred to as low-level connectors and are used to implement basic network communication

protocols. Connector URIs use the scheme part to identify the underlying

network protocol, the path element to identify a network resource (usually host and

port), and the query element to specify additional configuration parameters for the

connector. The anatomy of a URI is shown in figure4.1.

下面是一个例子:

这个URL使用http协议,包含路径元素(path)和查询字符串元素(query),其中查询字符串元素用来指定额外的参数.

因为简单灵活,ActiveMQ通过不同的连接器(connector)使用URI来标识给定的代理(broker).回到第三章中导论的

例子,你可以但看到下面的URI创建了一个连接到代理的连接.:

tcp://localhost:61616

tcp://localhost:61616?trace=true

scheme path query

Figure 4.1 Anatomy of a URI

This URI extends the previous example by also telling the broker to log all commands

sent over this connector (the trace=true part).

This is just one example of an option that’s available on the TCP transport.

这个URI是上面的例子的扩展,通过传递一个参数(trace=true部分)

告知代理(broker)需要给所有通过连接器(connector)执行的命令记录日志.

The failover transport in ActiveMQ supports automatic reconnection as well as the

ability to connect to another broker just in case the broker to which a client is currently

connected becomes unavailable. As will be discussed in chapter 10, ActiveMQ makes

this easy to use and configure through the use of composite URIs. These composite URIs

are used to configure such automatic reconnection. In figure 4.2, you can see an example

of a typical composite URI.

static:(tcp://host1:61616,tcp://host2:61616)

scheme   path1             path2

ActiveMQ提供一种失效自动转移的传输连接器.如果当前客户端与代理(broker)之间的连接变得不可用,

这种连接器支持自动重新建立连接,或者自动连接到其他的代理(broker).正如你将在第十章中看到的,

ActiveMQ使用一种复合URI,因而这种失效自动转移的传输连接器的使用和配置都很简答.这种复合URI正是

用了配置这种自动重连的. 图4.2是一个复合URI的一个典型实例.

Note that the scheme part or the URI now identifies the protocol being used (the

static protocol will be described later in this chapter) and the scheme-specific part

contains one or more low-level URIs that will be used to create a connection. Of

course, every low-level URI and the larger composite URI can contain the query part

providing specific configuration options for the particular connector.

注意,URI的协议部分(scheme)指定了使用的协议(本章稍后将讨论static协议),协议说明部分通常包含

1个或多个次级URI(low-level URIs)用来创建连接.

(译注: 比如static:(tcp://host1:61616,tcp://host2:61616)中,static是协议部分,

tcp://host1:61616,tcp://host2:61616是两个次级URI用来创建连接)

NOTE Since composite URIs tend to be complex, users are often tempted to

insert white spaces to make them more readable. Such white space is not

allowed, since the URI specification (and its standard Java implementation)

doesn’t allow it. This is a common ActiveMQ configuration mistake, so be

careful not to put white space in your URIs.

注意: 因为复合RUI通常比较复杂,用户经常会插入一些空格是的符合URI可读性更好些.但是,

这些空格是不合法的,因为URI规范(以及该规范的Java实现)不允许URI中的非法空格.

这是在配置ActiveMQ时的一个常见错误,所以在配置时需要十分小心,不要在URI中添加不必要的空格.

Now that you have some familiarity with ActiveMQ URI basics, let’s move on to discuss

various connectors supported by ActiveMQ. In the rest of this chapter, we’ll discuss

transport connectors and network connectors and how to configure them.

现在,你应该对ActiveMQ URI的基础知识有些熟悉了,

让我们开始讨论ActiveMQ支持的各种连接器.在本章的剩余部分,我们将讨论传输连接器(transport connector)

和网络连接器(network connector)以及如何配置他们.

activemq 实战三 了解连接器的URI-Understanding connector URIs的更多相关文章

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

    In order to exchange messages, producers and consumers (clients) need to connect to the broker. This ...

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

    The main role of a JMS broker such as ActiveMQ is to provide a communication infrastructure for clie ...

  3. spring +ActiveMQ 实战 topic selecter指定接收

    spring +ActiveMQ 实战 topic selecter指定接收 queue:点对点模式,一个消息只能由一个消费者接受 topic:一对多,发布/订阅模式,需要消费者都在线(可能会导致信息 ...

  4. coreseek实战(三):全文搜索在php中应用(使用api接口)

    coreseek实战(三):全文搜索在php中应用(使用api接口) 这一篇文章开始学习在php页面中通过api接口,使用coreseek全文搜索. 第一步:综合一下前两篇文章,coreseek实战( ...

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

    ActiveMQ简介 ActiveMQ是一种开源的,实现了JMS1.1规范的,面向消息(MOM)的中间件,为应用程序提供高效的.可扩展的.稳定的和安全的企业级消息通信.ActiveMQ使用Apache ...

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

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

  7. Python爬虫实战三之实现山东大学无线网络掉线自动重连

    综述 最近山大软件园校区QLSC_STU无线网掉线掉的厉害,连上之后平均十分钟左右掉线一次,很是让人心烦,还能不能愉快地上自习了?能忍吗?反正我是不能忍了,嗯,自己动手,丰衣足食!写个程序解决掉它! ...

  8. Thrift RPC实战(三) thrift序列化揭秘

    本文主要讲解Thrift的序列化机制, 看看thrift作为数据交换格式是如何工作的? 1.构造应用场景: 1). 首先我们先来定义下thrift的简单结构. 1 2 3 4 5 namespace ...

  9. miniFTP项目实战三

    项目简介: 在Linux环境下用C语言开发的Vsftpd的简化版本,拥有部分Vsftpd功能和相同的FTP协议,系统的主要架构采用多进程模型,每当有一个新的客户连接到达,主进程就会派生出一个ftp服务 ...

随机推荐

  1. NFS根文件系统

    按照以前文档可以正确制作根文件系统,并且开发板可正确nfs挂测主机目录. 现只需修改bootargs,使内核启动时挂测文件系统即可.setenv bootargs mem=64M console=tt ...

  2. win7、vs2013编译webkit总结

    在windows7.vs2013环境下编译webkit,本人测试成功 1.解压cygwin到C盘下(建议放在C盘更目录下,否则编译期间会有部分文件找不到) 启动命令:C:\cygwin\bin\min ...

  3. [转]Handler学习笔记(二)

    一.一个问题 有这样一个问题值得我们思考,若把一些类似于下载的功能(既耗时且不一定有结果)写在Activity(主线程)里,会导致Activity阻塞,长时间无响应,直至页面假死(如果5秒钟还没有完成 ...

  4. CF555B 贪心

    http://codeforces.com/problemset/problem/555/B B. Case of Fugitive time limit per test 3 seconds mem ...

  5. Charles安装包及破解包下载地址

    Charles安装包及破解包下载地址 http://xclient.info/s/charles.html?_=baf317d2a9932afca9b32c327f8a34c9

  6. English Sentenses【no use】

    1.Sorry if I might sound arrogant or offensive. 2.Any further question? 3.How dare you! 4.Try it if ...

  7. MFC 窗体样式修改

    窗体创建之后,如何设置窗体的样式呢? 一般情况下使用GetWindowLongW与SetWindowLongW即可实现窗体样式的修改或者使用ModifyStyle. 关于MFC存在GetWindowL ...

  8. udhcpc

    /********************************************* * dhcpc * dhcpc是dhcp的客户端,在busybox中实现.今天正好了解一下. * Tony ...

  9. imx6 uart分析

    本文主要记录: 1.uart设备注册 2.uart驱动注册 3.上层应用调用有些地方理解的还不是很透彻,希望指正. 1.uart设备注册过程 MACHINE_START(MX6Q_SABRESD, & ...

  10. API Design Principles -- QT Project

    [the original link] One of Qt’s most reputed merits is its consistent, easy-to-learn, powerfulAPI. T ...