+ All Categories
Home > Documents > Fuse_IDE-7.1-Tutorials-en-US.pdf

Fuse_IDE-7.1-Tutorials-en-US.pdf

Date post: 23-Sep-2015
Category:
Upload: william-mauricio-patino
View: 217 times
Download: 3 times
Share this document with a friend
Popular Tags:
56
Fuse IDE Tutorials Version 7.1 December 2012 Integration Everywhere
Transcript
  • Fuse IDETutorials

    Version 7.1December 2012

    Integration Everywhere

  • TutorialsVersion 7.1

    Updated: 15 Jan 2014Copyright 2012 Red Hat, Inc. and/or its affiliates.

    Trademark Disclaimer

    These materials and all Progress software products are copyrighted and all rights are reserved by Progress Software Corporation.The information in these materials is subject to change without notice, and Progress Software Corporation assumes no responsibilityfor any errors that may appear therein. The references in these materials to specific platforms supported are subject to change.

    Fuse, FuseSource, Fuse ESB, Fuse ESB Enterprise, Fuse MQ Enterprise, Fuse Mediation Router, Fuse Message Broker, FuseServices Framework, Fuse IDE, Fuse HQ, Fuse Management Console, and Integration Everywhere are trademarks or registeredtrademarks of FuseSource Corp. or its parent corporation, Progress Software Corporation, or one of their subsidiaries or affiliatesin the United States. Apache, ServiceMix, Camel, CXF, and ActiveMQ are trademarks of Apache Software Foundation. Any othernames contained herein may be trademarks of their respective owners.

    Third Party Acknowledgements

    One or more products in the Fuse IDE release includes third party components covered by licenses that require that the followingdocumentation notices be provided:

    JLine (http://jline.sourceforge.net) jline:jline:jar:1.0

    License: BSD (LICENSE.txt) - Copyright (c) 2002-2006, Marc Prud'hommeaux

    All rights reserved.

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the followingconditions are met:

    Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimerin the documentation and/or other materials provided with the distribution.

    Neither the name of JLine nor the names of its contributors may be used to endorse or promote products derived from thissoftware without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS ORIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ANDFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OFTHE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

  • Stax2 API (http://woodstox.codehaus.org/StAX2) org.codehaus.woodstox:stax2-api:jar:3.1.1

    License: The BSD License (http://www.opensource.org/licenses/bsd-license.php)

    Copyright (c) , All rights reserved.

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the followingconditions are met:

    Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimerin the documentation and/or other materials provided with the distribution.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS ORIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ANDFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OFTHE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    jibx-run - JiBX runtime (http://www.jibx.org/main-reactor/jibx-run) org.jibx:jibx-run:bundle:1.2.3

    License: BSD (http://jibx.sourceforge.net/jibx-license.html) Copyright (c) 2003-2010, Dennis M. Sosnoski.

    All rights reserved.

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the followingconditions are met:

    Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimerin the documentation and/or other materials provided with the distribution.

    Neither the name of JiBX nor the names of its contributors may be used to endorse or promote products derived from thissoftware without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS ORIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ANDFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OFTHE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    JavaAssist (http://www.jboss.org/javassist) org.jboss.javassist:com.springsource.javassist:jar:3.9.0.GA:compile

    License: MPL (http://www.mozilla.org/MPL/MPL-1.1.html)

  • HAPI-OSGI-Base Module (http://hl7api.sourceforge.net/hapi-osgi-base/) ca.uhn.hapi:hapi-osgi-base:bundle:1.2

    License: Mozilla Public License 1.1 (http://www.mozilla.org/MPL/MPL-1.1.txt)

  • Table of Contents1. Creating a New Route ......................................................................................................... 112. Running a Route ............................................................................................................... 213. Adding a Content-Based Router ............................................................................................ 254. Tracing a Message Through a Route ....................................................................................... 315. Testing a Route with JUnit ................................................................................................... 396. Deploying a camel project to Fuse ESB Enterprise ..................................................................... 457. Deploying a camel project to a fabric profile ............................................................................ 51

    7Fuse IDE Tutorials Version 7.1

  • List of Figures1.1. New Fuse IDE Project project location page ............................................................................. 121.2. New Fuse IDE Project details page ........................................................................................ 131.3. Generated project files ....................................................................................................... 141.4. Camel XML file wizard ....................................................................................................... 151.5. New camelContext file in the route editor's source view .............................................................. 171.6. Endpoint property editor ..................................................................................................... 181.7. Completed route, diagram view ............................................................................................ 183.1. When property editor ........................................................................................................ 263.2. Completed content-based router with logs .............................................................................. 284.1. Fuse Integration perspective ................................................................................................ 324.2. Route elements in JMX Explorer ........................................................................................... 334.3. Message files in simple-route project ..................................................................................... 344.4. Fuse Integration perspective's message tracing components ......................................................... 365.1. New Camel JUnit Test wizard .............................................................................................. 405.2. Test endpoints page .......................................................................................................... 425.3. JUnit view ...................................................................................................................... 436.1. Fuse ESB Enterprise server configuration ................................................................................ 466.2. Fuse ESB console ............................................................................................................. 477.1. Creating a fabric and listing its containers ............................................................................... 527.2. Fabric Details wizard ......................................................................................................... 527.3. simple-route bundle deployed .............................................................................................. 54

    Fuse IDE Tutorials Version 7.18

  • List of Examples1.1. XML for simple route ......................................................................................................... 192.1. Contents of message1.xml .................................................................................................. 223.1. XML for content-based router .............................................................................................. 28

    9Fuse IDE Tutorials Version 7.1

  • Fuse IDE Tutorials Version 7.110

  • Chapter 1. Creating a New RouteThis tutorial walks you through the process of creating a new project, adding a route to it, and adding two endpointsto the route. It assumes that you have already set up your workspace and that Fuse IDE is running.

    Goals In this tutorial you will:

    create a routing project

    add endpoints to a route

    connect two endpoints

    configure endpoints

    Creating the Fuse IDE project To create a Fuse IDE project:

    1. On the Toolbar, select File New Fuse Project to open the NewFuse IDE Project wizard, as shown in Figure 1.1 on page 12.

    11Fuse IDE Tutorials Version 7.1

  • Figure 1.1. New Fuse IDE Project project location page

    2. Click Next> to open the New Fuse IDE Project details page, as shownin Figure 1.2 on page 13.

    Fuse IDE Tutorials Version 7.112

    Chapter 1. Creating a New Route

  • Figure 1.2. New Fuse IDE Project details page

    3. Select camel-archetype-spring.

    4. Enter tutorial in the Group Id: field.

    5. Enter simple-route in the Artifact Id: field.

    6. The Version: field defaults to 1.0.0-SNAPSHOT. To change it, enter a

    different version identifier.

    13Fuse IDE Tutorials Version 7.1

  • 7. The Package: field defaults to tutorial.simple-route, the name of

    the package that contains camel-archetype-spring. To include the

    route in a different package, enter the name of that package.

    8. Click Finish.

    This procedure creates a Fuse IDE project, simple-route, in PackageExplorer that contains everything needed to create and run routes. Asshown in Figure 1.3, the files generated for simple-route include:

    simple-route/pom.xml (Maven project file)

    simple-route/src/main/resources/META-INF/spring/camel-context.xml

    (Spring XML file containing the routing rules)

    Figure 1.3. Generated project files

    Creating the route To create the new route:

    Fuse IDE Tutorials Version 7.114

    Chapter 1. Creating a New Route

  • 1. In Package Explorer, locatesimple-route/src/main/resources/META-INF/spring/camel-Context.xml.

    2. Right-click it to open the context menu, then select Delete.

    You're going to replace the old camel-Context.xml file with your ownto create a new route.

    3. In the Confirm Delete dialog, click OK.

    4. In Package Explorer, selectsimple-route/src/main/resources/META-INF/spring.

    5. Right-click it to open the context menu.

    6. Select New Camel XML File to open the Camel XML File wizard, asshown in Figure 1.4.

    Figure 1.4. Camel XML file wizard

    15Fuse IDE Tutorials Version 7.1

  • 7. Check that /simple-route/src/main/resources/META-INF/spring

    appears in the Container: field. Otherwise enter it manually, or select it

    using the button.

    TipThe button opens a dialog that displays the foldersof all active projects, which you can browse to find and selectthe files you need.

    8. Check that camelContext.xml appears in the File Name: field.

    Otherwise enter it manually.

    9. Check that Spring appears in the Framework field, or select it from thefield's drop-down list.

    10. Click Finish.

    TipFuse IDE opens in Java perspective, with Outline view locatedin the upper, right corner of the workspace. To provide moreroom for Design view to display the graphical representation ofyour route, click-drag Outline view to the lower, left corner ofthe workspace, below Package Explorer, and release it. Yourworkspace will look similar to Figure 1.5 on page 17, but withDesign view open on the canvas.

    11. Click the Source tab at the bottom, left of the canvas to open the newcamelContext.xml file in the route editor's Source view, as shown in

    Figure 1.5 on page 17.

    Fuse IDE Tutorials Version 7.116

    Chapter 1. Creating a New Route

  • Figure 1.5. New camelContext file in the route editor's source view

    12. Click the Design tab at the bottom, left of the canvas to return to theroute editor's Design view.

    13. Drag an Endpoint element ( ) from the Pallet to the canvas.

    14. Drag a second Endpoint element from the Pallet to the canvas.

    15. Select the first endpoint you dragged onto the canvas.

    The Properties editor, located below the canvas, displays the endpoint'sproperty fields for editing, as shown in Figure 1.6 on page 18.

    17Fuse IDE Tutorials Version 7.1

  • Figure 1.6. Endpoint property editor

    16. Enter file:src/data?noop=true in the Uri field. Leave the other fields

    blank.

    17. Select the second endpoint you dragged onto the canvas.

    18. Enter file:target/messages/others in the Uri field. Leave the other

    fields blank.

    19. On the canvas, select the first endpoint (file:src/data?noop=true),

    and click-drag it's connector arrow ( ) to the second endpoint(file:target/messages/others), then release it.

    A segmented line connects the two endpoints, as shown in Figure 1.7.

    Figure 1.7. Completed route, diagram view

    TipYou can click-drag the line's bendpoint (orange dot) to changethe angle of the line's segments. Doing so creates two newbendpoints, one on either side of the original. This behaviorenables you to easily adjust your diagram to accommodateincreasingly complex routes.

    Fuse IDE Tutorials Version 7.118

    Chapter 1. Creating a New Route

  • 20. To quickly align the connected endpoints, right-click the canvas to openthe context menu, and then select Layout Diagram.

    21. Select File Save to save the route.

    22. Click the Source tab at bottom, left of the canvas.

    The Source view displays the XML for the route. The camelContextelement will look like Example 1.1.

    Example 1.1. XML for simple route

    Next steps After you have created and designed your route, you can run it by deployingit into your Apache Camel runtime, as described in "Running a Route"on page 21.

    Further reading To learn more about:

    using the editor see Users Guide

    Apache Camel endpoints see Endpoint Reference.

    19Fuse IDE Tutorials Version 7.1

  • Fuse IDE Tutorials Version 7.120

  • Chapter 2. Running a RouteThis tutorial walks you through the process of running a route.

    Goals In this tutorial you will:

    run a route as a local Apache Camel context

    send messages through a route

    examine the messages received by the endpoints

    Prerequisites To complete this tutorial you will need:

    the Apache Camel project created in "Creating a New Route" on page 11

    Running the route To run the route:

    1. Open the simple-route project you created in "Creating the Fuse IDEproject" on page 11.

    2. In Package Explorer, selectsimple-route/src/main/resources/META-INF/spring/camelContext.xml

    .

    3. Right-click it to open the context menu, then select Run As LocalCamel Context (without tests).

    The Console panel opens to display messages that reflect the progressof the project's execution. A message similar to the following

    [pache.camel.spring.Main.main()] MainSupport INFO Apache Camel 2.8.0-fuse-00-05 starting

    [pache.camel.spring.Main.main()] CamelNamespaceHandler INFO OSGi environment not detected.

    [pache.camel.spring.Main.main()] SpringCamelContext INFO Apache Camel 2.8.0-fuse-00-05 (CamelCon

    text: camel-1) is starting

    [pache.camel.spring.Main.main()] SpringCamelContext INFO JMX enabled. Using ManagedManagementStrategy.

    [pache.camel.spring.Main.main()] AnnotationTypeConverterLoader INFO Found 3 packages with 14 @Con

    verter classes to load

    [pache.camel.spring.Main.main()] DefaultTypeConverter INFO Loaded 162 core type converters (total

    162 type converters)

    [pache.camel.spring.Main.main()] DefaultTypeConverter INFO Loaded additional 0 type converters

    21Fuse IDE Tutorials Version 7.1

  • (total 162 type converters) in 0.002 seconds

    [pache.camel.spring.Main.main()] FileEndpoint INFO Endpoint is configured with noop=true

    so forcing endpoint to be idempotent as well

    [pache.camel.spring.Main.main()] FileEndpoint INFO Using default memory based idempotent

    repository with cache max size: 1000

    [pache.camel.spring.Main.main()] SpringCamelContext INFO Route: route1 started and consuming

    from: Endpoint[file://src/data?noop=true]

    [pache.camel.spring.Main.main()] SpringCamelContext INFO Total 1 routes, of which 1 is started.

    [pache.camel.spring.Main.main()] SpringCamelContext INFO Apache Camel 2.8.0-fuse-00-05 (CamelCon

    text: camel-1) started in 0.437 seconds

    indicates the route executed successfully.

    4. To shutdown the route, click the red square ( ) located at the top, rightof the Console panel.

    Verifying the route To verify that the route executed properly:

    1. In the Package Explorer, select simple-route.

    2. Right-click it to open the context menu, then select Refresh.

    3. In Package Explorer, locate the folder target/messages/others.

    4. Verify that the folder contains these two files:

    message1.xml

    message2.xml

    5. Double-click message1.xml to open it in the editor's Design view, then

    select the Source tab at the bottom, left of the canvas to see the xmlcode.

    It's contents should match that shown in Example 2.1.

    Example 2.1. Contents of message1.xml

  • The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.

    -->

    JamesStrachanLondon

    Further reading To learn more about:

    configuring runtime profiles see "Editing a Local Camel Context runtimeprofile" in Users Guide.

    deploying Apache Camel applications see the Red Hat Apache Camellibrary1.

    1 http://fusesource.com/docs/router

    23Fuse IDE Tutorials Version 7.1

  • Fuse IDE Tutorials Version 7.124

  • Chapter 3. Adding a Content-BasedRouterThis tutorial walks you through adding a content-based router with logging to a route.

    Goals In this tutorial you will:

    add a content based-router to a route

    configure the content-based router

    add a log endpoint to each output branch of the content-based router

    rewire the route to use the content-based router and log its output

    Prerequisites To complete this tutorial you will need the simple-route project you createdin "Creating a New Route" on page 11.

    Procedure To add a content-based router with logging to your route:

    1. In Package Explorer, double-clicksimple-route/src/main/resources/META-INF/spring/camelContext.xml

    to open your simple-route project.

    2. Select the connector joining the two endpoint nodesfile:src/data?noop=true and file:target/messages/others.

    3. Right-click it to open the context menu, and select Edit Remove todelete the connector.

    TipAlternatively, you can delete the connector by selecting it, thenselecting Delete from the toolbar's Edit menu.

    4. On the canvas, select the terminal endpoint node,file:target/messages/others, and click-drag it out of the way.

    25Fuse IDE Tutorials Version 7.1

  • 5. On the canvas, select the starting endpoint node,file:src/data?noop=true, and right-click it to open the context menu.

    6. Select Add Routing Choice.

    A choice node ( ) appears on the canvas connected to the startingendpoint node.

    7. On the canvas, select the choice node, then right-click it to open thecontext menu.

    8. Select Add Routing When.

    A when node ( ) appears on the canvas connected to the choice node.The Properties editor opens, displaying the when node's property fieldsfor you to edit, as shown in Figure 3.1.

    Figure 3.1. When property editor

    9. In the Expression field, enter /person/city='London' .

    This XPath expression determines which messages will transit this pathin the route.

    10. From the Language drop-down menu, select xpath.

    11. In the Id field, enter when1.

    12. On the canvas, reselect the Choice node, then right-click it to open thecontext menu.

    13. Select Add Routing Otherwise.

    Fuse IDE Tutorials Version 7.126

    Chapter 3. Adding a Content-Based Router

  • An otherwise node ( ) appears on the canvas, connected to the choicenode.

    The otherwise node will eventually route to the terminal endpoint(file:target/messages/others) any message that does not matchthe XPath expression set for the when1 node.

    14. On the canvas, select the when1 node, and then right-click it to openthe context menu.

    15. Select Add Endpoints Log

    A log node ( ) appears on the canvas, connected to the when1 node.The Properties editor opens, displaying the log node's property fields foryou to edit.

    16. In the Message field, enter uk messages, and in the Log Name field,

    enter 1.

    TipIn Fuse Integration perspective's Messages View, Fuse IDEinserts the contents of the log node's Message field in the TraceNode Id column for message instances, when tracing is enabledon the route (see Figure 4.4 on page 36). In the Console, itadds the contents to the log data whenever the route runs.

    17. On the canvas, select the otherwise node, and then right-click it to openthe context menu.

    18. Select Add Endpoints Log

    A log node ( ) appears on the canvas, connected to the otherwisenode. The Properties editor opens, displaying the log node's propertyfields for you to edit.

    19. In the Message field, enter other messages, and in the Log Name field,

    enter 2.

    20. On the canvas, select the log 1 node, and then right-click it to open thecontext menu.

    21. Select Add Endpoints Endpoint

    27Fuse IDE Tutorials Version 7.1

  • An Endpoint node ( ) appears on the canvas, connected to the log 1node. The Properties editor opens, displaying the Endpoint node'sproperty fields for you to edit.

    22. In the Uri field, enter file:target/messages/uk, and leave the other

    property fields blank.

    23. On the canvas, select the log 2 node, and then click-drag its connector

    arrow ( ) to the terminal endpoint node,file:target/messages/others, and release it.

    24. To quickly realign all of the nodes on the canvas, right-click the canvasto open the context menu, and then select Layout Diagram.

    The route on the canvas should resemble Figure 3.2.

    Figure 3.2. Completed content-based router with logs

    25. On the toolbar, select File Save to save the completed route.

    26. Click the Source tab at the bottom, left of the canvas to display the XMLfor the route.

    The camelContext element will look like that shown in Example 3.1.

    Example 3.1. XML for content-based router

    Fuse IDE Tutorials Version 7.128

    Chapter 3. Adding a Content-Based Router

  • /person/city='London'

    Next steps You can run the new route as described in "Running the route" on page 21.

    Further reading To learn more about message enrichment see:

    When in Enterprise Integration Pattern Reference

    Red Hat Apache Camel library1

    1 http://fusesource.com/docs/router

    29Fuse IDE Tutorials Version 7.1

  • Fuse IDE Tutorials Version 7.130

  • Chapter 4. Tracing a Message Througha RouteThis tutorial walks you through the process of tracing a message through a route.

    Goals In this tutorial you will:

    run a route in the Fuse Integration perspective

    enable tracing on your route

    drop messages onto your route and track them through the route's nodes

    Prerequisites To complete this tutorial you will need the simple-route project you updatedin "Adding a Content-Based Router" on page 25.

    Procedure To trace a message through your route:

    1. Select Window Open Perspective Fuse Integration to open theFuse Integration perspective as shown in Figure 4.1 on page 32).

    31Fuse IDE Tutorials Version 7.1

  • Figure 4.1. Fuse Integration perspective

    TipYou can use the Open Perspective icon ( ) in the perspectivestab to access the list of available perspectives.

    2. In Project Explorer, expand the simple-route project to expose the

    src/main/resources/META-INF/spring/camel-context.xml file.

    3. Select Run As Local Camel Context (without tests) from thecamel-context.xml file's context menu.

    4. In JMX Explorer, expand Local Processes.

    Fuse IDE Tutorials Version 7.132

    Chapter 4. Tracing a Message Through a Route

  • 5. Double click Local Camel Context [id] to expand the elements of your

    route as shown in Figure 4.2 on page 33).

    Figure 4.2. Route elements in JMX Explorer

    6. In JMX Explorer, select Start Tracing from the camel-1's context menu.

    Fuse IDE displays a graphical representation of your route in DiagramView.

    7. In Diagram View, drag the nodes to rearrange them, so you can clearlysee the route's flow paths.

    TipYou will have to rearrange the nodes in Diagram View each timeyou select a different node in JMX Explorer.

    33Fuse IDE Tutorials Version 7.1

  • 8. In Project Explorer, expand simple-route/src/data, so you can

    access the message1.xml and message2.xml files as shown in

    Figure 4.3 on page 34.

    Figure 4.3. Message files in simple-route project

    9. Drag message1.xml and drop it on

    .../camel-1/Endpoints/file/src/data?noop=true.

    As the message traverses the route, Fuse IDE traces and records itspassage at each step and displays the results in Messages View.

    10. Repeat Step 9.

    11. Drag message2.xml drop it on

    .../camel-1/Endpoints/file/src/data?noop=true.

    12. Repeat Step 11.

    13. In the bottom, right panel, switch from Console to Messages View.

    14. In JMX Explorer, click camel-1 to populate Messages View with thetraces of each message.

    Fuse IDE Tutorials Version 7.134

    Chapter 4. Tracing a Message Through a Route

  • As shown in Figure 4.4 on page 36, Fuse IDE draws the route inDiagram View, tagging paths exiting a processing step with timing andperformance metrics. Only the metric Total exchanges is displayed inthe diagram. Hovering over the displayed metrics reveals additionalmetrics about message flow:

    mean time the step took to process a message

    maximum time the step took to process a message

    minimum time the step took to process a message

    35Fuse IDE Tutorials Version 7.1

  • Figure 4.4. Fuse Integration perspective's message tracing components

    15. In Messages View, click a message instance.

    The associated step in the route is highlighted in Diagram View. Youcan step through the message instances to see how a particular messagetraversed the route and whether it was processed as expected at eachstep in the route.

    Fuse IDE Tutorials Version 7.136

    Chapter 4. Tracing a Message Through a Route

  • Fuse IDE displays the details about a message instance in the top halfof the Properties panel and the contents of the message instance,including any headers, in the bottom half of the Properties panel. So, ifyour application sets headers at any step within a route, you can checkwhether they are set as expected.

    TipYou can control columnar layout in all Fuse IDE tables. Drag acolumn's border rule to expand or contract its width. To hide acolumn, totally contract its borders. You can rearrange tablelayout by reordering its columns. To do so, drag a column headerto where you want it to appear in the table.

    16. When done, switch back to the Console and click the stop button ( )in the upper, right side of its pane.

    Next steps You can run the route with a JUnit test case, as described in "Testing a Routewith JUnit" on page 39.

    Further reading To learn more about message enrichment see:

    Choice in Enterprise Integration Pattern Reference

    When in Enterprise Integration Pattern Reference

    Log in Enterprise Integration Pattern Reference

    Red Hat Apache Camel library1

    1 http://fusesource.com/docs/router

    37Fuse IDE Tutorials Version 7.1

  • Fuse IDE Tutorials Version 7.138

  • Chapter 5. Testing a Route with JUnitThis tutorial walks you through the process of creating a test case for your route and using it test the route.

    Goals In this tutorial you will:

    create a Apache Camel test case

    run the route with the test case

    observe the output

    Prerequisites To complete this tutorial you will need:

    the simple-route project you created in "Adding a Content-Based Router"on page 25

    Creating the test case To create a new test case:

    1. In Package Explorer, select src/test/java.

    2. Right-click it to open the context menu, and then select New CamelTest Case to open the New Camel JUnit Test Case wizard, as shown inFigure 5.1 on page 40.

    39Fuse IDE Tutorials Version 7.1

  • Figure 5.1. New Camel JUnit Test wizard

    3. Make sure the Source folder field containssimple-route/src/test/java.

    TipIf needed, you can click to find the proper folder.

    4. The Package field defaults to tutorial.simple-route. To include the

    test case in a different package, enter the name of the package.

    Fuse IDE Tutorials Version 7.140

    Chapter 5. Testing a Route with JUnit

  • 5. In the Camel XML file under test field, entersrc/main/resources/META-INF/spring/camelContext.xml, or use

    to open a file explorer, configured to screen for XML files,to locate the file.

    TipThe Name field defaults to CamelContextXmlTest for the nameof the test file.

    6. Click Next> to open the Test Endpoints page, shown inFigure 5.2 on page 42.

    41Fuse IDE Tutorials Version 7.1

  • Figure 5.2. Test endpoints page

    7. By default, all endpoints are selected and will be included in the testcase. You can select or deselect all endpoints by clicking the Select Allor Deselect All button, or you can select and deselect individual endpointsby clicking the check box next to each.

    8. Click Finish.

    TipIf prompted, add JUnit to the build path.

    Fuse IDE Tutorials Version 7.142

    Chapter 5. Testing a Route with JUnit

  • The artifacts for the test are added to your project, and the class implementingthe test case is opened in the Java editor.

    Running the test To run the test:

    1. Select the project root, simple-route, in the Package Explorer.

    2. Open the context menu.

    3. Select Run As JUnit Test.

    The JUnit view, shown in Figure 5.3 on page 43, opens in the Eclipsesidebar.

    Figure 5.3. JUnit view

    4. Examine the output and take action to resolve any test failures.

    Further reading To learn more about:

    JUnit see http://www.junit.org/

    43Fuse IDE Tutorials Version 7.1

  • Fuse IDE Tutorials Version 7.144

  • Chapter 6. Deploying a camel projectto Fuse ESB EnterpriseThis tutorial walks you through the process of deploying a camel project into Fuse ESB Enterprise. It assumesthat you have an instance of Fuse ESB Enterprise installed on the same machine on which you are running FuseIDE.

    Goals In this tutorial you will:

    start up Fuse ESB Enterprise 7.x Server

    deploy your project into Fuse ESB Enterprise 7.x Server

    check whether your project was successfully built and deployed

    uninstall your deployed bundle

    Prerequisites To complete this tutorial you will need

    access to a Fuse ESB Enterprise instance

    the simple-route project you updated in "Adding a Content-Based Router"on page 25

    Starting up Fuse ESB Enterprise7.x Server

    To start up Fuse ESB Enterprise 7.x server:

    1. In Fuse Integration perspective, click the Servers tab in the lower, rightpane to open the Servers view.

    2. Click new server wizard to open the Define a New Server page.

    3. If necessary, expand the Red Hat node to expose the available serveroptions.

    4. Click Fuse ESB Enterprise 7.x Server.

    45Fuse IDE Tutorials Version 7.1

  • 5. Accept the defaults for Server's host name (localhost) and Server

    name (Fuse ESB Enterprise 7.x server at localhost), and then

    click Next to open the Fuse ESB Enterprise Runtime page.

    6. In Installation directory, enter the path where the Fuse ESB Enterprise7.x installation is located, or click the Browse to search for it, and thenclick Next to open the Fuse ESB Enterprise page.

    Figure 6.1. Fuse ESB Enterprise server configuration

    7. Accept the defaults for Host Name (0.0.0.0) and Port Number (8101).

    8. Enter smx in both User Name and Password.

    NoteIf the default (smx) has been changed for either property, usethe new setting.

    9. Click Next, and then click Finish.

    fuse-esb-7.0.0.fuse-xxx [stopped] appears in Servers view.

    10. In Servers view, right-click fuse-esb-7.0.0.fuse-xxx to open the

    context menu, and then click Start.

    Fuse IDE Tutorials Version 7.146

    Chapter 6. Deploying a camel project to Fuse ESBEnterprise

  • Wait a few seconds for Fuse ESB Enterprise 7.x server to start up. Whenit does, Fuse ESB [xxx] appears in JMX Explorer under the localprocesses node.

    ImportantIf the warning that the remote host identification has changedappears, click yes to delete the old key and insert the new keyonly if the Fuse ESB Enterprise 7.x server runtime is installedon the same machine where Fuse IDE is running! Otherwiseclick no and contact your system administrator.

    When Fuse ESB Enterprise 7.x server starts up, the Fuse ESB consolestarts up in Shell view, as shown in Figure 6.2:

    Figure 6.2. Fuse ESB console

    11. In JMX Explorer, right-click Fuse ESB [xxx] to open the context menu,

    and then click Connect.

    Now you're ready to deploy your project.

    Deploying a project to Fuse ESBEnterprise

    To deploy a camel project to Fuse ESB Enterprise:

    1. From Project Explorer, drag the simple-route root project over to JMX

    Explorer and drop it on Fuse ESB [xxx].

    47Fuse IDE Tutorials Version 7.1

  • TipThe Deploy to... tool provides an alternative to the drag anddrop method of deployment. For details, see "Deploying aProject to a JMX Connected Container" in Users Guide.

    Console view chronicles the process as Fuse IDE builds thesimple-route project, runs the tests, and then installs the project asa bundle inside Fuse ESB [xxx].

    2. In JMX Explorer, right-click Fuse ESB [xxx] to open the context menu,

    and then click Refresh.

    TipYou may have to repeat the Refresh operation a few times beforeyour project appears in JMX Explorer under Fuse ESB [xxx} Camel as -camel-#. (Camel generates andappends an ID number to the end of the node name to ensurethat every camel context is uniquely identified.)

    In the mean time, you can verify whether your project's bundlewas installed by clicking the Bundles node under Fuse ESB[xxx] to display, in Properties view, all installed bundles. Starttyping tutorial in Properties view's Search tool to quicklydetermine whether your project's tutorial.simple-routebundle is included in the list.

    Once your project appears in JMX Explorer, you can start tracing on it,as described in "Tracing a Message Through a Route" on page 31.

    Uninstalling your project's bundle To uninstall your project from Fuse ESB 7.x server:

    1. Switch to the Fuse ESB console in Shell view.

    2. At the Fuse ESB console command line, type uninstall

    Further reading To learn more about deploying applications to external containers, see:

    Fuse IDE Tutorials Version 7.148

    Chapter 6. Deploying a camel project to Fuse ESBEnterprise

  • "Deploying Projects to a Container" in Users Guide

    49Fuse IDE Tutorials Version 7.1

  • Fuse IDE Tutorials Version 7.150

  • Chapter 7. Deploying a camel projectto a fabric profileThis tutorial walks you through the process of deploying a camel project into a fabric profile in Fuse Integrationperspective. It assumes that you have an instance of Fuse ESB Enterprise installed on the same machine onwhich you are running Fuse IDE.

    Goals In this tutorial you will:

    create a fabric in Fuse ESB Enterprise 7.x Server

    connect to the fabric

    create a new fabric profile

    deploy your project to the new fabric profile

    Prerequisites To complete this tutorial you will need:

    access to Fuse ESB Enterprise

    Fuse ESB Enterprise 7.x Server already added to Servers view (for details,see "Deploying a camel project to Fuse ESB Enterprise" on page 45)

    the simple-route project you updated in "Adding a Content-Based Router"on page 25

    Creating a fabric in Fuse ESB To create a fabric in Fuse ESB:

    1. If necessary, start up fuse-esb-7.0.0.fuse-xxx in Servers view.

    2. Wait a few seconds for the Fuse ESB Enterprise 7.x server to start up,and then switch to the Fuse ESB console in Shell view.

    3. At the Fuse ESB console command line, enter fabric:create and press

    Enter to create a Fuse Fabric.

    51Fuse IDE Tutorials Version 7.1

  • 4. Enter fabric:container-list and press Enter to list the new fabric's

    default container (root*) and its status.

    Figure 7.1. Creating a fabric and listing its containers

    5. In Fabric Explorer, right-click Fabrics to open the context menu, andthen click Add Fabric details to open the Fabric Details wizard.

    Figure 7.2. Fabric Details wizard

    6. Accept the defaults for Name (Local Fabric) and URLs

    (localhost:2181), User name (admin), and Password (admin).

    NoteIf the defaults for user name and password have been changed,use the new settings.

    7. Press OK.

    Fuse IDE Tutorials Version 7.152

    Chapter 7. Deploying a camel project to a fabric profile

  • The fabric's name appears in Fabric Explorer as a node under Fabrics.

    Connecting to the fabric In Fabric Explorer, right-click Local Fabric to open the context menu, andthen click Connect to connect to the new fabric.

    Now you're ready to create a new fabric profile into which you'll deploy yourcamel project.

    Creating a new fabric profile To create a new fabric profile:

    1. In Fabric Explorer, expand Local Fabric Versions 1.0 to reveal thefabric's top-level profiles.

    2. Further expand the profiles tree to find the camel profile nested under

    the karaf profile.

    3. Right-click the camel profile to open the context menu, and then click

    Create a new Profile.

    4. In Profile name, enter myCamelRoute, and then click OK.

    The new profile myCamelRoute appears under its parent profile camel,in Fabric Explorer.

    5. Click the myCamelRoute profile to populate the Profiles page with its

    information.

    6. In the Parents pane, you can see that the camel profile is the new

    profile's immediate parent. Leave camel selected.

    Now you're ready to deploy your camel project to the profilemyCamelRoute.

    Deploying your camel project tothe new fabric profile

    To deploy a camel project to a fabric profile:

    1. From Project Explorer, drag the simple-route root project over to

    Fabric Explorer and drop it on Local Fabric Versions 1.0 default karaf camel myCamelRoute.

    53Fuse IDE Tutorials Version 7.1

  • TipThe Deploy to... tool provides an alternative to the drag anddrop method of deployment. For details, see "Deploying aProject to a Fabric Container" in Users Guide.

    Console view chronicles the process as Fuse IDE builds thesimple-route project, runs the tests, installs the project as a bundlein the myCamelRoute profile, and then uploads the profile to the fabric'sinternal Maven repository.

    2. In Fabric Explorer click the myCamelRoute profile to populate Properties

    view with its properties and profile information.

    3. On the Profiles page, check that the simple-route bundle appears in theFabs field, as shown in Figure 7.3 on page 54.

    Figure 7.3. simple-route bundle deployed

    Now you can deploy your camel project to the fabric by creating one ormore containers on the fabric and assigning the myCamelRoute profileto them. Once the containers are started, you can start tracing on thedeployed projects, as described in "Tracing a Message Through a Route"

    Fuse IDE Tutorials Version 7.154

    Chapter 7. Deploying a camel project to a fabric profile

  • on page 31, but selecting the route in Fabric Explorer instead of JMXExplorer.

    Further reading To learn more about deploying applications to a fabric, see:

    "Deploying Projects to a Container" in Users Guide

    ????

    "Working with Fabric Profiles" in Users Guide

    "Working with Versions" in Users Guide

    55Fuse IDE Tutorials Version 7.1

  • Fuse IDE Tutorials Version 7.156

    TutorialsTable of ContentsChapter 1. Creating a New RouteChapter 2. Running a RouteChapter 3. Adding a Content-Based RouterChapter 4. Tracing a Message Through a RouteChapter 5. Testing a Route with JUnitChapter 6. Deploying a camel project to Fuse ESB EnterpriseChapter 7. Deploying a camel project to a fabric profile


Recommended