Code Monkey home page Code Monkey logo

osgi-chat's Introduction

Lean Microservices

The lean microservices talk shows the limitations of the popular spring boot model to decvelop microservices. It then shows OSGi with some extensions for packaging and remote communication as an alternative development model that is simpler for the individual module developers while providing a lot more flexibility at deployment time.

This example shows how to design a modular application from microservices. The modules communicate only through OSGi services based on a shared interface (API) bundles.

For packaging an OSGi index is created on the fly from maven dependencies and bndtools bndrun descriptors are used to describe the application. This results in a self contained jar for the packaging. Optionally this can be packaged into a docker image.

The simplest packaging (all) is to package all bundles of the app together. They then use plain OSGi services to talk locally.

Alternatively the application can be split up into individual deployments per microservice comparable to spring boot apps. In this case we use the Aries Remote Service Admin to support transparent remote communication between the microservices.

Aries Remote Service Admin can also be used to export a plain OSGi service with rest annotations as a fully featured REST service that can be used to communicate with non OSGi modules or with external systems.

OSGi chat example for JBCNCONF

The example implements a chat notification system with several inputs and outputs. The inputs will always send to all currently available outputs.

Using Remote Service Admin the inputs and outputs can reside on different processes and machines.

  • chat api : Simple interface to send a char message consisting of time, sender, message
  • irc connector: Logs into a freenet irc server into channel #jbcnconf and forwards all messages
  • shell command send : Forwards the string as a message
  • LCD display: Listens to chat messages and displays them on a tinkerforge 20x4 LCD screen
  • Motion detector: Tinkerforge motion detector that sends notifications about motions

Prerequisites

Install

Source

Checkout the source git clone [email protected]:cschneider/osgi-chat.git Start eclipse and import the directory osgi-chat and all sub dirs as existing maven projects.

Build

  • mvn clean install
  • cd packaging/index
  • mvn clean install
  • cd ../..
  • mvn clean install
  • Package consumer and service as docker images using the sh build.sh in the respective directories

Run

Simple deployment chat-all

cd packaging/chat-all
java -jar osgi-chat.jar

osgi-chat's People

Contributors

cschneider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

osgi-chat's Issues

Build Problem

Can you tell me what could be wrong? I am trying to play around with your code so i can understand how karaf and osgi can allow me to build lean microservice

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] net.lr.demo.chat.parent ............................ SUCCESS [ 0.479 s]
[INFO] net.lr.demo.chat.api ............................... SUCCESS [ 1.844 s]
[INFO] net.lr.demo.chat.lcd ............................... SUCCESS [ 0.666 s]
[INFO] net.lr.demo.chat.irc ............................... SUCCESS [ 0.652 s]
[INFO] net.lr.demo.chat.command ........................... SUCCESS [ 0.341 s]
[INFO] net.lr.demo.chat.index ............................. SUCCESS [ 1.521 s]
[INFO] net.lr.demo.chat.packaging ......................... SUCCESS [ 0.038 s]
[INFO] net.lr.demo.chat.packaging.all ..................... FAILURE [ 1.173 s]
[INFO] net.lr.demo.chat.packaging.display ................. SKIPPED
[INFO] net.lr.demo.chat.packaging.irc ..................... SKIPPED
[INFO] net.lr.demo.chat.packaging.service ................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.890 s
[INFO] Finished at: 2017-02-26T00:54:31-05:00
[INFO] Final Memory: 25M/249M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal biz.aQute.bnd:bnd-export-maven-plugin:3.3.0:export (default) on project net.lr.demo.chat.packaging.all: Default handler for Launcher-Plugin not found in biz.aQute.launcher -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal biz.aQute.bnd:bnd-export-maven-plugin:3.3.0:export (default) on project net.lr.demo.chat.packaging.all: Default handler for Launcher-Plugin not found in biz.aQute.launcher
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Default handler for Launcher-Plugin not found in biz.aQute.launcher
at aQute.bnd.maven.export.plugin.ExportMojo.execute(ExportMojo.java:52)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.IllegalArgumentException: Default handler for Launcher-Plugin not found in biz.aQute.launcher
at aQute.bnd.build.Project.getHandler(Project.java:2531)
at aQute.bnd.build.Project.getProjectLauncher(Project.java:2480)
at aQute.bnd.maven.export.plugin.ExportMojo.export(ExportMojo.java:57)
at aQute.bnd.maven.export.plugin.ExportMojo.execute(ExportMojo.java:48)
... 22 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn -rf :net.lr.demo.chat.packaging.all

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.