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. 网卡phy9161A

    硬件1. 网口网口使用4根信号线:两根发送,两根接收.一对信号线中一根承载0——+2.5V信号电压,而另一根负载的电压是0——-2.5V,因此可产生一个5Vpp的信号差.RJ45中有用的就是4根信号线 ...

  2. [爬虫]Python爬虫进阶

    请跳转到以下页面查看: 爬虫进阶

  3. cs108 04 oop design

    oop design 分为以下几个方面: - encapsulation and modularity(封装和模块化) - API/Client interface design(API 接口给调用类 ...

  4. MapReduce生成HFile入库到HBase

    转自:http://www.cnblogs.com/shitouer/archive/2013/02/20/hbase-hfile-bulk-load.html 一.这种方式有很多的优点: 1. 如果 ...

  5. 【转】WCF入门教程四[WCF的配置文件]

    一.概述 配置也是WCF编程中的主要组成部分.在以往的.net应用程序中,我们会把DBConn和一些动态加载类及变量写在配置文件里.但WCF有所不同.他指定向客户端公开的服务,包括服务的地址.服务用于 ...

  6. activiti小结

    前提:业务流程复杂且流程频繁变更的,建议使用工作流:其他情况不建议使用. activiti(v5.14),工作流引擎,基于jbpm.使用建模语言BPMN2.0进行定义. 工作流数据需要写入数据库,ac ...

  7. JVM内存模型 小小结

    可以看一下我的另一篇总结 JVM运行时数据区与JVM堆内存模型小结 推荐一篇文章,尚学堂的 Java内存模型深度解读 . 不方便全文转载,就摘录下吧. 以往的认知都是以基本类型.引用类型.常量.方法等 ...

  8. smb使用 ------转载自http://blog.csdn.net/tlaff/article/details/5463068

    一.在Linux系统中查看网络中Windows共享文件及Linux中的Samba共享文件: 常用到smbclient:用法如下 [root@localhost ~]# smbclient  -L  / ...

  9. erlang随机数问题

    一.计算机的随机数的老问题,伪随机数. random:seed() random:uniform(N) 如果seed是相同的,则第M次执行 random:uniform(N) .M.N相同,则得到的随 ...

  10. Z字形扫描矩阵

    问题描述 在图像编码的算法中,需要将一个给定的方形矩阵进行Z字形扫描(Zigzag Scan).给定一个n×n的矩阵,Z字形扫描的过程如下图所示: 对于下面的4×4的矩阵, 1 5 3 9 3 7 5 ...