Java Spring JMS: JmsTemplate to IBM MQ

回眸只為那壹抹淺笑 提交于 2019-12-07 17:42:26

问题


Update

It was my mistake I forget the ssl debugging running, it is super fast now and working like magic

I have a Spring Boot application that connects to IBM MQ using spring JMS. I realized that the jmsTemplate is super slow compared to not using Spring at all. I am sure I have something not configured correctly. Hope Someone can help.

I create a connection factory using IBM MQ 8 jar files.

@Bean
public ConnectionFactory connectionFactory() {
            properties.getCipherSpec());
    MQConnectionFactory factory = new MQConnectionFactory();
    try {
        factory.setHostName(properties.getHost());
        factory.setPort(properties.getPort());
        factory.setQueueManager(properties.getQueueManager());
        factory.setChannel(properties.getChannel());
        factory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
        factory.setClientReconnectTimeout(CLIENT_RECONNECT_TIMEOUT);
        factory.setClientReconnectOptions(WMQConstants.WMQ_CLIENT_RECONNECT);
        if (properties.isEnableSsl()) {
            factory.setSSLCipherSuite(properties.getCipherSpec());
            factory.setSSLSocketFactory(socketFactory());
        }   
        factory.setUseConnectionPooling(true);  
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return factory;
}

Then I am creating a caching Connection factory and setting Target Connection Factory to the connection factory above.

@Bean(name = "cachingConnectionFactory")
public CachingConnectionFactory cachingConnectionFactory(){
    CachingConnectionFactory factory = new CachingConnectionFactory();
    factory.setSessionCacheSize(50);
    factory.setTargetConnectionFactory(connectionFactory());
    factory.setReconnectOnException(true);
    factory.afterPropertiesSet();
    return factory;
}

and then in the Service class I am using the cache connection factory bean to create JmsTemplate per each thread and use the normal send receive operations.

@Autowired
private CachingConnectionFactory connectionFactory;

@PostConstruct
@DependsOn(value = "cachingConnectionFactory")
public void setJmsConnectionFactory(){
     this.jmsQueueTemplate = new JmsTemplate(this.cachingConnectionFactory);
}

Any help will be appreciated ...

来源:https://stackoverflow.com/questions/42356712/java-spring-jms-jmstemplate-to-ibm-mq

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!