gpt4 book ai didi

apache-camel - Apache Camel MQXAQueueConnectionFactory

转载 作者:行者123 更新时间:2023-12-04 18:05:32 26 4
gpt4 key购买 nike

好吧,我正在尝试让 MQXAQueueConnectionFactory 工作,我从 JmsComponent 创建了一个扩展类,以在将数据发送到队列时处理用户名和密码。
它确实在队列中获取/放置消息,但在我的情况下,我创建了一个路由器来测试 XA,例如

 from("wmq:queue:incomingQueue")
.process(new Processor(){
... Thread.sleep(20000)
})
.to("wmq:queue:outgoingQueue")

在 sleep 时,我关闭了队列管理器。但是,当尝试从队列中获取未提交的消息时
DISPLAY QSTATUS('qChainQueue') 我得到 CURDEPTH(0) ,而我理解的 XA 部分应该是 1。
  • 我这样做完全错了吗?
  • 如何测试?

  • 处理 WMQ 的 HelpClass:
    public class WMQComponent extends JmsComponent {
    private final String username;
    private final String password;

    public WMQComponent(String hostname, int port, String username, String password,
    String queueManager, String channel) throws JMSException {
    super();
    this.username = username;
    this.password = password;

    MQXAQueueConnectionFactory connectionFactory = new MQXAQueueConnectionFactory();
    connectionFactory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
    connectionFactory.setFailIfQuiesce(1);

    connectionFactory.setHostName(hostname);
    connectionFactory.setPort(port);
    connectionFactory.setQueueManager(queueManager);
    connectionFactory.setChannel(channel);

    setConnectionFactory(connectionFactory);
    }

    @Override
    public Endpoint createEndpoint(String uri) throws Exception {
    if (uri.contains("username") || uri.contains("password")) {
    throw new IllegalStateException("Username and password is set by the component");
    }
    if (uri.contains("?")) {
    return super.createEndpoint(uri + "&username=" + username + "&password=" + password);
    } else {
    return super.createEndpoint(uri + "?username=" + username + "&password=" + password);
    }
    }

    }

    出现以下错误:
    2015-03-25 14:01:12,077 [ #2 - Multicast] INFO  dest_chain_ldap                - org.springframework.jms.IllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'QMBATCHESB' with connection mode 'Client' and host name 'hostname.com'.; nested exception is com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'QMBATCHESB' with connection mode 'Client' and host name 'hostname.com'. Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.; nested exception is com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2059' ('MQRC_Q_MGR_NOT_AVAILABLE').
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:279)
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:469)
    at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:228)
    at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:431)
    at org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:385)
    at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:153)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:120)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:416)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:120)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:416)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)
    at org.apache.camel.processor.MulticastProcessor.doProcessParallel(MulticastProcessor.java:732)
    at org.apache.camel.processor.MulticastProcessor.access$200(MulticastProcessor.java:82)
    at org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:303)
    at org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:288)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    Caused by: com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'QMBATCHESB' with connection mode 'Client' and host name 'hostname.com'. Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.
    at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:496)
    at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:236)
    at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:430)
    at com.ibm.msg.client.wmq.internal.WMQXAConnection.<init>(WMQXAConnection.java:70)
    at com.ibm.msg.client.wmq.factories.WMQXAConnectionFactory.createV7ProviderConnection(WMQXAConnectionFactory.java:190)
    at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6210)
    at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:278)
    at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6155)
    at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:144)
    at com.ibm.mq.jms.MQQueueConnectionFactory.createConnection(MQQueueConnectionFactory.java:223)
    at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.doCreateConnection(UserCredentialsConnectionFactoryAdapter.java:175)
    at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.createConnection(UserCredentialsConnectionFactoryAdapter.java:150)
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:456)
    ... 29 more
    Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2059' ('MQRC_Q_MGR_NOT_AVAILABLE').
    at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:223)
    ... 41 more
    Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2059;AMQ9204: Connection to host 'hostname.com(1514)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2059;AMQ9213: A communications error for occurred. [1=java.net.ConnectException[Connection refused: connect],3=hostname.com]],3=hostname.com(1514),5=RemoteTCPConnection.connnectUsingLocalAddress]
    at com.ibm.mq.jmqi.remote.internal.RemoteFAP.jmqiConnect(RemoteFAP.java:1831)
    at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:345)
    ... 40 more
    Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2059;AMQ9213: A communications error for occurred. [1=java.net.ConnectException[Connection refused: connect],3=hostname.com]
    at com.ibm.mq.jmqi.remote.internal.RemoteTCPConnection.connnectUsingLocalAddress(RemoteTCPConnection.java:612)
    at com.ibm.mq.jmqi.remote.internal.RemoteTCPConnection.protocolConnect(RemoteTCPConnection.java:940)
    at com.ibm.mq.jmqi.remote.internal.system.RemoteConnection.connect(RemoteConnection.java:1097)
    at com.ibm.mq.jmqi.remote.internal.system.RemoteConnectionPool.getConnection(RemoteConnectionPool.java:348)
    at com.ibm.mq.jmqi.remote.internal.RemoteFAP.jmqiConnect(RemoteFAP.java:1503)
    ... 41 more
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at com.ibm.mq.jmqi.remote.internal.RemoteTCPConnection$2.run(RemoteTCPConnection.java:597)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.ibm.mq.jmqi.remote.internal.RemoteTCPConnection.connnectUsingLocalAddress(RemoteTCPConnection.java:588)
    ... 45 more

    最佳答案

    原因代码 2059 和表明连接被拒绝的各种错误表明存在机械问题(即监听器未运行)或身份验证问题。

    如果我试图调试它,我要做的第一件事就是启用授权事件、 channel 事件以及您通常会启用的任何其他事件。如果您使用 MQ Explorer,还要安装 MS0P Plugin这将允许您以人类可读的文本查看事件消息。

    接下来,我将使用 MQ 示例程序进行测试。因为我总是安装完整的客户端而不是获取 jar 文件,所以我有 amqsputc 可用。但是,Java 类具有 IVT(初始验证测试)程序。这些确保监听器正在运行, channel 已配置且可用等。从 v7.1 开始,这也确保了 CHLAUTH规则设置为允许访问。从 v8.0 开始,或者如果您安装了 Capitalware 导出,这也可以让我们测试用户 ID 和密码身份验证。

    假设连接请求发送到 MQ,队列管理器的错误日志和事件消息应该提供良好的诊断。请务必查看 QMgr 特定的错误日志和安装全局错误日志。

    一旦我确认基本连接就位,我会协调我的主机、端口、 channel 的客户端配置参数,如果指定 [不寒而栗!] QMgr 名称。假设这些是正确的并且已经证明基本连接有效,现在可以有信心地测试应用程序。

    同样的方法也适用。首先确保应用程序的连接请求使其连接到 QMgr。如果这样做并被拒绝,事件消息和错误日志将注明这一点以及原因。如果这些地方没有出现故障的迹象,则该应用程序无法访问 QMgr。 2059 可以表示套接字被拒绝,监听器已启动但 QMgr 未启动, channel 实例已达到最大值,或者在临时启动 channel 后它被 QMgr 关闭,通常是由于 CHLAUTH规则。在任何情况下,事件消息和错误日志都会详细说明原因。

    关于apache-camel - Apache Camel MQXAQueueConnectionFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29257341/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com