Search
JBoss Prodcut FAQ

Fuse By Example

JBoss Fuse comes with some out-of-the-box examples that show you how to build simple applications like a content-based routers or a JAX-RS web service. These examples are all very simple and focused on a single technology.

In real life however, things often get quite a bit more complicated than what these examples are showing you.

FuseByExample is a GitHub organisation with a set of more elaborate examples created by Fuse consultants based on their experience with customers. These examples are more realistic to real life situations, allowing you to learn Fuse beyond the out-of-the box examples.

Rider auto OSGI

This example is based on a fictional motorcycle parts business used throughout the Camel in Action book. Orders from customers come in via a webservice or a file based endpoint and are sent to a 'incoming orders' JMS queue. A separate bundle takes the incoming orders and normalizes them from the possible order formats (XML, CSV or CSL) to a POJO format. Processed orders end up in the 'orders' JMS queue.

EIPs

Endpoint, Bean, Choice, When, Unmarshal, Convertbody, SetBody, InOnly, Transform

Technologies

Camel, ActiveMQ, CXF, JAXB, Blueprint

Sourcecode

rider_auto_osgi

Camel dynamic routing

This example shows how to use Apache Camel, and its OSGi integration to dynamically route messages to new or updated OSGi bundles. This allows you to route to newly deployed services at runtime without impacting running services.

This example combines use of the Camel Recipient List, which allows you to at runtime specify the Camel Endpoint to route to, and use of the Camel VM Component, which provides a SEDA queue that can be accessed from different OSGi bundles running in the same Java virtual machine.

Note: Extra steps, like use of Camel VM Component, need to be taken when accessing Camel Routes in different Camel Contexts, and in different OSGi bundles, as you are dealing with classes in different ClassLoaders...

EIPs

Endpoint, Log, ReciepientList, SetBody, InOnly, Transform

Technologies

Camel, Blueprint, Spring, Jetty, ActiveMQ

Sourcecode

camel-dynamic-routing

SMX Bootstraps

This example contains a set of OSGi bundles that bootstrap the use of JBoss Fuse. It is intended as a starting point for the creation of additional bundles, and as a guide to using Fuse features. The Ping Pong bootstrap is used to show inter-bundle request-response communication using ActiveMQ.

In this example a Pinger defines a Camel route which periodically triggers a message to be sent and prints out the response. A Ponger listens for ping messages on a known queue, and responds by invoking an OSGi Blueprint service defined in an implementation bundle to generate the response.

EIPs

Endpoint, Log, SetBody

Technologies

Camel, Blueprint, Jetty

Sourcecode

smx-bootstraps

Horo app

This example presents a sample app for aggregating and re-presenting horoscopes. It is designed to highlight a number of areas for discussion that are usually overlooked. These include:

  • various levels of testing, and their general appropriateness ranging from simple unit tests to integration tests
    • how to get integration tests playing nicely within a shared build environment - loads of developers, a CI server
    • a couple of different ways of testing a Camel route
      • using the standard `CamelSpringTestSupport` approach with `mock:` and `direct:` endpoints
      • exercising an actual component against an embedded web server (assigned to a unique port)
    • writing routes in such a way that they can be easily tested
  • setting up MyBatis for data access across OSGi bundles that actively demonstrates the mybatis and mybatis-spring documentation, with
    • Spring transaction management for camel-mybatis
    • configuration externalised using the OSGi Config Admin mechanisms (property files in the `$FUSE_HOME/etc` directory)
    • testing the correctness of data access against an embedded H2 database (contentious and potentially not applicable to all your access needs)
  • reuse of expensive resources such as `DataSource`s between disparate bundles through the use of service references
  • configuration of database drivers and connection pools (c3p0) in an OSGi environment

EIPs

None

Technologies

Camel, Spring, MyBatis, H2

Sourcecode

horo-app

Camel persistence part 1

This example illustrates database persistence with Camel from simple to more elaborate. This covers persistence using JDBC drivers and JPA by using the Camel SQL component. Features like named queries and rollback are explained in the source. The example accepts text and csv-style datafiles and stores the records in a H2 or a HSQL database.

EIPs

Endpoint, SetBody, Split, Log, ConvertBody, Bean

Technologies

Camel, Spring, H2, HSQL, JDBC, Camel-Bindy, JPA

Sourcecode

camel-persistence-part1

Camel persistence part 2

This example covers transaction management with JBoss Fuse, Camel and persistent EIPs. It contains the following modules:

  • The aggregator module combines multiple messages and persists the data in a H2 Database using the JDBCAggregateRepository.
  • The idempotent module processes CSV-style input files and uses the JPAIdempotentRepository to persist which messages have already been processed.
  • The DAO module provides a layer to persist incident records in a H2 DB using OpenJPA
  • The DAO-JTA module uses JTA to to persist incident records in a H2 DB
  • The route-one-tx-manager route uses one global transaction manager  (Aries Tx Manager)
  • The route-two-tx-manager route uses two global transaction managers  (JMS and JDBC)

EIPs

