Working example for a remote OSGI service [closed] - osgi

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I am new to programming with OSGI. Can anyone provide me a working example of a client/server osgi service invocation.
I have been trying to acheve this for the last 2 weeks without any success.
My service is being discovered and executed by an eclipse instance in the same machine, but when I try the same thing from another machine it fails.
Any help will be appreciated.
Thanks.

In OSGi platform (Release 4 Version 4.1) services discovered through OSGi service registry are local services available only inside single OSGi framework instance (i.e. single JVM). You can not expect to execute an OSGi service running on a different machine.
If you want to call OSGi services across multiple framework instances (i.e. multiple JVMs / multiple machines) you should take a look at Distributed OSGi Specification (RFC 119) that will be part of upcoming OSGi specification (Release 4 Version 4.2) with CXF as a reference implementation.
Update: Another way to call remote OSGi services is to use R-OSGi. It is a middleware that provides an almost transparent way to access services on remote OSGi platforms.

OSGi services are intra-vm, not inter-vm, unless you add distributing on the top.
You might want to look at Brian's tutorial which does a good job of showing how OSGi services can be exported and use ECF to perform the remote distribution. There's quite a few bundles involved but he does a good job in explaining it.

Unless you are playing with either CXF's or Eclipse's Distributed OSGi implementations, there's nothing related to remoting in OSGi. You should be able to make any remoting implementation work between 2 OSGi-based processes.
What I will say is you will probably have class loader issues if you try and use RMI or any of the RPC patterns available in Spring's remoting. This is solvable, but requires a good understanding of OSGi and class loaders.
Does your code work if you run it outside of OSGi? Are you using a firewall? Can you run any network-based service on your PC that is visible to other PCs on the network?
As described, the problem looks more network-related than OSGi-related.
Also, you didn't mention what failure you get when running across different PCs.

The Riena platform of the eclipse foundation provides OSGi remote services by publishing the services as web-service endpoints.

Maybe the answers should be updated, since they are not valid anymore.
Now there is OSGi Remote Services available You can read about it in the OSGi Enterprice Specification Chapter 100. There are two main implementaions: Eclipse ECF and Apache CXF. There is a good example for ECF here

Related

