ServiceMix (Post JBI) :- Is it simply Camel running in OSGI? - osgi

I am new to ESB's and was reading an older book on Mule and ServiceMix.
After a bit of research, and looking at FuseSource docs which state that JBI is deprecated in favour of OSGi services, am I correct in assuming that for integration purposes :-
ServiceMix ESB is (nowadays) mainly Camel running in an OSGi container
Services can be deployed as OSGi bundles, and Camel can somehow use these services where it would otherwise uses POJOs to do custom processing
Thanks

My two cents: ServiceMix is a "ready-made" integration container for JAVA. It packs together a number of features on top of an OSGI runtime (Apache Karaf), of whom highlights:
Apache Camel – EIP framework
Apache ActiveMQ – messaging
So:
ServiceMix ESB is (nowadays) mainly an OSGI container including Camel (as well as ActiveMQ, CXF, ...)
Everything is deployed as OSGI bundles.

I like el.atomo s answer but I'll add for question 2:
Services can be deployed as OSGi bundles, and Camel can somehow use these services where it would otherwise uses POJOs to do custom processing
Camel itself is just POJOs. Based on the servicemix camel guide, each OSGI bundle is going to have it's own CamelContext. NMR (or TCP or HTTP or JMS or whatever camel component you use) is used to communicate between the specific OSGI bundles and camel routes which sit in different OSGI bundles (and therefore different CamelContexts)
The biggest difference between vanilla OSGi with camel setup inside it and Servicemix is probably the inclusion ActiveMQ, NMR, and BPMN2.
References:
http://servicemix.apache.org/docs/4.5.x/
http://servicemix.apache.org/docs/4.5.x/nmr/nmr-camel.html
http://servicemix.apache.org/docs/4.5.x/camel/camel-guide.pdf

Related

OSGi enroute and Apache CXF

I have successfully deployed SOAP services via Apache CXF within Apache Karaf, but would now like to do the same with OSGi enroute. I suspect my sticking point is the jaxws:endpoint definition, still pursuing resolution.
With that said, does anyone know of a working example of Apache CXF within OSGi enroute that I could reference?

Using Embedded Felix in Application Container or Application Container Bundle in Karaf and is OSGi a complete IoC container?

Imagine you want to have a highly modular web application in Java. Components are already using Spring framework also. Some components cover only pure Logic and some others also come with some presentation GUIs in HTML. The application is not Portlet compatible but we need to have dynamic menu which promotes the list of installed modules and links to the pages or REST APIs. Since it’s Java, using OSGI is recommended but I got too much confused with the recent features in OSGI (introduced past few years) and I have few questions:
Now OSGI is not only Module Management System but also IoC Container! It almost contains equivalent annotations for many of Spring IoC features. So How we can use Spring enabled modules inside OSGI? Can we eliminate Spring for our new designs and completely rely on OSGI? Or for dependency Injection within the modules we can use Spring and for Dependency injection over the Modules we can use OSGI?
For real-life large scale applications we have two options: Using Embedded Felix within application Container (e.g. Tomcat) or Using OSGI Bundle of Application Container (Jetty or Tomcat) within KARAF. Which approach is better? Which one is more scalable?
Researching OSGi can get confusing because there are 15 years of articles and examples out there - a lot of which are valid but may be out of date.
You could consider removing Spring if it was just used as an IoC container. OSGi DS provides #Component and #Reference annotations (like spring Autowire) if DS is enabled in your OSGi container. The new OSGi enroute project has some modern examples of performing IoC and providing REST services.
Replacing more of the features might be more work. Running the latest Spring in OSGi may not work due to the classloader differences in OSGi and the spring projects move away from OSGi.
OSGi is no IoC container at all. There are some technologies for injection support that run on OSGi though. The most important are declarative services and blueprint. Spring is not really supported. There is some Spring DM support but this code is not maintained for ages.
So you should use one of the two supported IoC containers above. For aries blueprint I have written support for CDI annotations using the maven-blueprint-plugin. This may be your best bet to convert the application. I recommend to first convert your spring application to use only CDI annotations and only then start the OSGi migration. Such a migration is not easy. Make sure you get some good coaching and consulting.
Embedded Felix on a servlet container is good if most of you application is non OSGi and you just want to use bundles for a very small part. Karaf is better if you want to write your whole application for OSGi.

