当前位置: 首页 > ActiveMQ in Action 读书笔记 > 正文

4.1 了解连接器的URI-Understanding connector URIs

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.








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



Basically, every URI has the following string format:







Consider the following URI:


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



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).












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:


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.









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.





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.



scheme   path1             path2





用了配置这种自动重连的. 图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.



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

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




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可读性更好些.但是,




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)以及如何配置他们.

赞 赏

   微信赞赏  支付宝赞赏

本文固定链接: https://www.jack-yin.com/coding/translation/activemq-in-action/748.html | 边城网事

该日志由 边城网事 于2013年09月22日发表在 ActiveMQ in Action 读书笔记 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: 4.1 了解连接器的URI-Understanding connector URIs | 边城网事
关键字: ,

4.1 了解连接器的URI-Understanding connector URIs 暂无评论