非法尝试使用现有的两阶段资源提交具有单阶段功能的资源

时间:2011-07-27 06:16:40

标签: jms websphere ibm-mq message-driven-bean xa

我在WebSphere 6中有一个MDB.MessageListener链接到Tibco EMS队列。在MDB中,我正在尝试写入WebSphere MQ队列。我收到以下错误:

WMSG0042I: MDB Listener LoanIQ Payments Inbound started successfully for JMSDestination jms/eid/payments
WTRN0063E: An illegal attempt to commit a one phase capable resource with existing two phase capable resources has occurred.
WTRN0086I: XAException encountered during prepare phase for transaction 00000131...0001. Local resources follow.
WTRN0089I: XATransactionWrapper@ 3fbe3fbe  XAResource: com.ibm.ejs.jms.JMSManagedSession$JMSXAResource@3fb83fb8  enlisted: true  mcWrapper.hashCode()1038237154: Vote: commit.
WTRN0089I: LocalTransactionWrapper@:4e2e4e2e  LocalTransaction:com.ibm.ejs.jms.JMSManagedSession$JMS LocalTransaction@4e5a4e5a  enlisted:true  registeredForSynctruemcWrapper.hashcode()1032076676: Vote: none.

QueueConnectionFactory实例是com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle。我可以从中获得XAConnection吗?我需要吗?如果可能的话,我宁愿和香草JMS呆在一起。

MDB实施类似于:

public void onMessage(Message message) {
    // ^^ incoming message delivered from EMS queue via WAS MessageListener
    TextMessage textMessage = (TextMessage) message;
    QueueConnectionFactory factory = (QueueConnectionFactory) context.lookup(factoryName);
    Queue queue = (Queue) context.lookup(queueName);
    QueueConnection connection = factory.createQueueConnection();
    connection.start();
    QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
    QueueSender sender = session.createSender(queue);
    TextMessage message = session.createTextMessage("some new payload");
    sender.send(message);
    // ^^ outgoing message sent to WebSphere MQ queue
}

2 个答案:

答案 0 :(得分:7)

查看错误,您有一个XA资源和一个JCA LocalTransaction

  

WTRN0089I:XATransactionWrapper @ 3fbe3fbe XAResource:com.ibm.ejs.jms.JMSManagedSession$JMSXAResource@3fb83fb8 enlisted:true mcWrapper.hashCode()1038237154:投票:提交。

  

WTRN0089I:LocalTransactionWrapper @:4e2e4e2e LocalTransaction:com.ibm.ejs.jms.JMSManagedSession $ JMS LocalTransaction @ 4e5a4e5a enlisted:true registeredForSynctruemcWrapper.hashcode()1032076676:投票:无。

听起来你没有将ConnectionFactory设置为启用XA,请参阅:

http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/umj_pjcfm.html

(向下滚动到“XA Enabled”)或Tibco EMS连接不支持XA。如果是后者,并且没有合适的XA驱动程序,那么您可以查看WAS infocentre中的Last-Participant支持,这可能会满足您的需求 - 即WAS将准备WMQ XA事务,本地提交Tibco,然后提交WMQ如果Tibco提交工作(否则回滚)。如果Tibco连接具有XA功能,那么WAS对内置的WMQ具有完全的XA支持,因此没有理由不对整个操作使用两阶段事务。

关于

  

QueueConnectionFactory实例是com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle。我可以从中获得XAConnection吗?我需要吗?如果可能的话,我宁愿和香草JMS呆在一起。

你不应该这样做,只需保持简单的JMS。作为一般的风格点,最好也可以转换为ConnectionFactory(而不是QueueConnectionFactory),然后保留跨域对象(Connection,Session,MessageProducer)。

答案 1 :(得分:1)

我有同样的问题。我已经配置了我的队列,QCF和AC,但在收到消息后,事务正在回滚,并且数据库更新也失败了。 我在onMessage方法中添加了@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void onMessage(Message message) {//Logic }

希望它有所帮助。我和MDB是WAS 7听取消息。

`