activemq 实战三 了解连接器的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.

在详细介绍连接器及其在整个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:[email protected]

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:[email protected]

注意,这个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)以及如何配置他们.

时间: 2024-10-31 19:14:25

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

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

In order to exchange messages, producers and consumers (clients) need to connect to the broker. This client-to-broker communication is performed through transport connectors. ActiveMQ provides an impressive list of protocols clients can use to exchan

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

The main role of a JMS broker such as ActiveMQ is to provide a communication infrastructure for client applications. For that reason, ActiveMQ provides connectors, a connectivity mechanism that provides client-to-broker communications (using transpor

Python机器学习实战&lt;三&gt;:k-邻近算法

安装说明参考openssl源码文件夹下INSTALL.W32 step1 环境搭建 安装perl,Visual Studio 2008 下载Openssl最新版源码.我下的版本为OpenSSL-1.0.0g. step2 启动Visual Studio 2008 Command Prompt 运行bin\vcvars32 设置 环境变量 注意: 如遇反馈"此处不应该有/Microsoft",参考错误1. step3 VS命令行窗口cd至openssl源码文件夹 执行以下命令 $perl

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

ActiveMQ简介 ActiveMQ是一种开源的,实现了JMS1.1规范的,面向消息(MOM)的中间件,为应用程序提供高效的.可扩展的.稳定的和安全的企业级消息通信.ActiveMQ使用Apache提供的授权,任何人都可以对其实现代码进行修改. ActiveMQ的设计目标是提供标准的,面向消息的,能够跨越多语言和多系统的应用集成消息通信中间件.ActiveMQ实现了JMS标准并提供了很多附加的特性.这些附加的特性包括,JMX管理(java Management Extensions,即java

机器学习实战三(Naive Bayes)

机器学习实战三(Naive Bayes) 前两章的两种分类算法,是确定的分类器,但是有时会产生一些错误的分类结果,这时可以要求分类器给出一个最优的猜测结果,估计概率.朴素贝叶斯就是其中一种. 学过概率论的人对于贝叶斯这个名字应该是相当的熟悉,在学条件概率的时候,贝叶斯公式可谓是一针见血.这里的"朴素贝叶斯",是因为在计算贝叶斯概率的时候只考虑最原始.最简单的假设. Naive Bayes(朴素贝叶斯) 优点:在数据较少的情况下依然有效,可处理多类别问题. 缺点:对于输入数据的格式要求严

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

ActiveMQ实战篇之ActiveMQ实现request/reply模型(二) 原文地址:https://www.cnblogs.com/bincoding/p/8254113.html

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

本文主要讲解Thrift的序列化机制, 看看thrift作为数据交换格式是如何工作的? 1.构造应用场景: 1). 首先我们先来定义下thrift的简单结构. 1 2 3 4 5 namespace java com.yangyang.thrift.api struct Pair { ? ? 1: required string key ? ? 2: required string value } required修饰符你肯定能猜测到它的意义, 但是你是否有没有这样的疑惑, "1",

ActiveMQ5.0实战三:使用Spring发送,消费topic和queue消息

实战一 , 实战二 介绍了ActiveMQ的基本概念和配置方式. 本篇将通过一个实例介绍使用spring发送,消费topic, queue类型消息的方法. 不懂topic和queue的google 之. 如图示, TOPIC和QUEUE分别代表一个topic和一个queue消息通道. TopicMessageProducer向topic发送消息, TopicConsumerA和TopicConsumerB则从topic消费消息. QueueMessageProducer向Queue发送消息, Q

ActiveMQ实战

ActiveMQ是JMS规范的一个实现产品,即对JMS的一套接口进行了实现.所以下面我们先对JMS与ActiveMQ进行一个简单介绍,然后再介绍ActiveMQ的P2P与PubSub两种开发模式. 一.    JMS简介 JMS即Java消息服务,是J2EE的13规范之一,是一套面向消息中间件(MOM)的应用程序接口.用在两个程序之间,或分布式系统中发送消息,进行异步通信. JMS使我们能够通过消息收发服务(也可以称为,消息中介程序或路由器)从一个JMS客户机向另一个JMS客户机发送消息.消息是