Endpoint, Bean, Aggregate, Log, IdempotentConsumer, Unmarshal, Split, Transacted, Transform, Filter, Multicast, Pipeline, ThrowException, Choice, When, Otherwise, Try, Catch

Technologies

Camel, Spring, ActiveMQ, H2, DBCP, OpenJPA, Bindy, JDBC

Sourcecode

camel-persistence-part2

SMX WS examples

This example contains a set of OSGi bundles that demonstrate web services in JBoss Fuse using CXF and Camel. The following patterns are shown:

  • Generating Java object from a WSDL using the 'cxf-codegen-plugin' utilizing the ' wsdl2java' command
  • A concrete CXF web service implementation
  • A Camel route that dynamically acts as a web service implementation
  • A Camel route that invokes a SOAP web service
  • A Camel route that acts as a web service proxy, taking requests and passing them to another web service

EIPs

Endpoint, SetHeader, Log, Transform, LoadBalance, ConvertBody

Technologies

Camel, CXF, SOAP, JAXB, Jetty

Sourcecode

smx-ws-examples

SMX application plugins

This example contains a sample integration application that demonstrates how to extend the integration capabilities of a core process at runtime via hot-deployable application level plugins.

This sample is based around a fictional flight booking application. The core process takes flight details which were previously gathered, and if there exists a plugin for the requested airline at that moment, it accept payment for the ticket and calls out to the airline's back-end to place the booking.

Airline plugins are OSGi bundles that use Camel for the integration to their respective systems.

EIPs

Endpoint, Transform, Choice, When, Otherwise, Recipientlist

Technologies

Camel, Jetty

Sourcecode

smx-application-plugins

Servicemix 4 example payment service

This project is an example of using OSGi, Camel, and JBoss Fuse together. A number of things are shown within this project:

  • The use of the ActiveMQ and activemq-camel component for inter OSGi bundle communication
  • multiple front-end proxies (WS and batch file)
  • bridging one way (fire and forget) messaging with request-response

and much more...

The scenario is a payment transfer service where transfer requests can be made either through a WS (SOAP/HTTP) interface or through batch files. This solution is a bit over-engineered, but the goal of this effort is to provide examples of best practices in creating applications using these technologies.

EIPs

Endpoint, Unmarshal, Marshal, Bean, Split, InOut, Transform

Technologies

Camel, JAXB, CXF, Spring, ActiveMX,

Sourcecode

servicemix4-example-payment-service

Hello Camel

This example demonstrates a minimal Camel project that creates an OSGi bundle, has a unit test and a test client that uses Camel. The Camel route is simple: an HTTP request-response service that prefixes 'Hello ' to the String body sent to it. The goal of this project is to provide a good starter project for creating your own more complicated and useful Camel Routes that can be deployed.

EIPs

Endpoint, Transform

Technologies

Camel, Spring, Jetty

Sourcecode

HelloCamel

File batch splitter

This example demonstrates how to consume files from the file system and split the content of the file into multiple messages using Apache Camel. The sample implements the Splitter EIP (Enterprise Integration Pattern), which splits an incoming message into a series of outgoing messages. Each of theoutgoing messages contains a piece of the original message. A sample incoming message file 'order1.xml' is located in src/data/inbox. When the route is run, the split result files will be located in target/data/outbox.

EIPs

Endpoint, Split, SetHeader

Technologies

Camel, Spring

Sourcecode

FileBatchSplitter

ESB transactions

This example will show you how to leverage the JTA transaction manager provided by JBoss Fuse when working with JMS or JTA Camel endpoints.  We will setup a route that reads messages from a queue and inserts information into a database using JTA and XA transactions and deploy that onto JBoss Fuse 6.0.

In studying this example you will learn:

  • how to set up an XA-aware DataSource
  • how to configure a JTA persistence unit
  • how to leverage JBoss Fuse's JTA and JPA support in your routes
  • how to configure a JMS component to support XA
  • how to define a transactional route
  • how to configure a ResourceManager that can recover XA transactions after a crash 

EIPs

None

Technologies

Camel, ActiveMQ, Hibernate, JPA

Sourcecode

esb-transactions

Camel Example TCP/IP proxy

This example describes a simple prototype that demonstrates the use of Fuse to manage TCP/IP controller failover.
A 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 so they were easy to kill to demonstrate failover. In practice, additional containers would be ideal to host controller services.

EIPs

Endpoint, SetBody, Log, LoadBalance

Technologies

Camel, Spring, Mina

Sourcecode

camel-example-tcpip-proxy

Fabric endpoint testing

This example presents a sample app for the usage of fabric endpoints. It contains a simple client which sends messages to the consumer and logs the conversation. The consumer module simply responds to the message of the client. The Client adresses the service of the consumer by using a fabric endpoint.

EIPs

Endpoint, SetBody, Log

Technologies

Camel, Blueprint, Fabric

Sourcecode

fabric-endpoint-example

Managing a Deployment using Fuse Fabric

This guide explains how to deploy an example by using Fuse Fabric trough the web based Management Console. It briefly explains the purpose, structure and components (like Profiles and containers). A tutorial takes you through the steps of a basic project deployment.

deploy-using-fabric