JBoss EAP + WMQ可怕的慢速消息发送

时间:2019-07-02 16:25:42

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

我正在使用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()。告诉我我在做什么错了吗?

1 个答案:

答案 0 :(得分:0)

通常,您的代码类似于反模式,即。如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