JMS web application with Eclipse and WebSphere Application Server - eclipse

I am new to JMS and WAS. I am grateful if someone provides any reference that helps me to create a web application in eclipse with JMS and WAS 7.0.
Also want to get answers for below questions..
How to inject ConnectionFactory or Destination object (created in WAS) into application using jndi?
How to install and run JMS web application on WAS server?

First you need to decide on the provider for JMS. It could be WebSphere MQ, the JMS provider that comes inbuilt with WAS or some other provider too.
Refer to the redbooks https://www.redbooks.ibm.com/Redbooks.nsf/RedbookAbstracts/sg247770.html?Open.
You can use InitialContext to lookup connection factory and Destination.
You can deploy the JMS app just like any other app. But ensure that JNDI objects are configured.
This is also a nice info-center to use for reference: http://pic.dhe.ibm.com/infocenter/prodconn/v1r0m0/topic/com.ibm.scenarios.wmqwasusing.doc/topics/scenario_overview.htm

Related

Weblogic and Websphere JMS Queue Communication

Currently in Weblogic we are running two applications and communicating through JMS Queue. Now one of the application we are moving to Liberty Server. What are the configuration we need to do for JMS Queue connection between Weblogic and Websphere.
Depending on which JMS Provider are you using, you have several options:
if provider has compatible JMS Resource Adapter (e.g. WebSphere MQ) - you can use that RA together with Liberty jca feature
if provider has a sort of thin client, you can embed that client libraries together with your application, and manually setup connection
if your current provider doesn't support any of above, you can use external JMS server that has compatible JMS RA (for example WebSphere MQ) and integrate it with both WebLogic and Liberty.
Update based on comments
There is no simple way to access Liberty JNDI externally - see this post Connect to Websphere Liberty jmsServer from remote application server
You could try to access embedded JMS via API. It is discussed here: https://www.ibm.com/mysupport/s/question/0D50z000062ktc3CAA/helloworld-jms-client-connecting-to-embedded-liberty-jms-server?language=en_US
But to be honest, if I were you I would either:
use external JMS Provider that is compatible with both runtimes e.g. WebSphere MQ
or rewrite interface between WebLogic and Liberty to REST, so that WebLogic invokes via REST simple application that reads the request and puts it to the queue in embedded Liberty JMS engine to avoid calling JMS engine externally.

REST Spring Boot Web Service on Websphere 9

I want to create a Spring Boot REST Web Service and deploy and publish it in Traditional Websphere 9 Application Server. Is it possible ?
What all challenges I might encounter? Can someone please provide me few pointers for reference?
Yes this can be done. It is not a good design, but yes it can be done. Back in the day when I was working for a big bank, they deployed java spring-boot microservices in IBM websphere(Not liberty).
How to do it?
1) Package your deployable as war. You can do this by editing your pom to package as WAR.
2) You can either add connection string config in your springboot starter class or get a JNDI created in the websphere instance. We observed that performance of the API's improved when the app used websphere JNDI as opposed to app created connection bean.
3) If you use IBM MQ, the best course of action is get a non-ssl and ssl based channel created at MQ and a JNDI for the MQ connection as well.
4) If you plan to create MQ connection beans within the app, like we did, ensure the JKS file has all the valid set of signers of your org.
Problems we faced
1) Our app used a lot of third party rule engine like drools, so ensure the websphere server.xml is configured to servlet version 3.1 or higher
2) Webshpere admin console is helpful, but don't just blindly believe if it says green to your container, always check your app logs for errors.
3) Common pain points are establishing a successful connection with IBM MQ host. Get a MQ server admin to troubleshoot all MQRC errors.
4) If you plan to use Oracle as backend, ensure the DBA has created a wallet for you to enable both SSL and Non SSL connections. Some organisations are picky with non-sssl db connections. It is easier to handle all this if you leverage webspehere JNDI for DB connections.
Let me know if this helped.
Both WebSphere Traditional and WebSphere Liberty support Spring boot.
Are you looking for something like this?
http://www.adeveloperdiary.com/java/spring-boot/deploy-spring-boot-application-ibm-liberty-8-5/

Jboss EAR with EJB and webservice health monitoring and management

I am using Jboss5.1 and I have a EAR1 deployed which has a EJB3 component implemented using #Stateless annotation and the same EJB is also exposed as webservice using the annotation #webservice.
I want to check through a EJB service/management service bean(Packaged in another EAR2) from the start of deployment to un-deployment of EAR1 PERIODICALLY, if the EJB and Webservice is deployed and running properly and working normally and is not in deadlock/non responsive state.
I have looked into JMX and I am able to get notifications of create and destroy for EJB as well as webservice, but how to check periodically whether the EJB and webservice is working normally and is not in deadlock/non responsive state?
Also how to monitor Jboss ESB services?
Is the JMX is the only way or does jboss provides any other API's to do monitoring how about JBOSS MONITORING
Thanks in advance if you are looking at this.
Especially JBoss AS5.x is using the so called profile service (PS) as the main way to interact with the server. Unfortunately the PS is not JMX-based and on the other side you don't see all EJBs in the Platform MBean server.
RHQ has a plugin to monitor EJB instances inside AS5 as well as for other resource types like JBoss ESB or Apache Tomcat and is able to determine the availability of EJBs.
but how to check periodically whether the EJB and webservice is
working normally and is not in deadlock/non responsive state?
This is usually something that you can (only)(*) determine by hitting the relevant beans/methods and evaluating the outcome.
*) It may be possible to determine a bean in a deadlocked state by requesting a heap dump and looking for deadlocked periodically.

