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 in 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 is just some common
Examples of URIs in practice.
Before detailing the connector and its role throughout the ACTIVEMQ system, it is important to understand the concept of URIs.
Uniform Resource Identifiers (URIs) are not a new concept, you may have used them many times, but you are not aware of them.
URIs are first used in the WWW network to define resources. The definition of Rui in the URI specification (participating Http://mng.bz/8iPP):
A string of compact characters used to locate abstract resources or physical resources. URIs are widely used in a wide variety of internet services because of their simplicity and flexibility.
The web address and e-mail address we use every day is a common way of using URIs.
Without going too deep to discussing URIs, let ' s briefly summarize the URI structure.
This would 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>
Instead of discussing the URI in depth, this is a brief introduction to the structure of the URI, which becomes an ideal way to clarify the URI's usefulness in the ACTIVEMQ Connector (connector).
Typically, each URI has the following structure:
< agreements >:< protocols-details-partial >
Consider the following URI:
Mailto:[email protected]
Note that the mailto scheme was used, followed by a 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 is hierarchical URIs, which take the following
Form
<scheme>://<authority><path><?query>
This kind of URIs is used by the Web browsers to identify websites. It ' s a type of URI known
As a URL (Uniform Resource Locator).
Consider the following URI example:
Mailto:[email protected]
Note that this URI uses the Mailto protocol (mailto is followed by an email address), which shows that the service we use also specifies
The specific resources that are required in the service.
Format:
< protocol >://< Authorization authentication >< path ><? query string >
This URI is used by a Web browser. It is one of the URIs that we often call URLs (Uniform Resource Locators).
Below is an example:
This URL uses the HTTP scheme and contains both path and query elements which is
Used to specify additional parameters.
Because of their flexibility and simplicity, URIs is 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 is used to create a
Connection to the broker:
tcp://localhost:61616
This was 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 is sometimes
Referred to as low-level connectors and is 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.
Here is an example:
This URL uses the HTTP protocol, including the path element (path) and the query string element, where the query string element is used to specify additional parameters.
Because of its simplicity and flexibility, ACTIVEMQ uses URIs to identify a given proxy (broker) through different connectors (connector). Back to chapter three, the introduction
For example, you can but see that the following URI creates a connection to the proxy.:
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 a option that's available on the TCP transport.
This URI is an extension of the above example by passing a parameter (trace=true section)
The notification agent (broker) needs to log all the commands executed through the connector (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 would be discussed in chapter, ActiveMQ makes
The Configure through the use of composite URIs. These composite URIs
is 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
The ACTIVEMQ provides a transmission connector for fail-over automatic transfer. If the connection between the current client and the agent (broker) becomes unavailable,
This connector supports automatic re-establishment of connections or automatic connection to other agents (brokers). As you will see in the tenth chapter,
ACTIVEMQ uses a composite URI, so the use and configuration of this fail-over automatic transfer connector is simple. This composite URI is exactly
Used to configure this automatic re-connection. Figure 4.2 is a typical instance of a composite URI.
Note that the scheme part or the URI now identifies the protocol being used (the
Static protocol'll be described later in this chapter) and the scheme-specific part
Contains one or more low-level URIs, that'll be the 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.
Note that the protocol portion of the URI (scheme) specifies the protocol used (the static protocol is discussed later in this chapter), and the Protocol Description section typically contains
1 or more secondary URIs (low-level URIs) are used to create a connection.
(For example, static: (tcp://host1:61616,tcp://host2:61616), Static is the protocol part,
tcp://host1:61616,tcp://host2:61616 is a two secondary URI used to create the connection)
NOTE Since composite URIs tend to be complex, users is often tempted to
Insert white spaces to make them more readable. Such White space isn't
Allowed, since the URI specification (and its standard Java implementation)
Doesn ' t allow it. This is a common ActiveMQ configuration mistake
Careful not to put white space in your URIs.
Note: Because composite rui are often more complex, users often insert some spaces that are more readable than URIs. However,
These spaces are not valid because the URI specification (and the Java implementation of the specification) does not allow illegal spaces in the URI.
This is a common error when configuring ACTIVEMQ, so be careful when configuring, and do not add unnecessary spaces in the URI.
Now so you had some familiarity with ActiveMQ URIs 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.
Now, you should be familiar with the basics of ACTIVEMQ URIs,
Let's start with a discussion of the various connectors supported by ACTIVEMQ. In the remainder of this chapter, we will discuss the transport connector (transport Connector)
and network connector and how to configure them.
ACTIVEMQ Real Combat Three understand the uri-understanding of the connector connector URIs