5

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 ...

Rand0m
  • 342
  • 1
  • 4
  • 10
  • The `CachingConnectionFactory` generally resolves such issues; you should use tools such as debug logging and/or a network monitor to figure out where the problem lies, but it would be unusual for it to be Spring in this configuration. – Gary Russell Feb 21 '17 at 01:12
  • But Spring (on the same box, same network) is taking as an average 2 seconds per message end to end (three queues in total) while not using spring at all End To End the component is doing 20 message per second. The reason switching to Spring is I am refactoring the whole code and JMS is one component but super importan – Rand0m Feb 21 '17 at 02:18
  • It would have been helpful if you provided that information in your original question rather than just "very slow". However, what you are saying makes no sense to me so you must have some other problem in your code or configuration. Edit your question to show the exact code/config which exhibits this behavior as well as the code you are comparing it to. – Gary Russell Feb 21 '17 at 13:30
  • Was my mistake, I forgot the debug settings... now it is taking end to end between 10 to 65 milli second per message. Super Super fast. Thanks – Rand0m Mar 08 '17 at 01:23
  • How do you set ssl debug settings? Does it mean setting javax.net.debug env variable to ssl:handshake? – Muzammil Mar 20 '20 at 15:52

0 Answers0