Sie sind auf Seite 1von 4

1/3/2015

FuseByExample/camel-example-tcpip-proxy GitHub

This repository

Explore

Search

Features

Enterprise

Blog

Sign up

FuseByExample / camel-example-tcpip-proxy

Star

Sign in

Fork

Fuse ESB (ServiceMix) example of Apache Camel acting as an TCP/IP Proxy with failover capability
Code
15 commits

2 branches

branch: master

0 releases

6 contributors

camel-example-tcpip-proxy /

Issues

Pull Requests

Switched to jboss.org repos, updated to GA version 379


kevinearls authored on Jun 9, 2014

latestcommitd0dcfdcd66

client

Updated the URI to use localhost instead of the 0.0.0.0 address so th

2 years ago

controller

Fixed the controller module test case to not append line-feed ("\n")

2 years ago

images

Update readme, pom files and images to JBoss Fuse 6.0.0

2 years ago

router

Updated the comment being added.

2 years ago

.gitignore

Update to JBoss Fuse 6.0.0.redhat-024

2 years ago

README.md

Initial commits for 6.1 release

pom.xml

Switched to jboss.org repos, updated to GA version 379

Pulse
Graphs

HTTPS clone URL

https://github.com/Fuse
ByExample/camel

a year ago
7 months ago

You can clone with HTTPS or


Subversion.

Clone in Desktop
Download ZIP

README.md

Using Fuse ESB to Manage Controller


Failover
This document describes a simple prototype that demonstrates the use of Fuse ESB to manage
TCP/IP controller failover.
Here is the design:

Client sends TCP/IP messages to ESB acting as a proxy. A failover-capable router pickups up
messages and sends them to Controller 1 using a TCP/IP service call. Controller 1 stamps the
message as having been processed and returns it to the router, and then back to the Client
application.
If Controller 1 fails, the router fails over to Controller 2. For purposes of a fast prototype, Controller 1
and Controller 2 were run as simple Camel-Mina services run from the command line (external to the
ESB) so they were easy to kill to demonstrate failover. In practice, additional Fuse ESB containers
would be ideal to host controller services.

Software Requirements:
JBoss Fuse 6.1.0
Maven 3.x -- http://maven.apache.org
JDK 1.6 or 1.7
https://github.com/FuseByExample/camel-example-tcpip-proxy

1/4

1/3/2015

FuseByExample/camel-example-tcpip-proxy GitHub

Installing Fuse
Download and Install JBoss Fuse
Download JBoss Fuse at http://www.redhat.com/jbossfuse/download
Unzip the archive in a directory without spaces in its path.

Project Layout
There are three modules: applications, controllers and router. Here is the layout in the file system:
JBoss Fuse - RouterDemo
client
controller
router

Start Fuse ESB


Run the command
bin/fusein the root directory of JBoss Fuse. Here is what the console looks like:

Building the projects


Launch a new terminal session, and run the command
mvncleaninstallin the root directory of top
level project. Make sure all projects build successfully.

Deploy the Router into Fuse ESB


In the JBoss Fuse terminal session run the command:
JBossFuse:karaf@root>features:installcamelmina
JBossFuse:karaf@root>features:installcamelgroovy
JBossFuse:karaf@root>osgi:installsmvn:com.fusesource.demo/proxyrouter/1.0.0SNAPSHOT

You should see output like this, with a Bundle ID generated by the deployment:
JBossFuse:karaf@root>osgi:installsmvn:com.fusesource.demo/proxyrouter/1.0.0SNAPSHOT
BundleID:225
JBossFuse:karaf@root>

https://github.com/FuseByExample/camel-example-tcpip-proxy

2/4

1/3/2015

FuseByExample/camel-example-tcpip-proxy GitHub

Launch the Controllers


Open two new terminal sessions and switch to the root of the controllers project in both. In one
session, execute this command to launch Controller 1:
controller$mvnPcontroller1

And in the other execute the command to launch Controller 2:


controller$mvnPcontroller2

Launch Client
Open a new terminal sessions and switch to the root of the applications project. In the session,
execute this command to launch the test Client application:
client$mvncamel:run

You should see the Client sending and receiving messages like below. Notice the response has a
element, that initially contains 'Controller 1'

