【问题标题】:Websphere Liberty profile - transacted Websphere MQ connection factoryWebsphere Liberty 配置文件 - 事务处理的 Websphere MQ 连接工厂
【发布时间】:2015-04-23 15:26:06
【问题描述】:

试图让我的 Liberty 配置文件服务器为我的 Websphere 消息队列实例创建一个事务处理的 jmsConnectionFactory。

Liberty profile v 8.5.5.5 Websphere MQ 7.x

我尝试将 jmsQueueConnectionFactory 更改为 jmsXAQueueConnectionFactory 但它没有帮助 -> 然后它似乎只是忽略它并且不连接到 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>

日志

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

骆驼码

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

【问题讨论】:

  • Camel 在这里需要一个完整的 XA 连接工厂吗?它将成为 xa 协调器还是仅使用 jms 事务处理会话?
  • 在我没有使用 JNDI 查找并使用 JmsComponent.jmsComponentTransacted(connectionFactoryAdapter) 之前,connectionFactoryAdapter 用于设置凭据,它使用 MQXAQueueConnectionFactory。这确实有效,它在准备好处理消息时提交给生产者,但现在没有。我需要的是 Camel 在处理完消息后进行提交,因此如果 QueueManager 在处理消息时出现故障或应用程序出现故障,它不会丢失。使用 JmsComponent.jmsComponent() 只会消耗队列中的消息,它可能会丢失

标签: websphere apache-camel ibm-mq websphere-liberty


【解决方案1】:

结束于:

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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-03
    • 1970-01-01
    • 2013-03-31
    • 1970-01-01
    • 1970-01-01
    • 2013-05-03
    • 1970-01-01
    相关资源
    最近更新 更多