Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

JVM Languages

Defining the ESB


Understanding the ESB Internals

Let's look at what happens inside the ESB when the "Hello, World!" application is executed. When you run the JMS client code in Listing One with the ESB, it appears that the message sent by the producer is simply received by the consumer component, as in Figure 16.

Figure 16: The JMS message is sent by the producer and then received by the consumer. The ESB internal message system reliable transports and routes the message to the proper message consumer(s).

In reality, the ESB is itself listening with its own consumer, thereby intercepting and then routing the message back to the client application's consumer via its own internal message producer. This involved, but transparent, message interaction is shown more clearly in Figure 17.

Figure 17: With the ESB, the JMS message is consumed internally, routed, and then sent again by the ESB to the client. This message routing is performed without adding any code within the components.

It's precisely this sort of automated messaging capability, along with the associated message routing, that is the foundation for the ESB's power and ease of use. The internal interception and routing of messages allows the ESB to distribute processing across process and machine boundaries in order to improve overall system scalability, and to transparently provide failover and redundancy across various parts of the network deployment.

It's time to prove that the ESB and its internal message routing works, and that the "Hello, world!" message will truly be received and displayed. Follow along as we run the application and see the message delivered first-hand.

Running the Application

Let's recap what we're trying to accomplish with this sample application. So far, we've downloaded and installed the ServiceMix ESB, written the Java code for the message sender and receiver components, and wrote the ESB configuration file which specifies some simple message routing guidelines. Now let's prepare to execute the application and watch the ESB in action. The first step in running any ESB application is to ensure that the ESB itself is running.

Start the ServiceMix ESBFor this example, you will need to download the complete sample code for this article. While the listings above contained the full Java source code, there is an ant script (not shown) and more to the configuration file in Listing Three. The "Hello, world!" application should be placed in a directory called hello-world, which is the directory you should change to when you run it.

  • Running on Microsoft Windows
    • To start the ServiceMix ESB on Windows, enter the following command from within the hello-world directory:

      > c:\servicemix-3.1\bin\servicemix.bat servicemix.xml
      

  • Running on Unix
      To start the ServiceMix ESB on Unix, enter the following command from within the hello-world directory:

      >  /usr/local/servicemix-3.1/bin/servicemix servicemix.xml
      

Note: Remember to ensure that execute permission is set on the servicemix shell script within the servicemix-3.1/bin directory.

When the ESB has completely started, you should see output similar to that in Figure 18.

Figure 18: The output displayed when ServiceMix is started for the "Hello, world!" sample application

Once startup is complete, you can run the sample client application that will send, receive, and display the "Hello, world!" message.

Run the Client ApplicationYou can run the sample client application on either Windows or Unix via the supplied ant script with the following simple command from within a second command prompt or terminal window:

> ant

With this one command, the sample client application will be compiled, if needed, and run. If successful, the output you receive should appear similar to that in Figure 19.

Figure 19: When the ESB sample "Hello, world!" application is run, the response output will be in the form of XML. Of course, using an ESB to send the message, "Hello, world!" is overkill, but it serves as an example that's easy to understand and get running.

The proper response is the "Hello, world!" message within the XML that was actually routed through the ESB. This text is seen just before "Done" message, at the bottom of Figure 19. Looking back at the first command prompt or terminal window, where the ESB is running and its output displayed, you should see some messages pertaining to a transaction that is started and then committed as the message is delivered. By default, with ServiceMix and this sample application, a transaction is started as each message is transported.

So there you have it -- your first ESB-based application. Reliable messaging, message routing, message normalization, and transaction support, all provided transparently and with very little code.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.