17:44:47INFOApacheCamel2.10.0.redhat60024(CamelContext:camel1)startedin0.573seconds
17:44:47INFOSendingmessage1withdata:<data><messageNumber>1</messageNumber><timestamp>17:44:47.348</timestamp></data>
17:44:47INFOReceived1message:<data><messageNumber>1</messageNumber><timestamp>17:44:47.348</timestamp><controller>Controller1</co
17:44:48INFOSendingmessage2withdata:<data><messageNumber>2</messageNumber><timestamp>17:44:48.335</timestamp></data>
17:44:48INFOReceived2message:<data><messageNumber>2</messageNumber><timestamp>17:44:48.335</timestamp><controller>Controller1</co
17:44:49INFOSendingmessage3withdata:<data><messageNumber>3</messageNumber><timestamp>17:44:49.335</timestamp></data>
17:44:49INFOReceived3message:<data><messageNumber>3</messageNumber><timestamp>17:44:49.335</timestamp><controller>Controller1</co
17:44:50INFOSendingmessage4withdata:<data><messageNumber>4</messageNumber><timestamp>17:44:50.334</timestamp></data>
17:44:50INFOReceived4message:<data><messageNumber>4</messageNumber><timestamp>17:44:50.334</timestamp><controller>Controller1</co
17:44:51INFOSendingmessage5withdata:<data><messageNumber>5</messageNumber><timestamp>17:44:51.334</timestamp></data>
17:44:51INFOReceived5message:<data><messageNumber>5</messageNumber><timestamp>17:44:51.334</timestamp><controller>Controller1</co
17:44:52INFOSendingmessage6withdata:<data><messageNumber>6</messageNumber><timestamp>17:44:52.334</timestamp></data>
17:44:52INFOReceived6message:<data><messageNumber>6</messageNumber><timestamp>17:44:52.334</timestamp><controller>Controller1</co

Kill the Controller 1 session any way you like, and you should see uninterrupted message flow, with
Controller 2 handling the messages (note the changes to 'Controller 2' at message 12):

17:44:56INFOSendingmessage10withdata:<data><messageNumber>10</messageNumber><timestamp>17:44:56.334</timestamp></data>
17:44:56INFOReceived10message:<data><messageNumber>10</messageNumber><timestamp>17:44:56.334</timestamp><controller>Controller1</
17:44:57INFOSendingmessage11withdata:<data><messageNumber>11</messageNumber><timestamp>17:44:57.335</timestamp></data>
17:44:57INFOReceived11message:<data><messageNumber>11</messageNumber><timestamp>17:44:57.335</timestamp><controller>Controller1</
17:44:58INFOSendingmessage12withdata:<data><messageNumber>12</messageNumber><timestamp>17:44:58.334</timestamp></data>
17:44:58INFOReceived12message:<data><messageNumber>12</messageNumber><timestamp>17:44:58.334</timestamp><controller>Controller2</
17:44:59INFOSendingmessage13withdata:<data><messageNumber>13</messageNumber><timestamp>17:44:59.334</timestamp></data>
17:44:59INFOReceived13message:<data><messageNumber>13</messageNumber><timestamp>17:44:59.334</timestamp><controller>Controller2</

Restart Controller 1 and youll see it take control back from Controller 2 (this is user-defined behavior
in the configuration of the failover-load balancer)

:<data><messageNumber>40</messageNumber><timestamp>17:45:26.333</timestamp></data>
messageNumber>40</messageNumber><timestamp>17:45:26.333</timestamp><controller>Controller2</controller></data>
:<data><messageNumber>41</messageNumber><timestamp>17:45:27.334</timestamp></data>
messageNumber>41</messageNumber><timestamp>17:45:27.334</timestamp><controller>Controller2</controller></data>
:<data><messageNumber>42</messageNumber><timestamp>17:45:28.335</timestamp></data>
messageNumber>42</messageNumber><timestamp>17:45:28.335</timestamp><controller>Controller1</controller></data>
:<data><messageNumber>43</messageNumber><timestamp>17:45:29.335</timestamp></data>
messageNumber>43</messageNumber><timestamp>17:45:29.335</timestamp><controller>Controller1</controller></data>
:<data><messageNumber>44</messageNumber><timestamp>17:45:30.335</timestamp></data>
messageNumber>44</messageNumber><timestamp>17:45:30.335</timestamp><controller>Controller1</controller></data>

https://github.com/FuseByExample/camel-example-tcpip-proxy

3/4

1/3/2015

FuseByExample/camel-example-tcpip-proxy GitHub

Links to additional documentation


https://access.redhat.com/knowledge/docs/JBoss_Fuse/

2015 GitHub, Inc.

Terms

Privacy

Security

Contact

https://github.com/FuseByExample/camel-example-tcpip-proxy

Status

API

Training

Shop

Blog

About

4/4

Das könnte Ihnen auch gefallen