Websphere Liberty profile - transacted Websphere MQ connection factory

☆樱花仙子☆ 提交于 2020-01-02 04:47:07

问题


Trying to get my Liberty profile server to create a transacted jmsConnectionFactory to my instance of Websphere message queue.

Liberty profile v 8.5.5.5 Websphere MQ 7.x

I've tried to change the jmsQueueConnectionFactory to jmsXAQueueConnectionFactory but it does not help -> Then it seems to just ignore it and doesn't connect to the MQ

server.xml

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

  <!-- Enable features -->
  <featureManager>
    <feature>wmqJmsClient-1.1</feature>
    <feature>jndi-1.0</feature>
    <feature>jsp-2.2</feature>
    <feature>localConnector-1.0</feature>
  </featureManager>

  <variable name="wmqJmsClient.rar.location" value="D:\wlp\wmq\wmq.jmsra.rar"/>

  <jmsQueueConnectionFactory jndiName="jms/wmqCF" connectionManagerRef="ConMgr6">
    <properties.wmqJms
            transportType="CLIENT"
            hostName="hostname"
            port="1514"
            channel="SYSTEM.DEF.SVRCONN"
            queueManager="QM"           
            />
  </jmsQueueConnectionFactory>

  <connectionManager id="ConMgr6" maxPoolSize="2"/>

  <applicationMonitor updateTrigger="mbean"/>
  <application id="App"
               location="...\app.war"
               name="App" type="war"/>
  <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
  <httpEndpoint id="defaultHttpEndpoint"
                httpPort="9080"
                httpsPort="9443"/>
</server>

log

2015-04-23 17:07:14,981 [JmsConsumer[A0]] WARN  ultJmsMessageListenerContainer - Setup of JMS message listener invoker failed for destination 'A0' - trying to recover. Cause: Could not commit JMS transaction; nested exception is com.ibm.msg.client.jms.DetailedIllegalStateException: JMSCC0014: It is not valid to call the 'commit' method on a nontransacted session. The application called a method that must not be called on a nontransacted session. Change the application program to remove this behavior.
2015-04-23 17:07:14,983 [JmsConsumer[A0]] INFO  ultJmsMessageListenerContainer - Successfully refreshed JMS Connection

Camel code

public static JmsComponent mqXAComponentTransacted(InitialContext context, String jndiName) throws JMSException, NamingException {
    return JmsComponent.jmsComponentTransacted((XAQueueConnectionFactory) context.lookup(jndiName));
}

回答1:


Ended up with:

public static JmsComponent mqXAComponentTransacted(InitialContext context, String connectionFactoryJndiName, String userTransactionJndiName) throws JMSException, NamingException {
    LOG.info("Setting up JmsComponent using jndi lookup");
    final JtaTransactionManager jtaTransactionManager = new JtaTransactionManager((UserTransaction) context.lookup(userTransactionJndiName));
    final ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryJndiName);
    final JmsComponent jmsComponent = JmsComponent.jmsComponentTransacted(connectionFactory, (PlatformTransactionManager) jtaTransactionManager);
    jmsComponent.setTransacted(false);
    jmsComponent.setCacheLevel(DefaultMessageListenerContainer.CACHE_NONE);
    return jmsComponent;
}


来源:https://stackoverflow.com/questions/29827894/websphere-liberty-profile-transacted-websphere-mq-connection-factory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!