Apache Felix + Spring

I have successfully created an osgi application with apache felix. Now I want to integrate spring 4 with it. How do I do it ? Can anyone provide me a complete example ?
Thanks
Arpan
In order to use Spring in your OSGi based java application for Spring Controllers or Dependency Injection you need to use Apache Aries Blueprint. Apache Karaf also provides a convenient distribution of the Felix OSGi Container with support for Apache Aries Blueprint. However before embarking on mixing Spring with OSGi I recommend reading the discussion on Blueprint here

How to run ActiveMQ in a OSGi Felix container?

Hi I would like run ActiveMQ inside the Apache Felix OSGi container. I don't want to run it as an embedded broker, in other words I don't want to have to write code. The ideal situation would be just to deploy the AMQ jars inside Felix and change config files to modify its behavior.
It looks like this is posible with the Apache Karaf container, but I cannot find neither documentation on how to do it in felix nor a clear answer if this is possible.
Thanks.
It looks like you are looking for Apache Service Mix
= Apache Karaf with ActiveMQ + Apache Camel + Apache CXF + other nice stuff.
But if you rather do it yourself, you could stick with Karaf or Felix, can't you just take the ActiveMQ bundle and do it similar to this instruction?
http://activemq.apache.org/osgi-integration.html
If you really want to deploy ActiveMQ in pure Apache Felix then the best way to start is to look into the Karaf feature for ActiveMQ. You need to install all the bundles referenced there and some basic karaf bundles.
In the ActiveMQ Karaf feature the broker is started using a Spring or Blueprint deployer from Karaf. This will look for spring dm or blueprint files and start them. The broker config is then such a file that starts the whole ActiveMQ.
So with some effort it should be possible but in the end you will duplicate a lot functionality of karaf. So using Karaf in the first place like Petter suggests is the simpler way to go.

OSGi: What are the differences between Apache Felix and Apache Karaf?

Apache Karaf is a sub project of Apache Felix. It is defined as "a lightweight OSGi container".
I don't understand when should I use the heavyweight and when to use the lightweight. Their site doesn't explain this too much.
The 'lightweight OSGi container' label is contrasting Karaf with more feature rich OSGi containers, not with Felix.
To quote Guillaume Nodet (Karaf's author) from here:
Felix is just the OSGi core runtime. Karaf provides a "distribution" based on Felix by adding other features such as a console, an SSH remoting mechanism, a file deployer and more.
In this diagram of the Karaf architecture, Felix (or other OSGi implementation - currently Equinox is also supported) is the OSGi box, the other boxes are the features added by Karaf:
Therefore, unless you have specific needs which are not met by Karaf (requiring access to the underlying implementation) it usually makes sense to use this since it provides more 'out of the box'.
#Marcel
Karaf isn't monolithic or huge like a Java EE server. It is a very slim and minimalist implementation. It is a core product without much functionality other than a basic console, file loading so that you can actually read configuration files, etc. The latest zip file of it is 19.1 MB. Yeah. Small. It can easily run on small devices and work in embedded.
What you may be thinking of is something more like ServiceMix which uses Karaf as a core/kernel. But it includes CXF, ActiveMQ, Camel and other libraries in its full configuration. Even then they have minimal, medium and full sizes.
Really, for 99% of the projects out there it wouldn't make sense to start directly with Felix and not use Karaf instead.
Currently, there are three popular open source OSGi containers:
- Equinox. It is the modular Java runtime at the heart of the Eclipse IDE,
- Knopflerfish, Is an open source implementation of the OSGi R3 and OSGi R4 specifications.
- Apache Felix. Is the open source OSGi container from the Apache Software Foundation.
http://www.javaworld.com/article/2077837/java-se/java-se-hello-osgi-part-1-bundles-for-beginners.html
The Apache project maintains a general-purpose OSGi container called Felix.
Here is used as ServiceMix and
The main difference between the ServiceMix and Karaf is that
ServiceMix bundles a bunch of other integration components β€” ActiveMQ
message broker, the Camel routing engine, and some other things
According: http://kevinboone.net/osgitest.html

Resources