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

最佳答案

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

关于java - JBoss EAP + WMQ可怕的慢速消息发送,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56856651/

10-09 01:30