GithubHelp home page GithubHelp logo

fusebyexample / smx-application-plugins Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jkorab/smx-application-plugins

4.0 11.0 2.0 36 KB

A demo of an integration application that supports hot-deployable plugins.

License: Apache License 2.0

Java 100.00%

smx-application-plugins's Introduction

NOTE: This project is not supported on JBoss Fuse version 6.3 or later

This projects contains a sample integration application that demostrates 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 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.

Project layout

The Maven projects contained within are as follows:

  • flights-features - Contains an XML features file used to install the rest of the bundles.
  • flights-booking - Contains a bundle that exposes a core booking process through a REST endpoint.
  • flights-booking-spi - Defines an interface through which plugins can register their availability in the OSGi service registry.
  • flights-plugin-german-airline - A plugin into the booking process for a ficticious German airline that accepts bookings for tickets starting with "DE".
  • flights-plugin-irish-airline - A plugin into the booking process for a ficticious Irish airline that accepts bookings for tickets starting with "IE".

There is also an additional parent project camel-bundle that simplifies the Maven project configuration.

Prerequisites

Set up JBoss Fuse by downloading the latest 6.1.0 version from Red Hat.

Ensure that Maven is set up on your system.

Installation

Download this project and run

smx-bootstraps> mvn clean install

Start JBoss Fuse

$JBOSS_FUSE_HOME> bin/fuse

      _ ____                  ______
     | |  _ \                |  ____|
     | | |_) | ___  ___ ___  | |__ _   _ ___  ___
 _   | |  _ < / _ \/ __/ __| |  __| | | / __|/ _ \
| |__| | |_) | (_) \__ \__ \ | |  | |_| \__ \  __/
 \____/|____/ \___/|___/___/ |_|   \__,_|___/\___|

  JBoss Fuse (6.1.0.redhat-312)
  http://www.redhat.com/products/jbossenterprisemiddleware/fuse/

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.

Install the features file from your local Maven repo into the known collection of features:

JBossFuse:karaf@root> features:addurl mvn:com.fusesource.examples/flights-features/1.0-SNAPSHOT/xml/features

You can now check that the features defined in that file are available for installation:

JBossFuse:karaf@root> features:list | grep flights
[uninstalled] [1.0                 ] flights-booking                      smx-application-plugins           
[uninstalled] [1.0                 ] flights-irish-airline                smx-application-plugins           
[uninstalled] [1.0                 ] flights-german-airline               smx-application-plugins

NP: It's often a good idea to prefix all of your features and bundles with a known string, such as flights in this case, so you can easily find them via the grep command in the various listings.

Install the core booking system's OSGi bundles by installing the flights-booking feature

JBossFuse:karaf@root> features:install flights-booking
JBossFuse:karaf@root> list | grep flights
[ 254] [Active     ] [            ] [Started] [   60] flights-booking (1.0.0.SNAPSHOT)
[ 255] [Active     ] [            ] [       ] [   60] flights-booking-spi (1.0.0.SNAPSHOT)

Check that bookings for an Irish Airlines are unsupported by hitting the following from your web browser:

http://localhost:9191/booking?flightNumber=IE943

This should return:

Unable to book flight for IE943 - unsupported airline

Now install the feature which enables integration with Irish Airlines:

JBossFuse:karaf@root> features:install flights-irish-airline 
JBossFuse:karaf@root> list | grep flights
[ 254] [Active     ] [            ] [Started] [   60] flights-booking (1.0.0.SNAPSHOT)
[ 255] [Active     ] [            ] [       ] [   60] flights-booking-spi (1.0.0.SNAPSHOT)
[ 256] [Active     ] [            ] [Started] [   60] flights-plugin-irish-airline (1.0.0.SNAPSHOT)

Refresh the URL in your browser, you should now see that as the integration service has been made available, the core process will now take payment for the flight and invoke the airline's back-end.

Taking payment for IE943;Irish Airline processed booking 

Repeat again for a flight number starting with "DE" and installing the flights-german-airline feature.

Voila! Hot deployable integrations as plugins.

Next steps

Take a look at a plugin's SpringDM config in src/main/resources/META-INF/spring. Note how the plugin exposes its Camel endpoint details to the OSGi service registry.

Check out the Spring config in the flights-booking project. Note how the interfaces registered by the plugins are accessed as a Set of BookingProcessor interfaces, and read by the BookingProcessorRegistry to provide an object that is able to be used in Camel expressions to influence the routing of the core booking process.

smx-application-plugins's People

Contributors

gertv avatar jkorab avatar kevinearls avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

sudino fuse-forks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.