我正在尝试使用IBM MQXAConnectionFactory连接到MQ。 以下是代码
public class Custom {
public ConnectionFactory connectionFactory() throws Exception {
MQXAConnectionFactory connectionFactory = new MQXAConnectionFactory();
connectionFactory.setHostName(hostName);
connectionFactory.setPort(port);
connectionFactory.setQueueManager(queueManager);
connectionFactory.setChannel(channel);
connectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
connectionFactory.setClientReconnectTimeout(1000);
connectionFactory.setMsgBatchSize(10);
connectionFactory.setUseConnectionPooling(true);
return connectionFactory;
}
public CachingConnectionFactory cachingConnectionFactory() throws Exception{
CachingConnectionFactory factory = new CachingConnectionFactory();
factory.setSessionCacheSize(50);
factory.setTargetConnectionFactory(connectionFactory());
factory.setReconnectOnException(true);
factory.afterPropertiesSet();
return factory;
}
public static void main(String[] args) throws Exception {
Custom b = new Custom();
MQXAConnectionFactory cachingConnectionFactory = (MQXAConnectionFactory) b.cachingConnectionFactory().getTargetConnectionFactory();
XAConnection xaConnection = cachingConnectionFactory.createXAConnection();
xaConnection.start();
XASession session = xaConnection.createXASession();
MessageProducer messageProducer = session.createProducer(session.createQueue(queueName));
TextMessage textMessage = (TextMessage) session.createTextMessage();
textMessage.setText("pavan");
session.run();
messageProducer.send(textMessage);
xaConnection.stop();
session.close();
xaConnection.close();
System.out.println(xaConnection);
}
}
这会产生错误
WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2072' ('MQRC_SYNCPOINT_NOT_AVAILABLE')
这适用于非xa连接。这里有什么问题?