Professional Documents
Culture Documents
Table of Contents
1 Description of the problem
1.1 Messaging . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Broking . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Decoupling . . . . . . . . . . . . . . . . . . . . . . . . .
1.4 Developing directions . . . . . . . . . . . . . . . . . . . .
1.4.1 Message Translator (Messaging Systems) . . . . .
1.4.2 Publish-Subscribe Channel (Messaging Channels).
Subscriber . . . . . . . . . . . . . . . . . . . . . .
1.4.3 Content-Based Router (Message Routing) . . . .
3
. . .
3
. . .
4
. . .
5
. . .
6
. . .
6
Durable
. . .
7
. . .
8
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
9
9
9
11
11
13
13
14
3 Code
14
4 Conslusion
18
Task : Message broker integration which will allow an asynchronous communication between the distributed components of the system.
1.1
Messaging
Messaging is a technology that enables high-speed, asynchronous, programto-program communication with reliable delivery. Programs communicate by
sending packets of data called messages to each other. Channels, also known
as queues, are logical pathways that connect the programs and convey messages. A channel behaves like a collection or array of messages, but one that
is magically shared across multiple computers and can be used concurrently
by multiple applications. A sender or producer is a program that sends a
message by writing the message to a channel. A receiver or consumer is a
program that receives a message by reading (and deleting) it from a channel.
The message itself is simply some sort of data structuresuch as a string,
a byte array, a record, or an object. It can be interpreted simply as data,
as the description of a command to be invoked on the receiver, or as the
description of an event that occurred in the sender. A message actually contains two parts, a header and a body. The header contains meta-information
about the messagewho sent it, where its going, etc.; this information is
used by the messaging system and is mostly (but not always) ignored by the
applications using the messages. The body contains the data being transmitted and is ignored by the messaging system. In conversation, when an
application developer who is using messaging talks about a message, hes
usually referring to the data in the body of the message.[1, p. 13]
Messaging capabilities are typically provided by a separate software system called a messaging system or message-oriented middleware (MOM). A
messaging system manages messaging the way a database system manages
data persistence. Just as an administrator must populate the database with
the schema for an applications data, an administrator must configure the
messaging system with the channels that define the paths of communication between the applications. The messaging system then coordinates and
manages the sending and receiving of messages. The primary purpose of a
database is to make sure each data record is safely persisted, and likewise
the main task of a messaging system is to move messages from the senders
computer to the receivers computer in a reliable fashion.
The reason a messaging system is needed to move messages from one
computer to another is that computers and the networks that connect them
3
1.2
Broking
A Message Broker takes care of all connections between the applications in an organisation. One connection is created between each system
and Message Broker, and messages transported via this bi-directional connection can be translated, filtered, archived, modified and routed to their
final destination(s).
The transport of messages can be based on one of many transport protocols supported by the broker (e.g. TCP/IP, files). The Message Broker takes
care of translations between the data formats used by the various systems.
All commonly used message formats are supported in the base product (e.g.
HL7, EDIFACT, XML, delimited formats, SAP/HCM, flat records).
The use of a Message Broker offers a scalable platform that has access to
data sent by many applications in the organisation, it improves the reliability
and accessibility of data and it concentrates all available message flows in one
point. Because of the fact that the message broker processes all messages,
a copy of the data contained in the messages can easily be forwarded to
analytical, management database or other applications. Creating a focal
point for data thus adds to the quality of care, the integration of data, and
the central management of the connections.
4
By using Message Broker as a strategic solution for all integration requirements the maintenance costs of point-to-point connections are significantly lowered and new connections can be created at little costs using the
organisations own resources. [3]
1.3
Decoupling
Loose Coupling There is considerable interest in loose coupling in distributed systems, particularly in the web services community. The terminology is often ill-defined and imprecise, though. In the context of web services,
loose coupling refers to minimizing the dependencies between services in order to have a flexible underlying architecture (reducing the risk that a change
in one service will have a knock-on effect on other services). This is partially
supported by the intended independence of web services with the subsequent
intention to produce combinations of web services as discussed above. Loose
coupling is, however, further enhanced by a number of additional features:[4,
p. 385]
Programming with interfaces provides one level of loose coupling by
separating the interface from its implementation (and also supports important areas of heterogeneity, for example in the choice of programming language and platform used). Programming with interfaces is
adopted by most distributed systems paradigms including distributed
objects and components as well as web services.
There is a trend towards simple, generic interfaces in distributed systems and this is exemplified by the minimal interface offered by the
World Wide Web and the REST approach in web services. This approach contributes to loose coupling by reducing dependency on specific operation names. One consequence of this is that data becomes
more important than operation, with the semantics of interoperation
often held in the data (for example, the associated XML document
definition in web services); this data-oriented view is discussed further
in the context of mobile systems.
As mentioned above, web services can be used with a variety of communication paradigms, including request-reply communication, asynchronous messaging or indeed indirect communication paradigms. The
level of coupling is directly affected by this choice. For example, in
request-reply communication, the two parties are intrinsically coupled;
1.4
1.4.1
Developing directions
Message Translator (Messaging Systems)
In many cases, enterprise integration solutions route messages between existing applications such as legacy systems, packaged applications, homegrown
custom applications, or applications operated by external partners. Each of
these applications is usually built around a proprietary data model. Each
application may have a slightly different notion of the Customer entity , the
attributes that define a Customer and which other entities a Customer is related to. For example, the accounting system may be more interested in the
customers tax payer ID numbers while the customer-relationship management (CRM) system stores phone numbers and addresses. The applications
underlying data model usually drives the design of the physical database
schema, an interface file format or a programming interface (API) those
entities that an integration solution has to interface with. As a result, the
applications expect to receive messages that mimic the applications internal
data format (see Figure 1).
1.4.2
The Content-Based Router examines the message content and routes the
message onto a different channel based on data contained in the message.
The routing can be based on a number of criteria such as existence of fields,
specific field values etc. When implementing a Content-Based Router, special
caution should be taken to make the routing function easy to maintain as the
router can become a point of frequent maintenance. In more sophisticated
integration scenarios, the Content-Based Router can take on the form of a
configurable rules engine that computes the destination channel based on a
set of configurable rules (see Figure 3).
2
2.1
In order to decouple the application, there must be created a common interface for the reading/writing files and for sending and receiving messages
through the communication network. This interface is IAsyncIO. This interface must be implemented by the FileIO and NetworkIO classes. These
classes will implement all the logic behind reading, writing from files or for
sending, receiving through the network. Thus, the calling classes must not
be aware of the implementation.
For the implementation I have chosen the Java 1.8 programming language and Java Development Kit 8 (link for JDK 8).
One of the ways to realize the decoupling in Java is to move the specific
component into a separate jar library and to include it at the compilation
of the sourse code. Therefore, our FileIO and NetworkIO, altogether with
IAsyncIO is moved to a separate jar library.
For realizing the Object Oriented Programming approach, the Message,
Parameter and other helping entities were also moved toa diferent package
and compiled in a separate library. The purpose of the enumerated entities
will be specified later on.
Other components of our system are the App and Broker classes. These
are the core classes of our application which perform the logic and provide
the systems main functionalites. Each of these classes is a standalone entity.
2.2
Functionalities
2.3
2.3.1
Use cases
Scenarios
Using the system, the user is able to send a read the content of an XML
file, send it to a differents user through the network, receive a confirmation
that the message arrived, receive a message from a different user, store the
content of the message in an XML file.
First scenario - read from file.
11
12
2.4
2.4.1
13
2.4.2
Component Diagram
Code
14
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 }
try {
while ( true ) {
mess = netRead . read (" localhost ");
if (! mess . getType () . equals (" change_port ")){
queue . put ( mess );
} else {
this . port = 3000;
netRead . setPort ( port );
}
}
} catch ( InterruptedException ex ) {
Logger . getLogger ( Broker . class . getName () ).
log ( Level . SEVERE , null , ex );
}
15
16
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
The rest of the code can be accessed by the repository link on github:
https://github.com/ViSilver/Message-Broker.
17
Conslusion
18
References
[1] Gregor Hohpe, Bobby Woolf, Enterprise Integration Patterns. Designing, Building and Deploying Messaging Sollutions, 2012.
[2] Andrew S. Tanenbaum, Prentice Hall, Computer Networks, 1999.
[3] Ren Spronk - Sr.Consultant, Ringholm bv, The role of Message Brokers: a management overview, October 2003.
[4] George Coulouris, Jean Dollimore, im Kindberg, Gordon Blair, DISTRIBUTED SYSTEMS. Concepts and Design, Fifth Edition, 2012.
[5] http://www.json.org/
19