How do I deploy a Spring MDP on JBOSS 5 App server? - spring

I want to find out if my thoughts are correct about deploying MDP on JBOSS:
There are definitely advantages of using MDP instead of MDB but all these advantages will only work when you don’t use an EJB Container/App Server. Since, I need to use JBOSS 5 APP server, it would be an overkill to have an MDP running under Spring Context which in turn gets deployed on JBOSS App server.
The second reason is Spring framework releases are very quick whereas JBOSS 5 is old, I believe that there will be issues such as conflicting jars.
The third reason is that I haven’t seen many people doing it.

I've been working on several Spring-based projects with more than a dozen message listeners and those projects were deployed, namely, on JBoss (from Jboss 4.x in the early days to the latest JBoss EAP).
There's nothing wrong with deploying a Spring's message listener container within the JBoss infrastructure. In the past, you could hit some inconsistencies though. The most annoying was that the redelivery options defined on the queue were ignored. But that's history as from JBoss5+
To deploy your message listener container on JBoss, you need to configure a regular JndiTemplate and lookup destinations and the ConnectionFactory using it. To be able to resolve destinations by name, you need to specify a JndiDestinationResolver on the container that uses said JndiTemplate. You could also lookup the queue yourself (and get rid of the DestinationResolver)

Related

What is the best container for an integration/pipeline system written with Camel?