JMS queue in websphere

We are currently using JMS queue in Weblogic.
Can we use same JMS queue in Websphere as part of weblogic to websphere migration.
Is there any other concept available in websphere which can replace JMS queue?
WebSphere Application Server has a built-in JMS provider, due to the Java EE standard which defines it as mandatory (as Arjan Tijms already stated).
Setting up the JMS provider requires a so called Service Integration Bus, which is a simple Messaging Bus inside WebSphere. The Service Integration Bus also allows to setup High Available JMS queues/topics when using WebSphere Application Server Network Deployment.
Using this queues/topics outside of a WebSphere context - by putting messages into the queues from external clients or reading them from external clients - is hard.
Mainly due to the WebSphere internal CORBA communication it is quite tricky to setup a working and stable
configuration - and you need to know some internal WebSphere tricks.
My recommandation is to use internal jms configuration only for applications which are deployed on the same WebSphere Application Server-Configuration.
If you really need external access to the JMS queues/topics, you should write a adapter to access it.
This blog post describes in detail how to setup a simple WebSphere internal JMS configuration.
WebSphere has indeed an internal JMS provider. It's accessed using the SIB (Service Integration Bus). See http://www.packtpub.com/article/messaging-with-websphere-application-server-7.0-part1
WepSphere has JMS queues as well. Are you wanting to have the queue running within WebSphere, or are you trying to point to a queue running elsewhere?
Yes, you can.
Configuration depends on your JMS System.
If your JMS Middleware is running external like ApacheMQ or Swift JMS, you can normally install an Resource Adapter and then use that specific configuration (at least for the Jms configuration). Then you can use Websphere's JMS Configuration (like Queues and Topics) and therefor your normal MDB configuration.
Besides ActivationSpec (like above) at least with Websphere MQ you could use Listener Ports. I don't know if Listener Ports are available for other JMS Products.
If you want to use a built in Messaging System, you can use SIB I guess.
So plenty of options depending on your System.
A JMS provider is mandated by the Java EE specs so every application server has an inbuilt JMS Provider.
You have to make the right calls about your application needs. There might be valid reasons to use an external JMS provider such as WebSphere MQ.

JMS without JNDI?

We are running portlets in WebSphere 6.01, using Java 1.4. We want to send JMS messages to a JBoss 5 queue, running Java 5 (or maybe 6, but it's certainly newer than 1.4). Trying to connect using JNDI is not working, since we have to include the JBoss client jars in the classpath of the portlet, and they are Java 1.5. So I get an unsupported major/minor error when I try to create the InitialContext.
Can we connect straight to JBoss without using JNDI? Or is there some way to get around this issue I can't think of?
Even if you were able to connect to JMS without going through JBoss's JNDI, you would still need to include the JBoss client JAR in order to use JMS. Both JNDI and JMS are APIs, and you need the server's implementation of that client API in order to talk to the server.
If it's just your JNDI classes that prereq Java 5 and not the JBoss classes then you can do this. But you would have to set all of the properties of the objects and that is provider-specific. The WebSphere MQ JMS samples show how to do this with WMQ and you would need to know the property and value names for JBoss to make the equivalent code. Here is a code snippet from the WMQ JmsProducer.java sample:
JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
JmsConnectionFactory cf = ff.createConnectionFactory();
// Set the properties
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, host);
cf.setIntProperty(WMQConstants.WMQ_PORT, port);
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, channel);
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, queueManagerName);
// Create JMS objects
connection = cf.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
if (isTopic) {
destination = session.createTopic(destinationName);
}
else {
destination = session.createQueue(destinationName);
}
producer = session.createProducer(destination);
On the other hand, if your JBoss classes prereq Java 1.5 then you need to run Java 1.5 or better.
Depending on the JBoss version you can directly instantiate all the JMS objects.
One particular version:
see http://www.jboss.org/file-access/default/members/jbossmessaging/freezone/docs/usermanual-2.0.0.beta1/html/using-jms.html
(Section 5.5. Directly instantiating JMS Resources without using JNDI)
I think JNDI is the only way that you can create JMS connection factories and destinations (queue or topic), and these are your means of communication.
In fact using JNDI is a way to be independant of the JMS provider, because you can easly change it.
But if you've got no problem with that most provider offer facilities to create a connection factory and destinations
It sounds like the problem isn't with JNDI but with the conflicting classnames between the environments.
You could try doing the classloading yourself when you try to instantiate the JBOSS client classes. That way you get a separate classloader from the one that loaded the Portlet. Just make sure you understand whether you need Parent-first or Parent-last behavior. Also on that page is debugging classloading which can show you how to set the Classpath for the classloader so you can isolate the JBOSS libraries and avoid classname collisions. It is a good resource for understanding even advanced classloading issues.