【问题标题】:JBoss EAP + WMQ Terrible slow message sendingJBoss EAP + WMQ 可怕的慢消息发送
【发布时间】:2019-07-05 23:21:38
【问题描述】:

我正在使用 JBoss EAP 7、WMQ 资源适配器连接到 WMQ 和 AMQ 资源适配器用于 AMQ。我必须从 AMQ 获取消息做一些逻辑并将其放入 WMQ。每当 JMSProducer 向 WMQ 发送消息时,大约需要 3-5 秒。

我的资源适配器配置:

 <resource-adapter id="com.wmq.jmsra.main">
     <archive>
         com.wmq.jmsra.rar
     </archive>
     <transaction-support>XATransaction</transaction-support>
     <config-property name="connectionConcurrency">
         2
     </config-property>                     
     <connection-definitions>
         <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedQueueConnectionFactoryImpl" jndi-name="${wmq.jndi.factory}" enabled="true" tracking="false" use-java-context="true" pool-name="WMQConnectionFactory">
             <config-property name="hostName">
                 ${mq.wmq.host}
             </config-property>
             <config-property name="password">
                 ${mq.wmq.input.password}
             </config-property>
             <config-property name="queueManager">
                 ${mq.wmq.manager}
             </config-property>
             <config-property name="port">
                 ${mq.wmq.port}
             </config-property>
             <config-property name="channel">
                 ${mq.wmq.channel}
             </config-property>
             <config-property name="transportType">
                 CLIENT
             </config-property>
             <config-property name="sslCipherSuite">
                 TLS_RSA_WITH_AES_128_CBC_SHA
             </config-property>
             <config-property name="username">
                 ${mq.wmq.input.user}
             </config-property>
             <xa-pool>
                 <min-pool-size>1</min-pool-size>
                 <initial-pool-size>1</initial-pool-size>
                 <max-pool-size>50</max-pool-size>
                 <fair>false</fair>
                 <no-tx-separate-pools>false</no-tx-separate-pools>
             </xa-pool>
             <recovery>
                 <recover-credential>
                     <user-name>${mq.wmq.input.user}</user-name>
                     <password>${mq.wmq.input.password}</password>
                 </recover-credential>
             </recovery>
         </connection-definition>
     </connection-definitions>
     <admin-objects>
         <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="${wmq.jndi.destination}" use-java-context="true" pool-name="wmq_queue_out">
             <config-property name="baseQueueName">
                 ${mq.wmq.output}
             </config-property>
             <config-property name="baseQueueManagerName">
                 ${mq.wmq.manager}
             </config-property>
         </admin-object>
     </admin-objects>
 </resource-adapter>

我的 AMQ MDB:

@MessageDriven(activationConfig = {
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "${mq.amq.main.input}"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
})
@ResourceAdapter("com.amq.jmsra.main")
public class MessageOnCryptServerToBank implements MessageListener {

    @Inject
    @JMSConnectionFactory("${wmq.jndi.factory}")
    private JMSContext context;

    @Resource(mappedName = "${wmq.jndi.destination}")
    private Destination queue;

    @Override
    public void onMessage(Message message) {
        String msgFromAmq = getTextFromMessage(message);
        // some logic
        TextMessage textMessage = context.createTextMessage(msgToWMQ);
        JMSProducer producer = context.createProducer();
        producer.send(queue, textMessage);
    }
}

我在每个字符串周围添加基准测试,以检测其中哪些会冻结我的应用程序。结果是producer.send()。告诉我我做错了什么?

【问题讨论】:

    标签: java jms ibm-mq jboss-eap-7


    【解决方案1】:

    通常,您的代码类似于反模式,即。正如 MQ 教程中描述的那样避免什么 - https://developer.ibm.com/messaging/learn-mq/mq-tutorials/slow-lost-messages-high-cpu-improve-your-mq-app/

    两者之间似乎不匹配

    private Destination queue;
    

    producer.send(destination, textMessage);
    

    destination 在您的代码中实际上是在哪里初始化的?它多久初始化一次?为什么不使用queue

    【讨论】:

    • 感谢您的回复!我的错误......这段代码来自两个不同的类 - 其中一个消耗消息另一个产生。为清楚起见省略了代码。当然destinationqueue 是同一个对象。感谢您的链接!我读了这篇文章,它看起来像是纯 Java 应用程序的文章。但我使用 JBoss,我想 JBoss 为我创建对象池并且不会分配新的连接和会话等。
    猜你喜欢
    • 2019-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-11
    • 1970-01-01
    • 2015-08-03
    • 1970-01-01
    相关资源
    最近更新 更多