2015-04-23 213 views
4

嘗試讓我的Liberty配置文件服務器爲我的Websphere消息隊列實例創建事務jmsConnectionFactory。Websphere Liberty配置文件 - 事務Websphere MQ連接工廠

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)); 
} 
+0

是駱駝需要一個完整的XA連接工廠嗎?它將成爲xa協調員還是僅使用jms事務會話? – Calanais

+0

之前我沒有使用JNDI查找並使用 JmsComponent.jmsComponentTransacted(connectionFactoryAdapter) connectionFactoryAdapter用於設置憑據,並且它使用了MQXAQueueConnectionFactory。 這確實有效,它在處理消息準備就緒時向生產者提交,但現在不會。 我需要的是,Camel在處理完消息後才進行提交,所以在QueueManager出現故障或應用程序在處理消息時出現故障的情況下,它不會丟失。使用JmsComponent.jmsComponent()會消耗隊列中的消息,並可能丟失 – J2B

回答

0

止帶起來:

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; 
} 
相關問題