Suggestion on AWS Component & Deployment process [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Am planning to have multiple restful services (microservices) deployed in AWS. What are the essential components in AWS needed in order to deploy them and how can the deployment be scripted? Am checking on among the below two approaches as to which suite the best.
Approach 1:
Create the webservice as a Spring Boot application packaged as jar and deploy in AWS.
Approach 2:
Create the webservice as a Spring Boot application packaged as war and deploy to an application server in AWS.
The requirement is part of developing an enterprise application in AWS.
You may have to probably Dokerize your Microservices. Springboot comes with default Tomcat server, you can either use it or use undertow.
Once the Microservices are Dockerized, you can either use Docker Hub or Docker Trusted Registry or (any other tool of your choice) to save the Microservices Images.
The microservices Images can deployed in different Virtual Machines in a Cloud Environment (AWS/Azure/Any) using orchestration tools such DC/OS, Docker Data Center, Rancher, etc. If you're still planning to use your microservices like the way Monolith applications work then it will defeat the whole purpose of Microservices.
There are plenty of tools available to automate your continuous deployment. The right place to start is to try out different tools and analyze the pros/cons and come to a conclusion that fits best for you.
Please refer below for a head start:
http://www.slideshare.net/mongodb/webinar-enabling-microservices-with-containers-orchestration-and-mongodb

In the OSGi eco-system landscape is there any mean to automatically upgrade the OSGi Container himself?

Maybe this question seems odd ?
I am working on OSGi-fication of our software based on Agents collecting some informations on servers.
Concerning Bundles update, it's natively supported by OSGi frameworks (OBR, Apache ACE, ...)
But, concerning the OSGI Container itself (Felix, Karaf, ...), is there a mechanism or a framework/tool having capacity to upgrade the container "automatically"?
Any idea? Any feedback?
Not in the OSGi specification. It assumes the framework is available on the classpath and can be launched. Any ability to update the framework implementation would be specific to a framework implementation as a value add.

Where are spring tutorials without spring-boot? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
All the tutorials on spring.io are now all spring-boot centric. I'm not interested in converting existing projects to boot, and am not particularly interested in using boot for new projects, the "Takes an opinionated view of building Spring applications..." project statement isn't particularly encouraging.
Given this, I'm wondering where all the tutorials are for using spring without boot. Sure, the docs are great but those old tutorials were great.
Hopefully, with Google help, it is easy to find the excellent tutorials from mkyong. The reference manual (ok, not a tutorial) contains also a good deal of examples.
But you are right, it is easy to find javadoc and reference manuals for older Spring versions, but I could not find any tutorial on spring.io without spring-boot.
Edit (per m4rtin's comment) :
For a true beginner that would want to avoid spring-boot (want to deploy to a real container for example), they can be used alone. They can be used also as a way to skip the spring-boot part along with a more up to date tutorial from spring.io. I mean : spring-boot is just a way to automagically build a skeletal application including application contextes, and it is used for that in recent tutorials. But you can always create the skeletal application without spring-boot (with the use of the older mkyong tutorials) and then add the other components to follow a newer tutorial. Of course, it is a more advanced use, but it is the way I did for recently try some parts of Spring (other than the basic framework) because I am used to my old own tomcat and do not really like boot.
Of course if you only want to try something that you will throw away as soon as completed, the right way is probably to fully follow the new tutorials and use boot.
One can never please everyone.
When adding plain Spring samples people will start asking question why DataSources don't work or their activemq setup doesn't work (people usually don't takes days to figure it out, if it doesn't work < 5m a guide/project/sample is crap even if the error is their own).
The same for XML and JavaConfig for years the argument was that Spring == XML Hell (just take a look at their samples was often overheard/-read) now that is Java based config (a road that even Java EE is taking) it isn't ok either.
The Spring Boot guides allow you to focus on the core content at hand, instead of all the necessities/complexities around them. Nonetheless I do agree that some basic plain Spring Framework guides should exist. You might wan to comment on this issue

Migrating EJB2.1 Application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a legacy financial application which is written using EJB2.1(Making use of Entity Beans, Stateless Session Beans and Couple of MDBs).
I want to migrate the application to latest Java EE or Spring framework. The application consists of around 400 entities and Entity beans are mainly used for Creating and Updating.
For the viewing part a separate DAO layer is there and I don't want to touch that part.Also I want to keep the business logic written in service beans as it is very complex to re write.
i.e., I simply want to replace the ORM part of the system. The application is making use of JTA transactions.
Sorry to ask a very high level question, but which technology I can use to replace the ORM.
Spring/Hibernate
Java EE
The primary considerations for the application would be scalability, performance also ease of deployment.
I just want opinions on who have used these technologies, I don't want to start a war between 'evangelists'.
If you find the input is not suffcient please ask me I can provide more details.
the argument here is really between EJB-3.x versus Spring/Hibernate the first caveat being that one does not necessarily mutually exclude the other. (annotations, container, testing, etc.)
there's lots of support in migrating to EJB 2.1 to EJB 3.x and lots of toolsets to assist. one of the principal challenges that i've seen with EJB is integration testing outside the container. (for example. in a continuous integration environment) There are JTA solutions, JNDI solutions and others to support but on the whole, i've found that there is more 'out-of-container' testing support on the Spring migration path than Java EE. that said, there are foundation frameworks such as Arquillian from JBoss designed to support this.
so i would suggest you look at EJB 2.1 to EJB 3 migration paths and then look at the Arquillian framework for integration testing support

How does OSGi manage interaction of components running in separate JVMs?

I have been trying to understand a bit more about the wider picture of OSGi without reading thru the entire specification. As with so many things, the introduction to what OSGi actually is was probably written by someone who had been working on it for a decade and perhaps wasn't best placed to put themselves in the mindset of someone who knows nothing about it :-)
Looking at Felix's example DictionaryService, I don't really understand what is going on. Is OSGi a distinct instance of a JVM into which you load bundles which can then find each other?
Obviously it is not just this because other answers on StackOverflow are explicit that OSGi can solve the dependency problem of a distributed system containing modules deployed within distinct JVMs (plus the FAQ keeps talking about networks).
In this latter case, how does a component running in one JVM interact with another component in a separate JVM? Can the two components "use" each other as if they were running within the same JVM (i.e. via local method calls), and how does OSGi manage the marshalling of data across a network (do you have to use Serializable for example)?
Or does the component author have to use some other distinct mechanism (either provided by OSGi or written themselves) for communication between remote components?
Any help much appreciated!
Yes, OSGi only deals with bundles and services running on the same VM. However, one should note that it is a distinct feature of OSGi that it facilitates running multiple applications (in a controlled way and sharing common modules) on the same JVM at all.
When it comes to accessing services outside the clients JVM, there is currently no standardized solution. Paremus Infiniflow and the derived open-source project Newton use an SCA approach. The upcoming 4.2 release of the OSGi specs will address one side of the problem, namely how to use generic distribution software in such a way that it can bring remote services into the client's JVM.
As somebody mentioned R-OSGi, this approach also deals with the other side of the problem, being how to manage dependencies between distributed OSGi frameworks. Since R-OSGi is not generic distribution software but explicitly deals with the lifecycle issues and dependency management of OSGi bundles.
As far as I know, OSGi does not solve this problem out of the box. There are OSGi-bundles, for example Remote OSGi, which allow the programmer to distribute services across a network.
Not yet, i think it's being worked on for the next release.
But some companies have already implemented distributed osgi. One i'm aware of is Paremus' Infiniflow (http://www.paremus.com/products/products.html). At linkedin they are also working on this. More info here: Building Linkedin next gen architecture with osgi and here: Matt raible: building linkedin next gen architecture
Here's a summary of the changes for OSGI 4.2: Some thoughts on the OSGi R4.2 draft, There's a section on RFC-119 dealing with distributed OSGi.
AFAIK, bundles are running in the same JVM, but are not loaded using the same class loader (that why you can use two different versions of the same bundle at the same time).
To interact with components in another JVM, you must use a network protocol such as rmi.
The OSGi alliance is working on a standard for distributed OSGi:
http://www.osgi.org/download/osgi-4.2-early-draft2.pdf
There even is an early Apache implementation of this new standard:
http://cxf.apache.org/distributed-osgi.html
#Patriarch24
The accepted answer to this question would seem to indicate otherwise (unless I'm misreading it). Also, taken from the FAQ:
The OSGi Service Platform provides the functions to change the composition dynamically on the device of a variety of networks, without requiring a restart
(Emphasis my own). Although in the same FAQ it describes OSGi as in-VM.
Why am I so confused about this? Why is such a basic question about a decade-old technology not clear?
The original problem of OSGI was more related to distribution of code (and then configuration of bundle) than to distribution of execution.
People looking at distributed components are rather looking towards SCA
The "introduction" link is not really an intro, it is a FAQ entry. For more information, see http://www.osgi.org/About/WhatIsOSGi Not hard to find I would think.
Anyway, OSGi is an in-VM SOA. That is, the OSGi Framework is about what happens inside the VM, it provides a framework for structuring your application inside the VM so you can built it too a large extent from components. So the core has nothing to do with distribution, it is completely oblivious of who implements the services, it just provides a mechanism for modules to meet each other in a loosely coupled way.
That said, the µService model reifies the joints between the modules and it turns out that you can build support on top of the framework that provides distribution to the other components. In the last releases we specified some mechanisms that make this standardized in the core and provide a special service Remote Service Admin that can manage a distributed topology.
If you are looking for a distributed OSGi centric Cloud runtime - then the Paremus Service Fabric ( https://docs.paremus.com/display/SF16/Introduction ) provides these capabilities.
One or more Systems each consisting of a number of OSGi assemblies (Blueprint or Declarative Services) can be dynamically deployed and maintained across a population of OSGi runtime Frameworks (Knopflerfish, Felix or Equinox).
A light weight RSA remote framework is provided which provides Service discovery by default using DDS (a seriously good middleware messaging technology) - (thought ZooKeeper and other approach can be used). Currently supported re-moting protocols include RMI and Avro.
Regards
Richard

Resources