I have a Java EE application (actually, it is an apache camel application) deployed on WebSphere Application Server 7.
My application consumes service requests from Web Services (threads started from the servlet container in WAS) and from JMS queues (not SI-BUS, but WebSphere MQ if that matters). For the JMS listener, Camel (or the underlying spring framework perhaps) initiates own threads (seems to be simple java threads more or less) to deal with JMS requests.
I also have a transactional Database attached to the application. So, in spring, I have something like this definied to grab a transaction manager (WebSphere built in JTA probably).
<tx:annotation-driven/>
So my problem is, that I get an error like this when a Camel/JMS is triggering an event in the application:
org.apache.openjpa.persistence.PersistenceException: TransactionManager not found in JNDI under name java:comp/websphere/ExtendedJTATransaction
Seems like threads not initiated by the container itself cannot do JNDI lookups correct. Is there a way around this issue?
Related
My questions is related to an older post.
I am trying to publish a message to a Wildfly JMS queue. Right now the queues and the app run on the same JBoss container. I am trying to create a new Spring Boot app that can publish messages to the existing queues from another container. Since Wildfly is old I am not finding much help online.
All JMS clients (including Spring JMS) need basic things like JNDI context properties, admin object names, etc. You can refer to the Wildfly Hello World JMS Quickstart for these details and then plug them in to your Spring Boot application. The actual names of the admin objects (i.e. connection factory, queue, etc.) will, of course, vary based on your particular configuration.
We have a requirement for one standalone Java application that can push JMS message to a JMS queue configured on Weblogic, Websphere and JBoss application server.
Is there any generic JMS client library available, that we can use in our application for pushing the messages to any or all of these servers?
As we understand, there is a specific JMS client for each server (for e.g. wljmsclient.jar required for Weblogic target server, as we would need weblogic.jndi.WLInitialContextFactory to be available as Initial Context factory class, similarly for Websphere and JBoss). And we would like to avoid having 3 different JMS client libraries (1 each for server) in the same application.
However, the catch here is, destination server is not known during compilation time. Only during runtime, it will be known whether the given message is to be pushed to Weblogic, Websphere or JBoss server or all of them. Hence, there is a need for a deployed application to support all 3 servers during runtime.
Is there any alternative generic JMS client library?
You can develop your own client that supports the 3 servers.
Basically you need to have for your standalone application :
The different JMS provider jar on the classpath
For example a jms_config.properties file which stores the configuration for each server (initial context factory, etc.)
Then from a generic code you can build the InitialContext, JMS Queues, etc. depending on the target server.
I have a Spring Integration application, where I have a JMS inbound channel adapter that will receive messages from a queue in a remote JMS broker. I'm looking up the connection factory directly from the broker's remote JNDI service and this is what I use to set up my inbound channel adapter. I understand that behind the scenes there is a DefaultMessageListenerContainer. According to AbstractMessageListenerContainer javadocs, found here, if "sessionTransacted" is set to "true" for the DMLC, local JMS transactions will be used for the delivery of messages from the broker.
I'm not interested in having the receipt of messages to be part of externally managed transactions.
Now, if the JMS broker provides a resource adapter and therefore there is a JCA managed connection factory (that might be capable of participating in JTA transactions) configured in a JBoss App server where my Spring Integration is running packaged in a war . I could use this instead of directly looking up from the broker's JNDI as I described above. Since I am not interested in global transactions, I don't see the value of using this JCA connection factory, moreover I don't know if the caching of connections/sessions that JCA does might clash with the DMLC caching strategy. Additionally I'm not sure if adding a JCA layer to wrap the original connection factory will impact performance.
Which is the right approach then, take connection factory directly from broker JNDI and let DMLC handle everything or take a JCA managed connection? There seems to be a not very well documented school of thought that tells that JCA is safer and more robust, but if I'm not using EJBs I dont see how this can be true.
We are working on an IBM WebSphere MQ application, and we use JMS API to operate the message. But we have a problem that the connection takes too much time, and we want to pool the JMS connection, for it's a standalone application, we have no application container to provide JNDI or pooling service. So is there a solution to resolve this? For JDBC we can use DBCP or c3p0 to archive pooling datasource, in JMS, is there any similar project that can pool JMS connections?
It used to be that the JMS MQConnectionFactory had pooling built in, but it seems that in version 7, it has been removed.
Set the use of ConnectionPooling in earlier versions of the WebSphere
MQ classes for JMS. This method is retained for compatibility with
older MQJMS applications, but, because this Connection Pooling
functionality has been removed from version 7, setting this property
will have no effect.
In the absence of anything else, you can use Apache Commons Pool. Same idea as DBCP (which uses Pool) but for non JDBC objects.
Spring's CachingConnectionFactory works well for this use case.
This answer in https://stackoverflow.com/a/31119435/1765341 explains how to do this in Tomcat, but the code there can easily be adapted for Java standalone applications. This should be much easier (and less error prone) than writing an Apache Commons Pool implementation.
I a using ehcache with JMS replication and ActiveMQ as a JMS server.
It is currently used to cache database results with Hibernate 3.6.7
My cacheManager is configured as above:
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.jms.JMSCacheManagerPeerProviderFactory" properties="initialContextFactoryName=br.com.sonner.iss.jms.ExampleActiveMQInitialContextFactory,
providerURL=failover:tcp://localhost:6969,userName=XXX,password=YYYY,
replicationTopicConnectionFactoryBindingName=topicConnectionFactory,
replicationTopicBindingName=ehcache,
getQueueConnectionFactoryBindingName=queueConnectionFactory,
getQueueBindingName=ehcacheGetQueue"
propertySeparator=","
/>
The replication and failover is working as it should. If the JMS goes down (the replication stops) and the starts over again when the JMS server starts again.
The only problem that I am facing is that if the JMS server is down at the moment of the startup of my app. The app does not start.
Probably because when Spring goes up it reads the hibernate configurations and when hibernate is loading the app just freezes waiting for the broker.
Does anyone has a work-arround this issue?
I am thinking if there is a way to use the spring jmsTemplate configuration to configure ehcache.xml jndi entries.