I know the question is very general and the answer is too biased to the scale, scope, type, etc. of the the target system. Hence, actually I want to know what is the pros and cons of using various containers such as spring-boot, single-main, karaf, etc. and also when/why I should to use a container for such a system.
In our previous project my colleagues used apacha-karaf but they had a lot of troubles such as building the project, settings to allow components export jmx, poor documentation, etc. with it. Since the current system is a spring-based application maybe using spring-boot makes more sense. Any thoughts?
The main questions you have to ask is what are your requirements regarding:
How many integration (micro?)services you will have to support?
Will you need to support independent configuration of these services?
Will you need to support independent branching/versioning of these services?
Will you need to have "hot deployment" (i.e. deploying/ updating/ re-configuring one does not inherently affects the operation of the others) of these services?
If the answer is yes to all, then you have two main alternatives:
Go the JBoss Fuse way (RedHat branded version of Apache Karaf). This means that each of your integration (micro)services will be an OSGi bundle in Fuse.
Go with a non OSGi container, but in this case in order to satisfy your requirements you need another layer of managing the life-cycle of your services. E.g. you can take a look at Fabric8 (https://fabric8.io/).
This will mean that you will ideally have one (micro)service per Docker container (instead of a micro-service per OSGi bundle) and Fabric8 will provide you will the Web UI (plus many other tools, like Kubernetes commands, maven commands) to manage the deployment of your service to a Docker container. As a result, a service may be using spring boot/ tomcat, another one may be just a jvm standalone process or another one may be an OSGi bundle running inside Karaf container, deployed inside a docker container. So option (1) can also be deployed to option (2).
Depending what path you follow you have to be savvy with different technologies, e.g.:
Fuse: osgi/ Fuse container, camel, maven, ..
Fabric: your on demand container (e.g. spring-boot/ tomcat, java process, Fuse, python process, scala process etc..), Docker, Kubernetes, Fabric8, OpenShift, maven, ..
Hope this help :-)
I use the java dsl of Camel together and deploy it inside apache-karaf wrapped inside a docker container. The key is to use feature descriptors and a maven repository. Then you can create custom distributions of a camel project which are loaded in your karaf distribution. This means you can work towards a really cool microservice approach where services are deployed as individual docker containers.
The biggest difficult was getting the custom distribution of Karaf working. Once that was done the rest was pretty ok. I don't use spring so can't speak about spring-boot.
Inside Karaf/docker you can deploy hawtio and from hawtio do monitoring, see metrics and do all kinds of other stuff. Karaf also has decanter which has a kibana dashboard and alerting feature.
The answer should totally depend on what container technologies you are most familiar with and what you'd like to do with the Camel application.
I think Spring Boot is best when you'd like to create a MSA application with Camel and you are familiar with Spring already. The good news is that Camel now fully supports Spring Boot: http://camel.apache.org/spring-boot.html
On the other hand, if you have a preference to the classical-style standalone approach Karaf would be a rock-solid option since commercial products like JBoss Fuse (https://developers.redhat.com/products/fuse/overview/) use Karaf as the primary container. Plus, if you are an OSGi lover then no doubt you choose Karaf ;-)
Finally, don't forget that you can also run Camel applications on a JEE application container. Basically you can package them as .war and deploy them to any JEE container, but it should be worth noting that WildFly has an extended integration support for Camel: http://wildfly-extras.github.io/wildfly-camel/ With the WildFly-Camel subsystem you can deploy Camel applications as simple .jar as you do on Karaf.
Actually I have the same question, here is my conclusion:
Karaf
pros:
1. OSGI based, hot deploy and support multiple version.
2. Maven support, can continuously deploy from maven repo.
Cons:
1. Legacy jars are not support OSGI, need to recreate the jars
2. Dependency conflicts are really hell.
3. Split functions into bundles, it will take more time to develop and test.
Spring Boot
pros:
1. Spring is like a glue, can integration different libraries easily.
2. Spring boot make it much easier to startup, develop and test efficiently.
3. Spring boot + docker, will make the deployment much easier in cloud environment
cons:
1. If you want to support multiple version at same time, need double your infra.
So my suggestion is to use camel in Spring boot. My architecture design is like Spring Boot + Camel + Docker + Consul + Registrator

Alternative of JTATransaction

I have an Spring based J2EE application which runs well on Weblogic, I wanted to move it to Tomcat.
It seems tomcat doesn't support JTA Transaction Manager without external jar help like Atomikos, JOTM, Bitronix, SimpleJTA.
I am reluctant to make changes into my application where i am already using annotation based JTA transaction manager.
Are there alternatives for JTA Transaction Manager which I can use so that I am able to switch from weblogic to tomcat or tomcat to weblogic or any other server without changing my configuration file each time?
All in all what's best for transaction manager configuration when you want to keep your application (war) independent of server(s).
You could try TomEE.
It's a Java EE 6 server that meets the Web Profile requirements and is based on Tomcat.
So it will support JTA transactions.
You can get it from http://tomitribe.com
Just to give you a more direct link to TomEE: http://tomee.apache.org/download/tomee-1.7.2.html
If your application is configured and developed to use Weblogic then chances are you are using JDNDI to lookup the JTA transaction manager and your datasources.
So any solution that supports the same lookups would work.
For Atomikos, we recently added (commercial) support for Tomcat's JNDI space - check out http://www.atomikos.com/Main/BuyOnline to learn more.
Hope this helps!

Writing a JSF based spring boot app so that it can also run on a Java EE app server without change

Spring boot is great - we have an app that runs standalone fine, using JAXRS 2, JSF 2.1.6. They versions are irrelevant really, other than they are under our control.
Our corporate deployments are on fully blown Java EE app servers though, so we don't have the option of deploying the app to something simple such as Tomcat or even as a jar with embedded Tomcat.
Trying to get a Spring boot app to work on these ends up being a world of pain, as the Java EE app server will either stop you completely or partially from using different versions of jars to the ones it ships with.
So my question is, is there a magic bullet that allows Spring boot apps to fully blown app servers like WildFly,Glassfish etc. Or what are the general approaches to getting around this issue?
The only one I can think of is to code the application to exactly the same spec as the app server, and then use Maven profiles to ship the jars for the embedded up, but to have them as provided when using them in an app server. Of course this immediately takes away the advantage of Spring not being tied down to a particular version of Java EE.

How to ensure that HornetQ is deployed before any application in JBoss 6?

We have an issue, that if you start JBoss 6 with our Java EE 6 applications deployed, where one of them uses a JMS Queue, the related MDB won't consume any messages until you re-deploy the applications. The MDB is using a Singleton with a Startup annotation.
My research so far resulted in the assumption that this is caused by HornetQ being deployed after the application.
I also found some hints to get around this here and here, but I neither was able (and by the way didn't like) to use JBoss specific annotation in my applications due to missing Maven dependency nor am I using any deployment descriptor file so far.
So my question is, how do I ensure, preferrably with standard Java EE annotations or HornetQ/JBossAS configuration file that the queues are deployed before my application gets deployed?

How to integrate a SpringSource dm Server into another OSGi-based application server?

I would really like to use SpringSource dm Server, but our customer requires us to run our apps on their application server (Websphere). Is there a way to integrate SpringSource dm Server with other application servers? At least dm Server is build on OSGi, and many other application servers (including Websphere) are based on OSGi as well. Is it possible to run a SpringSource dm Server as a websphere component?
SpringSource dm Server is based on the Eclipse Equinox OSGi framework (and should not be confused with the Spring DM technology, included in dm Server, which can run on Equinox, Apache Felix, and Knopflerfish).
However, embedding dm Server in another application server, such as WebSphere Application Server, based on Equinox would be a non-trivial piece of work. It would be necessary to get both products to use the same version of Equinox, which they currently do not, then modify dm Server to support embedding in the server (e.g. to integrate with the host server's application invocation mechanism, thread pools, and class loading scheme).
If you think this support is important, please raise a requirement (which requires a simple registration) against dm Server.
Spring DM is deployed on a Knoplerfish OSGi implementation.
Websphere is deployed on an Equinox OSGi implmentation.
So the question becomes - are the two interchangeable? They both support R4, so I would say, yes, they are.
The next question would be to check dependencies, particularly with respect to things like HttpServices.
I would say this would be ok, but I think the final proof would be try deploying it. Easiest would be to drop the bundles into a Websphere deployment. You'll need your bundles and whatever spring bundles you're using.
I'm also interested in this topic. Another way of looking at this problem is that you want an application depoyable in both Spring dm server and a traditional app server (Websphere, weblogic, JBoss, ...).
The OSGi containers are embeddable inside non-OSGi applications, so it is theoretically possible to deploy an app to both Spring dm server and the same app + OSGi container to a traditional app server.
Now, as usual, the devil's in the details, including such topics of web development and bridging servlets between the outer app server and the OSGi container.
I do not think that this is really the case ...
see the following link for this: http://apsblog.burtongroup.com/2008/11/websphere-7-osgi.html
But it seems on the other side, that the trend is clear ... there will be a time when OSGI based application can be deployed on Java EE application servers

Resources