mq-jms-spring
mq-jms-spring copied to clipboard
MQ Queue Manager Channel Name is disappearing form the JmsConnectionFactory when we use them across both JmsListener and JmsTemplate
**MQ Queue Manager Channel Name is disappearing form the JmsConnectionFactory when we use them across both JmsListener and JmsTemplate
Spring JMS - mq-jms-spring-boot-starter (Version 2.0.0) java version "1.8.0_162" Java(TM) SE Runtime Environment (build 1.8.0_162-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
MQQueueConnectionFactory mqQueueConnectionFactory = new MQQueueConnectionFactory(); mqQueueConnectionFactory.setHostName(lsHost); mqQueueConnectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT); mqQueueConnectionFactory.setChannel(lsChannel); mqQueueConnectionFactory.setPort(loPort); mqQueueConnectionFactory.setQueueManager(lsManager); mqQueueConnectionFactory.setPollingInterval(loPollingInterval); mqQueueConnectionFactory.setSSLSocketFactory(loSSLSocketFactory); mqQueueConnectionFactory.setSSLFipsRequired(false); mqQueueConnectionFactory.setSSLCipherSuite(lsSslCipherSuite); mqQueueConnectionFactory.setSSLPeerName(lsSslPeerName);
CachingConnectionFactory loCacheConnFactory = new CachingConnectionFactory(); loCacheConnFactory.setTargetConnectionFactory(mqQueueConnectionFactory); loCacheConnFactory.setSessionCacheSize(loCacheSize); loCacheConnFactory.setCacheConsumers(true); loCacheConnFactory.setReconnectOnException(true);
JmsTransactionManager loJmsTransactionManager = new JmsTransactionManager(loCachingConnectionFactory);
JmsTemplate loJmsTemplate = new JmsTemplate(loCachingConnectionFactory); loJmsTemplate.setPubSubDomain(false); loJmsTemplate.setDeliveryPersistent(true); loJmsTemplate.setReceiveTimeout(loTimeOut); loJmsTemplate.setSessionTransacted(true);
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); factory.setConnectionFactory(aCachingConnectionFactory); factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER); factory.setConcurrency("1-5"); factory.setSessionTransacted(lbSessionTranscated); factory.setAutoStartup(true); factory.setReceiveTimeout(loTimeOut); factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER); factory.setTransactionManager(loJmsTransactionManager);
SimpleJmsListenerEndpoint loEndPoint = new SimpleJmsListenerEndpoint(); loEndPoint.setMessageListener(loMessageListenerInstance); loEndPoint.setDestination(lsQueueName);
DefaultMessageListenerContainer loListenerContainer = factory. createListenerContainer(loEndPoint);
loListenerContainer.setMaxConcurrentConsumers(loMaxConcurrentConsumer); loListenerContainer.setConcurrentConsumers(loConcurrentConsumer); loListenerContainer.setIdleTaskExecutionLimit(loIdleTaskExeLimit); loListenerContainer.setMaxMessagesPerTask(loMaxMsgPerTask); loListenerContainer.setIdleConsumerLimit(loIdleConsumerLimit); loListenerContainer.setAcceptMessagesWhileStopping(false);
loJmsTemplate.send(aQueueName, MessageCreator);
2021-06-10T12:32:06.016+01:00 [APP/PROC/WEB/0] [ERR] org.springframework.transaction.CannotCreateTransactionException: Could not create JMS transaction; nested exception is com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ0018: Failed to connect to queue manager '' with connection mode 'Client' and host name 'RBSMQ-RS861AC.server.rbsgrp.net(5111)'. 2021-06-10T12:32:06.016+01:00 [APP/PROC/WEB/0] [ERR] Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information. 2021-06-10T12:32:06.016+01:00 [APP/PROC/WEB/0] [ERR] at org.springframework.jms.connection.JmsTransactionManager.doBegin(JmsTransactionManager.java:234) 2021-06-10T12:32:06.016+01:00 [APP/PROC/WEB/0] [ERR] at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:378) 2021-06-10T12:32:06.016+01:00 [APP/PROC/WEB/0] [ERR] at com.rbs.bdd.mq.clustered.framework.message.sender.impl.ClusteredMessageSenderImpl.sendMessageToQueue(ClusteredMessageSenderImpl.java:128) 2021-06-10T12:32:06.016+01:00 [APP/PROC/WEB/0] [ERR] at com.rbs.bdd.mq.clustered.framework.message.sender.impl.ClusteredMessageSenderImpl.sendMessage(ClusteredMessageSenderImpl.java:73) 2021-06-10T12:32:06.016+01:00 [APP/PROC/WEB/0] [ERR] at com.rbs.bdd.mq.clustered.framework.message.sender.impl.ClusteredVanquishTextMessageSenderImpl.dispatchMessage(ClusteredVanquishTextMessageSenderImpl.java:42) 2021-06-10T12:32:06.016+01:00 [APP/PROC/WEB/0] [ERR] at com.rbs.bdd.api.service.InwardRetrieveServiceImpl.sendMessageToClusteredQueue(InwardRetrieveServiceImpl.java:97) 2021-06-10T12:32:06.017+01:00 [APP/PROC/WEB/0] [ERR] at com.rbs.bdd.api.service.InwardRetrieveServiceImpl.processRetrieveRequest(InwardRetrieveServiceImpl.java:80) 2021-06-10T12:32:06.017+01:00 [APP/PROC/WEB/0] [ERR] at com.rbs.bdd.api.controller.InwardPaymentController.processRetrieveRequest(InwardPaymentController.java:53) 2021-06-10T12:32:06.017+01:00 [APP/PROC/WEB/0] [ERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2021-06-10T12:32:06.017+01:00 [APP/PROC/WEB/0] [ERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 2021-06-10T12:32:06.017+01:00 [APP/PROC/WEB/0] [ERR] at
When we explicitly set mqQueueConnectionFactory.setChannel(lsChannel); before loJmsTemplate.send(aQueueName, MessageCreator); thing are working as expected! Not sure why channel is Vanished from the pre-configured ConnectionFactory object?**
I've got no real idea what's going on here. Your code doesn't compile (even when obvious variables like the qmgr and channel names are added) so it's rather difficult to know what you are trying to do. But I suspect that you are trying and not quite succeeding in bypassing the automatic connection configuration done by Spring Boot that sets defaults on connections when the CFs are created.
Though you also say you are using v2.0.0 of the starter which is 3 years old, and all kinds of things have changed since then.
I doubt very much that this is one long continuous method, but this is how you have written it. It makes it very hard to debug your code, as it appears that (even though you are on a back level version of the MQ Spring boot starter) your issue is in how you are making use of connection factory beans.
Let me explain why its difficult to debug your code -
You initialise a CachingConnectionFactory as loCacheConnFactory
, which you don't subsequently use.
You base your JmsTemplate on loCachingConnectionFactory
, which is never initialised.
JmsTemplate loJmsTemplate = new JmsTemplate(loCachingConnectionFactory);
and you base your JmsListenerContainerFactory on aCachingConnectionFactory
, which is nowhere else in your code.
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(aCachingConnectionFactory);
I would expect you to be using syntax similar to the configurations, components and beans defined in this sample - https://github.com/ibm-messaging/mq-dev-patterns/tree/master/Spring-JMS/src/main/java/com/ibm/mq/samples/jms/spring/level114
I've got no real idea what's going on here. Your code doesn't compile (even when obvious variables like the qmgr and channel names are added) so it's rather difficult to know what you are trying to do. But I suspect that you are trying and not quite succeeding in bypassing the automatic connection configuration done by Spring Boot that sets defaults on connections when the CFs are created.
Though you also say you are using v2.0.0 of the starter which is 3 years old, and all kinds of things have changed since then.
Hello Mark,
Many thanks for your review and suggestions, I haven't pasted the full code in my previous post because I thought just a sample template would suffice. I have attached my full code here and it will help you to understand what we are trying to implement. I have upgraded the version to latest (2.4.2) as well. Please let me know if you have any further queries on this. I am using multiple Queue Managers (load balanced QM's) and the code is dynamically creating the CF's and get assigned to JmsListeners and JmsTemplate.
Regards, Lithesh
package com.rbs.bdd.mq.clustered.framework.config;
import java.io.InputStream; import java.security.KeyStore; import java.security.Provider; import java.security.Security; import java.util.Enumeration; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.Properties; import java.util.StringTokenizer;
import javax.jms.JMSException; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory;
import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Scope; import org.springframework.core.io.ClassPathResource; import org.springframework.jms.config.DefaultJmsListenerContainerFactory; import org.springframework.jms.config.SimpleJmsListenerEndpoint; import org.springframework.jms.connection.CachingConnectionFactory; import org.springframework.jms.connection.JmsTransactionManager; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.listener.DefaultMessageListenerContainer; import org.springframework.jms.support.converter.MappingJackson2MessageConverter; import org.springframework.jms.support.converter.MessageConverter; import org.springframework.jms.support.converter.MessageType; import org.springframework.transaction.PlatformTransactionManager;
import com.ibm.mq.jms.MQQueueConnectionFactory; import com.ibm.msg.client.wmq.WMQConstants; import com.rbs.bdd.crypto.service.DecryptionService; import com.rbs.bdd.mq.clustered.framework.common.exception.VanquishRuntimeException; import com.rbs.bdd.mq.clustered.framework.error.handler.ClusteredErrorHandler; import com.rbs.bdd.mq.clustered.framework.exception.handler.ClusteredExceptionListener; import com.rbs.bdd.mq.clustered.framework.listener.ClusteredMessageListener; import com.rbs.bdd.mq.clustered.framework.listener.impl.ClusteredBDDMessageListenerImpl; import com.rbs.bdd.mq.clustered.framework.model.ClusteredListenerContainerModel; import com.rbs.bdd.mq.clustered.framework.model.ClusteredListenerContainers; import com.rbs.bdd.mq.clustered.framework.model.JmsTemplateModel; import com.rbs.bdd.mq.clustered.framework.model.impl.ClusteredListenerContainersImpl; import com.rbs.bdd.mq.clustered.framework.props.BDDClusteredMQMessageProperties; import com.rbs.bdd.mq.clustered.framework.props.ClusteredJmsProperties; /** --------------------------------------------------------------------------------------------------------
-
Description : A configuration class used in this framework to create all the MQ objects
-
Author : Lithesh Anargha
-
Email : [email protected]
-
Date : 07/02/2020
-
Project : Vanquish
-
Platform : Bankline Direct Digital
-
Organization : Royal Bank of Scotland plc. -------------------------------------------------------------------------------------------------------- **/ @Configuration @ComponentScan("com.rbs.bdd") public class IBMMQClusteredConfiguration {
private static final String EMPTY = ""; private static final String TRUE = "true"; private static final String YES = "yes"; private static final String JKS = "JKS"; private static final String COMMA = ","; private static final String SEMICOLON = ";"; private static final String EMPTY_VALUE_PROVIDED = "Empty list supplied for configuration and is not valid!"; private static final boolean AUTO_STARTUP = false; private static int RECEIVE_TIME_OUT = 120000;
/**
- The enable logging info details as and when required. */ private static final Logger LOGGER = LoggerFactory.getLogger(IBMMQClusteredConfiguration.class);
/**
- The autowired spring boot object for JmsProperties Class. */ @Autowired private ClusteredJmsProperties jmsProperties;
@Autowired private DecryptionService decryptionService;
@Autowired private BDDClusteredMQMessageProperties bddClusteredMQMessageProperties;
/** *
- @return */ @Bean(name = "bddClusteredMQChannelList") public List<String> getClusteredMQChannelList() { List<String> loChannelList = getAsListString(jmsProperties.channel); return loChannelList; }//eof getClusteredMQChannelList
/** *
- @return */ @Bean(name = "bddClusteredMQQueueManagerList") public List<String> getClusteredMQQueueManagerList() { List<String> loChannelList = getAsListString(jmsProperties.queuemanager); return loChannelList; }//eof getClusteredMQQueueManagerList
/** *
- @return */ @Bean(name = "bddClusteredQueueManagerHostList") public List<String> queueManagerHostList() { List<String> loChannelList = getAsListString(jmsProperties.host); return loChannelList; }//eof getQueueManagerHostList
/** *
- @return */ @Bean(name = "bddClusteredErrorHandler") public ClusteredErrorHandler vanquishErrorHandler() { return new ClusteredErrorHandler(); }//eof vanquishErrorHandler
/** *
- @return */ @Bean(name = "bddClusteredExceptionListener") public ClusteredExceptionListener vanquishExceptionListener() { return new ClusteredExceptionListener(); }//eof VanquishExceptionListener
/** *
- @param aListenerContainerModelList
- @return */
/** *
-
@return */ private List<MQQueueConnectionFactory> bddMQQueueConnectionFactoryList() { logMessage(" -> bddMQQueueConnectionFactoryList() "+this.getClass().getName()); List<MQQueueConnectionFactory> loMQQueueConnectionFactoryList = new LinkedList<MQQueueConnectionFactory>(); try { List<String> loHostList = getAsListString(jmsProperties.host); List<String> loChannelList = getAsListString(jmsProperties.channel); List<Integer> loPortList = getAsListInteger(jmsProperties.port); List<String> loQManagerList = getAsListString(jmsProperties.queuemanager); List<String> loSSLPeerNameList = getAsListStringWithSemicolon(jmsProperties.sslPeerName); List<Integer> loPollingIntervalList = getAsListInteger(jmsProperties.minPollingInterval);
int loCount = 0; for (String lsHostName : loHostList) { String lsHost = getStringValue(lsHostName); String lsChannel = getStringFromTheList(loChannelList,loCount); Integer loPort = getIntegerFromTheList(loPortList,loCount); String lsManager = getStringFromTheList(loQManagerList,loCount); String lsSSLPeerName = getStringFromTheList(loSSLPeerNameList,loCount); Integer loPollingInterval = getIntegerFromTheList(loPollingIntervalList,loCount); logMessage("lsHost -> "+lsHost); logMessage("lsChannel -> "+lsChannel); logMessage("loPort -> "+loPort); logMessage("lsManager -> "+lsManager); logMessage("loPollingInterval -> "+loPollingInterval); logMessage("lsSSLPeerName -> "+lsSSLPeerName); MQQueueConnectionFactory mqQueueConnectionFactory = new MQQueueConnectionFactory(); mqQueueConnectionFactory.setHostName(lsHost); mqQueueConnectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT); mqQueueConnectionFactory.setChannel(lsChannel); mqQueueConnectionFactory.setPort(loPort); mqQueueConnectionFactory.setQueueManager(lsManager); mqQueueConnectionFactory.setPollingInterval(loPollingInterval); mqQueueConnectionFactory = enableSSL(mqQueueConnectionFactory,lsSSLPeerName); loMQQueueConnectionFactoryList.add(mqQueueConnectionFactory); loCount = loCount + 1; }//eof for
} catch (Exception aException) { aException.printStackTrace(); throw new VanquishRuntimeException(aException); } logMessage(" <- bddMQQueueConnectionFactoryList() "+this.getClass().getName()); return loMQQueueConnectionFactoryList; }// EOF bddMQQueueConnectionFactoryList
/** *
-
@param aMQQueueConnectionFactory
-
@param aSSLPeerName */ private MQQueueConnectionFactory enableSSL(MQQueueConnectionFactory aMQQueueConnectionFactory, String aSSLPeerName) { logMessage(" -> enableSSL() "+this.getClass().getName()); try { Properties loSystemProps = System.getProperties();
//-Dorg.cloudfoundry.security.keymanager.enabled=false -Dcom.ibm.mq.cfg.useIBMCipherMappings=false loSystemProps.setProperty("javax.net.debug", "all"); loSystemProps.setProperty("com.ibm.mq.cfg.useIBMCipherMappings", "false"); loSystemProps.setProperty("org.cloudfoundry.security.keymanager.enabled", "false"); System.setProperties(loSystemProps); //Used to override any restricted JCE provider issues. Security.addProvider(new BouncyCastleProvider()); //Security.insertProviderAt(new BouncyCastleJsseProvider(), 1); //Class.forName("com.sun.net.ssl.internal.ssl.Provider"); Provider[] loProviders = Security.getProviders(); if (loProviders != null) { logMessage("!!!!! LISTING ALL THE PROVIDERS !!!!!"); for (Provider loProvider : loProviders) { logMessage("Provider -> "+loProvider.toString()); }//eof for }//eof if String lsEnabled = getStringValue(jmsProperties.sslEnabled); if (!isEnabled(lsEnabled)) return aMQQueueConnectionFactory; String lsKeyStoreName = getStringValue(jmsProperties.sslKeyStoreName); String lsKeyStorePassPhrase = getStringValue(jmsProperties.sslKeyStorePassPhrase); lsKeyStorePassPhrase = getDecryptedText(lsKeyStorePassPhrase); String lsTrustStoreName = getStringValue(jmsProperties.sslTrustStoreName); String lsTrustStorePassPhrase = getStringValue(jmsProperties.sslTrustStorePassPhrase); lsTrustStorePassPhrase = getDecryptedText(lsTrustStorePassPhrase); String lsSslPeerName = getStringValue(aSSLPeerName); String lsSslCipherSuite = getStringValue(jmsProperties.sslCipherSuite); String lsSslVersion = getStringValue(jmsProperties.sslVersion); logMessage("lsKeyStoreName -> "+lsKeyStoreName); logMessage("lsKeyStorePassPhrase -> "+lsKeyStorePassPhrase); logMessage("lsTrustStoreName -> "+lsTrustStoreName); logMessage("lsTrustStorePassPhrase -> "+lsTrustStorePassPhrase); logMessage("lsSslPeerName -> "+lsSslPeerName); logMessage("lsSslCipherSuite -> "+lsSslCipherSuite); logMessage("lsSslVersion -> "+lsKeyStoreName); if (lsKeyStoreName.length()==0) { throw new VanquishRuntimeException( bddClusteredMQMessageProperties.getPropertyValue("message.filecantbeempty")); }//eof if if (lsTrustStoreName.length()==0) { throw new VanquishRuntimeException( bddClusteredMQMessageProperties.getPropertyValue("message.filecantbeempty")); }//eof if // instantiate a KeyStore with type JKS KeyStore loKeyStore = KeyStore.getInstance(JKS); // load the contents of the KeyStore InputStream loKSInputStream = new ClassPathResource(lsKeyStoreName).getInputStream(); if (loKSInputStream == null) { throw new VanquishRuntimeException( bddClusteredMQMessageProperties.getPropertyValue("message.filedidntexist")); }//eof if loKeyStore.load(loKSInputStream, lsKeyStorePassPhrase.toCharArray()); KeyStore loTrustStore = KeyStore.getInstance(JKS); // Open our file and read the trust store (no password) InputStream loTSInputStream = new ClassPathResource(lsTrustStoreName).getInputStream(); if (loTSInputStream == null) { throw new VanquishRuntimeException( bddClusteredMQMessageProperties.getPropertyValue("message.filedidntexist")); }//eof if loTrustStore.load(loTSInputStream, lsTrustStorePassPhrase.toCharArray()); // Create a default trust and key manager TrustManagerFactory loTrustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); KeyManagerFactory loKeyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); // Initialise the managers loTrustManagerFactory.init(loTrustStore); loKeyManagerFactory.init(loKeyStore, lsKeyStorePassPhrase.toCharArray()); logMessage("loTrustStore -> "+loTrustStore); logMessage("loKeyStore -> "+loKeyStore); logMessage("loTrustManagerFactory -> "+loTrustManagerFactory); logMessage("loKeyManagerFactory -> "+loKeyManagerFactory); SSLContext loSSLContext = SSLContext.getInstance(lsSslVersion); logMessage("loSSLContext -> "+loSSLContext); loSSLContext.init(loKeyManagerFactory.getKeyManagers(), loTrustManagerFactory.getTrustManagers(), new java.security.SecureRandom()); logMessage("!!!!! AVAILABLE TRUST MANAGERS !!!!!"); if (loTrustManagerFactory != null) { TrustManager[] loTrustManagers = loTrustManagerFactory.getTrustManagers(); for (TrustManager loTrustManager : loTrustManagers) { logMessage("loTrustManager-> "+loTrustManager); }//eof for }//eof if logMessage("!!!!! AVAILABLE KEY ALIAS FROM KEYSTORE !!!!!"); if (loKeyStore != null) { Enumeration<String> loKeyStoreAlias = loKeyStore.aliases(); while (loKeyStoreAlias.hasMoreElements()) { String lsKeyAlias = loKeyStoreAlias.nextElement(); logMessage("KEY STORE ALIAS -> "+lsKeyAlias); }//eof while }//eof if logMessage("!!!!! AVAILABLE KEY ALIAS FROM TRUSTSTORE !!!!!"); if (loTrustStore != null) { Enumeration<String> loTrustStorAlias = loTrustStore.aliases(); while (loTrustStorAlias.hasMoreElements()) { String lsTrustKeyAlias = loTrustStorAlias.nextElement(); logMessage("TRUST STORE ALIAS -> "+lsTrustKeyAlias); }//eof while }//eof if // Get an SSLSocketFactory to pass to WMQ SSLSocketFactory loSSLSocketFactory = loSSLContext.getSocketFactory(); aMQQueueConnectionFactory.setSSLSocketFactory(loSSLSocketFactory); aMQQueueConnectionFactory.setSSLFipsRequired(false); if (lsSslCipherSuite.length()>0) aMQQueueConnectionFactory.setSSLCipherSuite(lsSslCipherSuite); if (lsSslPeerName.length()>0) aMQQueueConnectionFactory.setSSLPeerName(lsSslPeerName); logMessage("!!!!! SUCCESSFULLY CREATED SSL CONTEXT !!!!!"); if (loKSInputStream!=null) { logMessage("!!!!< Key store input stream closed >!!!!"); loKSInputStream.close(); }//eof if if (loTSInputStream!=null) { logMessage("!!!!< Trust store input stream closed >!!!!"); loTSInputStream.close(); }//eof if
} catch (JMSException aJMSException) { aJMSException.printStackTrace(); throw new VanquishRuntimeException(aJMSException); } catch (Exception aException) { aException.printStackTrace(); throw new VanquishRuntimeException(aException); }
logMessage(" <- enableSSL() "+this.getClass().getName()); return aMQQueueConnectionFactory; }//eof enableSSL
/** *
-
@return */ @Bean(name = "bddCachingMQConnectionFactoryListForSender") @Primary public List<CachingConnectionFactory> bddCachingMQConnectionFactoryListForSender() { logMessage(" -> bddCachingMQConnectionFactoryListForSender() "+this.getClass().getName()); List<CachingConnectionFactory> loCachingConnectionFactoryList = new LinkedList<CachingConnectionFactory>(); try { List<Integer> loCacheSizeList = getAsListInteger(jmsProperties.sessionCacheSize);
List<MQQueueConnectionFactory> loMQQueueConnectionFactoryList = bddMQQueueConnectionFactoryList(); ListIterator<MQQueueConnectionFactory> loMQQueueConnectionFactoryListIter = loMQQueueConnectionFactoryList.listIterator(); int loCount = 0; while (loMQQueueConnectionFactoryListIter.hasNext()) { Integer loCacheSize = loCacheSizeList.get(loCount); MQQueueConnectionFactory loMQQueueConnectionFactory = loMQQueueConnectionFactoryListIter.next(); CachingConnectionFactory loCacheConnFactory = new CachingConnectionFactory(); loCacheConnFactory.setTargetConnectionFactory(loMQQueueConnectionFactory); loCacheConnFactory.setSessionCacheSize(loCacheSize); loCacheConnFactory.setCacheConsumers(true); loCacheConnFactory.setReconnectOnException(true); loCachingConnectionFactoryList.add(loCacheConnFactory); loCount = loCount + 1; }//eof while } catch (Exception aException) { aException.printStackTrace(); throw new VanquishRuntimeException(aException); } logMessage(" <- bddCachingMQConnectionFactoryListForSender() "+this.getClass().getName()); return loCachingConnectionFactoryList; }// eof bddCachingMQConnectionFactoryListForSender
/** *
-
@return */ @Bean(name = "bddCachingMQConnectionFactoryListForListener") @Primary public List<CachingConnectionFactory> bddCachingMQConnectionFactoryListForListener() { logMessage(" -> bddCachingMQConnectionFactoryListForListener() "+this.getClass().getName()); List<CachingConnectionFactory> loCachingConnectionFactoryList = new LinkedList<CachingConnectionFactory>();
List<String> loQueueNamesList = getAsListString(jmsProperties.queueNamesList); logMessage(" loQueueNamesList -> "+loQueueNamesList); if (isEmptyStringList(loQueueNamesList)) { logMessage(" <- bddCachingMQConnectionFactoryListForListener() "+this.getClass().getName()); return loCachingConnectionFactoryList; }//eof if
List<String> loListenerClassesList = getAsListString(jmsProperties.queueListenerClasses); logMessage(" loListenerClassesList -> "+loListenerClassesList); if (isEmptyStringList(loListenerClassesList)) { logMessage(" <- bddCachingMQConnectionFactoryListForListener() "+this.getClass().getName()); return loCachingConnectionFactoryList; }//eof if
try { List<Integer> loCacheSizeList = getAsListInteger(jmsProperties.sessionCacheSize);
List<MQQueueConnectionFactory> loMQQueueConnectionFactoryList = bddMQQueueConnectionFactoryList(); ListIterator<MQQueueConnectionFactory> loMQQueueConnectionFactoryListIter = loMQQueueConnectionFactoryList.listIterator(); int loCount = 0; while (loMQQueueConnectionFactoryListIter.hasNext()) { Integer loCacheSize = loCacheSizeList.get(loCount); MQQueueConnectionFactory loMQQueueConnectionFactory = loMQQueueConnectionFactoryListIter.next(); CachingConnectionFactory loCacheConnFactory = new CachingConnectionFactory(); loCacheConnFactory.setTargetConnectionFactory(loMQQueueConnectionFactory); loCacheConnFactory.setSessionCacheSize(loCacheSize); loCacheConnFactory.setCacheConsumers(true); loCacheConnFactory.setReconnectOnException(true); loCachingConnectionFactoryList.add(loCacheConnFactory); loCount = loCount + 1; }//eof while
} catch (Exception aException) { aException.printStackTrace(); throw new VanquishRuntimeException(aException); } logMessage(" <- bddCachingMQConnectionFactoryListForListener() "+this.getClass().getName()); return loCachingConnectionFactoryList; }// eof bddCachingMQConnectionFactoryListForListener
/** *
- @return */ @Bean(name = "jmsTransactionManagerListForListener") public List<PlatformTransactionManager> jmsTransactionManagerListForListener() { logMessage(" -> jmsTransactionManagerListForListener() "+this.getClass().getName()); List<PlatformTransactionManager> loPlatformTransactionManagerList = new LinkedList<PlatformTransactionManager>(); JmsTransactionManager loJmsTransactionManager = null; try { List<CachingConnectionFactory> loCacheConnFactoryList = bddCachingMQConnectionFactoryListForListener(); ListIterator<CachingConnectionFactory> loCacheConFactoryListIter = loCacheConnFactoryList.listIterator(); while (loCacheConFactoryListIter.hasNext()) { CachingConnectionFactory loCachingConnectionFactory = loCacheConFactoryListIter.next(); loJmsTransactionManager = new JmsTransactionManager(loCachingConnectionFactory); loPlatformTransactionManagerList.add(loJmsTransactionManager); }//eof while } catch (Exception aException) { aException.printStackTrace(); throw new VanquishRuntimeException(aException); } logMessage(" <- jmsTransactionManagerListForListener() "+this.getClass().getName()); return loPlatformTransactionManagerList; }//eof jmsTransactionManagerListForListener
/** *
- @return */ @Bean(name = "jmsTransactionManagerListForSender") public List<PlatformTransactionManager> jmsTransactionManagerListForSender() { logMessage(" -> jmsTransactionManagerListForSender() "+this.getClass().getName()); List<PlatformTransactionManager> loPlatformTransactionManagerList = new LinkedList<PlatformTransactionManager>(); JmsTransactionManager loJmsTransactionManager = null; try { List<CachingConnectionFactory> loCacheConnFactoryList = bddCachingMQConnectionFactoryListForSender(); ListIterator<CachingConnectionFactory> loCacheConFactoryListIter = loCacheConnFactoryList.listIterator(); while (loCacheConFactoryListIter.hasNext()) { CachingConnectionFactory loCachingConnectionFactory = loCacheConFactoryListIter.next(); loJmsTransactionManager = new JmsTransactionManager(loCachingConnectionFactory); loPlatformTransactionManagerList.add(loJmsTransactionManager); }//eof while } catch (Exception aException) { aException.printStackTrace(); throw new VanquishRuntimeException(aException); } logMessage(" <- jmsTransactionManagerListForSender() "+this.getClass().getName()); return loPlatformTransactionManagerList; }//eof jmsTransactionManagerListForSender
/** *
-
@return */ @Bean(name = "clusteredJmsTemplateModelListForSender") public List<JmsTemplateModel> clusteredJmsTemplateModelListForSender() { logMessage(" -> clusteredJmsTemplateModelListForSender() "+this.getClass().getName()); List<JmsTemplateModel> loJmsTemplateModelList = new LinkedList<JmsTemplateModel>(); try { List<CachingConnectionFactory> loCacheConnFactoryList = bddCachingMQConnectionFactoryListForSender(); ListIterator<CachingConnectionFactory> loCacheConFactoryListIter = loCacheConnFactoryList.listIterator(); List<PlatformTransactionManager> loPlatformTransactionManagerList = jmsTransactionManagerListForSender(); int count = 0; while (loCacheConFactoryListIter.hasNext()) { CachingConnectionFactory loCachingConnectionFactory = loCacheConFactoryListIter.next(); Long loTimeOut = getAsLong(jmsProperties.receiveTimeout, RECEIVE_TIME_OUT);
logMessage(" loTimeOut -> "+loTimeOut); logMessage(" count -> "+count); PlatformTransactionManager loPlatformTransactionManager = loPlatformTransactionManagerList.get(count); JmsTransactionManager loJmsTransactionManager = (JmsTransactionManager) loPlatformTransactionManager; logMessage("loCachingConnectionFactory -> "+loCachingConnectionFactory); logMessage("loJmsTransactionManager -> "+loJmsTransactionManager); JmsTemplate loJmsTemplate = new JmsTemplate(loCachingConnectionFactory); loJmsTemplate.setPubSubDomain(false); loJmsTemplate.setDeliveryPersistent(true); loJmsTemplate.setReceiveTimeout(loTimeOut); boolean lbSessionTranscated = getAsBoolean(jmsProperties.sessionTranscated); logMessage("lbSessionTranscated -> "+lbSessionTranscated); loJmsTemplate.setSessionTransacted(lbSessionTranscated); JmsTemplateModel loJmsTemplateModel = new JmsTemplateModel(); loJmsTemplateModel.setJmsTemplate(loJmsTemplate); loJmsTemplateModel.setCachingConnectionFactory(loCachingConnectionFactory); loJmsTemplateModel.setPlatformTransactionManager(loJmsTransactionManager); loJmsTemplateModelList.add(loJmsTemplateModel); count = count + 1; }//eof while
} catch (Exception aException) { aException.printStackTrace(); throw new VanquishRuntimeException(aException); } logMessage(" <- clusteredJmsTemplateModelListForSender() "+this.getClass().getName()); return loJmsTemplateModelList; } // eof clusteredJmsTemplateModelListForSender
/** *
- @param aClassName
- @param aListenerContainerModel
- @param aPlatformTransactionManager
- @return */ @Bean(name = "bddClusteredMessageListener") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public ClusteredBDDMessageListenerImpl bddMessageListener(String aClassName, ClusteredListenerContainerModel aListenerContainerModel, PlatformTransactionManager aPlatformTransactionManager) { ClusteredBDDMessageListenerImpl loBDDMessageListener = null; try { Object loObject = Class.forName(aClassName).newInstance(); ClusteredMessageListener loClusteredMessageListener = (ClusteredMessageListener) loObject; loBDDMessageListener = new ClusteredBDDMessageListenerImpl(loClusteredMessageListener, aListenerContainerModel, aPlatformTransactionManager); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException eException) { eException.printStackTrace(); throw new VanquishRuntimeException(eException); } return loBDDMessageListener; }//bddMessageListener
/** *
- @return */ @Bean(name = "bddClusteredlistenerContainers") public ClusteredListenerContainers bddClusteredlistenerContainers(List<ClusteredListenerContainerModel> aClusteredListenerContainerModelList) { ClusteredListenerContainers loListenerContainers = new ClusteredListenerContainersImpl(aClusteredListenerContainerModelList); return loListenerContainers; }//eof listenerContainers
/** *
-
@param aMaxConcurrency
-
@param aMinConcurrency
-
@param aCachingConnectionFactory
-
@param aPlatformTransactionManager
-
@return */ @Bean(name = "bddClusteredJmsListenerContainerFactory") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public DefaultJmsListenerContainerFactory bddJmsListenerContainerFactory(String aMaxConcurrency, String aMinConcurrency, CachingConnectionFactory aCachingConnectionFactory, PlatformTransactionManager aPlatformTransactionManager) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); factory.setConnectionFactory(aCachingConnectionFactory); factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER); String lsConcurrency = aMinConcurrency + "-" + aMaxConcurrency; factory.setConcurrency(lsConcurrency); boolean lbSessionTranscated = getAsBoolean(jmsProperties.sessionTranscated); logMessage("lbSessionTranscated -> "+lbSessionTranscated); factory.setSessionTransacted(lbSessionTranscated); factory.setAutoStartup(AUTO_STARTUP); factory.setErrorHandler(vanquishErrorHandler()); Long loTimeOut = getAsLongValue(jmsProperties.listenerReceiveTimeout); if (loTimeOut.longValue() > 0) factory.setReceiveTimeout(loTimeOut);
String lsCacheConsumerEnabled = getStringValue(jmsProperties.cacheConsumerEnabled); if (isEnabled(lsCacheConsumerEnabled)) factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
factory.setTransactionManager(aPlatformTransactionManager);
return factory; }// eof bddJmsListenerContainerFactory
/** *
- @param aListString
- @return */ private boolean isEmptyStringList(List<String> aListString) { if (aListString == null) return true; if (aListString.size()==0) return true; return false; }//eof isEmptyStringList
/** *
- @param aListInteger
- @return */ private boolean isEmptyIntegerList(List<Integer> aListInteger) { if (aListInteger == null) return true; if (aListInteger.size()==0) return true; return false; }//eof isEmptyIntegerList
/** *
-
@return */ @Bean(name = "bddClusteredListenerContainerList") public List<ClusteredListenerContainerModel> bddListenerContainerList() { List<ClusteredListenerContainerModel> loMainContainerList = new LinkedList<ClusteredListenerContainerModel>();
ClusteredListenerContainersImpl loListenerContainersImpl = (ClusteredListenerContainersImpl) bddClusteredlistenerContainers(loMainContainerList);
//loListenerContainersImpl.setClusteredListenerContainerModelList(loMainContainerList);
List<String> loQueueNamesList = getAsListString(jmsProperties.queueNamesList); logMessage(" loQueueNamesList -> "+loQueueNamesList); if (isEmptyStringList(loQueueNamesList)) return loMainContainerList;
List<String> loListenerClassesList = getAsListString(jmsProperties.queueListenerClasses); logMessage(" loListenerClassesList -> "+loListenerClassesList); if (isEmptyStringList(loListenerClassesList)) return loMainContainerList;
List<Integer> loConcurrencyList = getAsListInteger(jmsProperties.queueConcurrencyNumberList); logMessage(" loConcurrencyList -> "+loConcurrencyList); if (isEmptyIntegerList(loConcurrencyList)) return loMainContainerList;
List<Integer> loMaxConcurrentConsumerList = getAsListInteger(jmsProperties.maxConcurrentConsumers); List<Integer> loIdleTaskExeLimitList = getAsListInteger(jmsProperties.idleTaskExecutionLimit); List<Integer> loIdleConsumerLimitList = getAsListInteger(jmsProperties.idleConsumerLimit); List<Integer> loConcurrentConsumerList = getAsListInteger(jmsProperties.concurrentConsumers); List<Integer> loMaxMsgPerTaskList = getAsListInteger(jmsProperties.maxMessagePerTask); List<String> loMinConsumerList = getAsListString(jmsProperties.minConcurrentConsumers);
logMessage(" loMaxConcurrentConsumerList -> "+loMaxConcurrentConsumerList); logMessage(" loIdleTaskExeLimitList -> "+loIdleTaskExeLimitList); logMessage(" loIdleConsumerLimitList -> "+loIdleConsumerLimitList); logMessage(" loConcurrentConsumerList -> "+loConcurrentConsumerList); logMessage(" loMaxMsgPerTaskList -> "+loMaxMsgPerTaskList); logMessage(" loMinConsumerList -> "+loMinConsumerList);
ListIterator<String> loQueueNameListIter = loQueueNamesList.listIterator();
int liIndex = 0; while (loQueueNameListIter.hasNext()) { String lsQueueName = loQueueNameListIter.next();
lsQueueName = getStringValue(lsQueueName); if (lsQueueName.length()==0) return loMainContainerList; logMessage(" lsQueueName -> "+lsQueueName); Integer loMaxConcurrency = loConcurrencyList.get(liIndex); if (loMaxConcurrency == null) loMaxConcurrency = new Integer(1); logMessage(" loMaxConcurrency -> "+loMaxConcurrency); String lsMaxConcurrency = String.valueOf(loMaxConcurrency); logMessage(" lsMaxConcurrency -> "+lsMaxConcurrency); String lsMinConsumers = loMinConsumerList.get(liIndex); logMessage(" lsMinConsumers -> "+lsMinConsumers); Integer loMaxConcurrentConsumer = getIntegerFromTheList(loMaxConcurrentConsumerList,liIndex); Integer loIdleTaskExeLimit = getIntegerFromTheList(loIdleTaskExeLimitList,liIndex); Integer loIdleConsumerLimit = getIntegerFromTheList(loIdleConsumerLimitList,liIndex); Integer loConcurrentConsumer= getIntegerFromTheList(loConcurrentConsumerList,liIndex); Integer loMaxMsgPerTask = getIntegerFromTheList(loMaxMsgPerTaskList,liIndex); logMessage(" loMaxConcurrentConsumer -> "+loMaxConcurrentConsumer); logMessage(" loIdleTaskExeLimit -> "+loIdleTaskExeLimit); logMessage(" loIdleConsumerLimit -> "+loIdleConsumerLimit); logMessage(" loConcurrentConsumer -> "+loConcurrentConsumer); logMessage(" loMaxMsgPerTask -> "+loMaxMsgPerTask); for (String lsClassName : loListenerClassesList) { lsClassName = getStringValue(lsClassName); logMessage(" lsQueueName -> "+lsQueueName); List<CachingConnectionFactory> loCachingConnectionFactoryList = bddCachingMQConnectionFactoryListForListener(); ListIterator<CachingConnectionFactory> loCachConnFactListIter = loCachingConnectionFactoryList.listIterator(); List<PlatformTransactionManager> loPlatformTransactionManagerList = jmsTransactionManagerListForListener(); int loCount = 0; while (loCachConnFactListIter.hasNext()) { CachingConnectionFactory loCachingConnectionFactory = loCachConnFactListIter.next(); PlatformTransactionManager loPlatformTransactionManager = loPlatformTransactionManagerList.get(loCount); ClusteredListenerContainerModel loListenerContainerModel = new ClusteredListenerContainerModel(); loListenerContainerModel.setPlatformTransactionManager(loPlatformTransactionManager); loListenerContainerModel.setQueueName(lsQueueName); //Start of newly added code List<String> loChannelList = getClusteredMQChannelList(); List<String> loQMList = getClusteredMQQueueManagerList(); String lsChannelName = loChannelList.get(loCount); String lsQueueManagerName = loQMList.get(loCount); logMessage(" lsChannelName -> "+lsChannelName); logMessage(" lsQueueManagerName -> "+lsQueueManagerName); loListenerContainerModel.setCachingConnectionFactory(loCachingConnectionFactory); loListenerContainerModel.setChannelName(lsChannelName); loListenerContainerModel.setQueueManagerName(lsQueueManagerName); //End of newly added code DefaultJmsListenerContainerFactory loListenerContainerFactory = bddJmsListenerContainerFactory(lsMaxConcurrency, lsMinConsumers, loCachingConnectionFactory, loPlatformTransactionManager); MQQueueConnectionFactory loMQQueueConnectionFactory = (MQQueueConnectionFactory) loCachingConnectionFactory.getTargetConnectionFactory(); String lsHostName = loMQQueueConnectionFactory.getHostName(); loListenerContainerModel.setHostName(lsHostName); ClusteredBDDMessageListenerImpl loBDDMessageListenerImpl = bddMessageListener(lsClassName,loListenerContainerModel, loPlatformTransactionManager); SimpleJmsListenerEndpoint loEndPoint = new SimpleJmsListenerEndpoint(); loEndPoint.setMessageListener(loBDDMessageListenerImpl); loEndPoint.setDestination(lsQueueName); DefaultMessageListenerContainer loListenerContainer = loListenerContainerFactory. createListenerContainer(loEndPoint); loListenerContainer.setMaxConcurrentConsumers(loMaxConcurrentConsumer); loListenerContainer.setConcurrentConsumers(loConcurrentConsumer); loListenerContainer.setIdleTaskExecutionLimit(loIdleTaskExeLimit); loListenerContainer.setMaxMessagesPerTask(loMaxMsgPerTask); loListenerContainer.setIdleConsumerLimit(loIdleConsumerLimit); loListenerContainer.setAcceptMessagesWhileStopping(false); loListenerContainer.setExceptionListener(vanquishExceptionListener()); loListenerContainerModel.setDefaultMessageListenerContainer(loListenerContainer); loListenerContainerModel.setBDDMessageListenerImpl(loBDDMessageListenerImpl); loListenerContainersImpl.addListenerContainerModel(loListenerContainerModel); loMainContainerList.add(loListenerContainerModel); loCount = loCount + 1; }//eof inner while going for next QM }//eof for going for next listener class liIndex = liIndex + 1;
}//eof while //going for next queue //register listener containers loListenerContainersImpl = (ClusteredListenerContainersImpl) bddClusteredlistenerContainers(loMainContainerList); loListenerContainersImpl.activateListeners(); return loMainContainerList; } // eof bddListenerContainerList
/** *
-
@param aStringValue
-
@return */ private Long getAsLong(String aStringValue, long aValue) { logMessage(" -> getAsLong() "+this.getClass().getName()); Long loLongValue = new Long(aValue); if (aStringValue == null) return loLongValue; if (aStringValue.trim().length() == 0) return loLongValue;
String lsStringValue = aStringValue.trim(); loLongValue = Long.parseLong(lsStringValue); logMessage(" <- getAsLong() "+this.getClass().getName()); return loLongValue; }//eof getAsLong
/** *
- @param aString
- @return */ private String getStringValue(String aString) { String lsString = aString; if (lsString == null) return EMPTY; lsString = lsString.trim(); return lsString; }//eov getStringValue
/** *
- @return */ @Bean("jacksonClusteredJmsMessageConverter") public MessageConverter jacksonJmsMessageConverter() { logMessage(" -> jacksonJmsMessageConverter() "+this.getClass().getName()); MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); converter.setTargetType(MessageType.TEXT); converter.setTypeIdPropertyName("_type"); logMessage(" <- jacksonJmsMessageConverter() "+this.getClass().getName()); return converter; }//eof jacksonJmsMessageConverter
/** *
- @param aStringValue
- @return */ private String getDecryptedText(String aStringValue) { String lsEncrypted = getStringValue(jmsProperties.sslPassPhraseEncrypted); if (!isEnabled(lsEncrypted)) return aStringValue; String lsDecryptedText = decryptionService.decryptBase64StringToText(aStringValue); return lsDecryptedText; }//eof getDecryptedText
/** *
- @param aValue
- @return */ private boolean isEnabled(String aValue) { String lsValue = EMPTY; lsValue = aValue; if (lsValue == null) lsValue = EMPTY; lsValue = lsValue.trim(); if (lsValue.equalsIgnoreCase(TRUE)) return true; if (lsValue.equalsIgnoreCase(YES)) return true; return false; }//eof isEnabled
/*
-
@param aStringValue
-
@return */ private List<String> getAsListString(String aStringValue) { logMessage(" -> getAsListString() "+this.getClass().getName()); List<String> loStringValueList = new LinkedList<String>(); if (aStringValue == null) return loStringValueList; if (aStringValue.trim().length() == 0) return loStringValueList;
StringTokenizer loTokenizer = new StringTokenizer(aStringValue, COMMA);
while (loTokenizer.hasMoreTokens()) { String lsToken = loTokenizer.nextToken(); if (lsToken != null) lsToken = lsToken.trim(); loStringValueList.add(lsToken); }//eof while logMessage(" <- getAsListString() "+this.getClass().getName()); return loStringValueList; }//eof getAsListString
/** *
- @param aStringList
- @param aIndex
- @return */ private String getStringFromTheList(List<String> aStringList, int aIndex) { logMessage(" aStringList -> "+aStringList); if (aStringList == null) throw new VanquishRuntimeException(EMPTY_VALUE_PROVIDED); int liCurrentIndex = aIndex; int liSize = aStringList.size(); liSize = liSize - 1; if (liSize == 0) return EMPTY; //Let us take the first one if not provided if (liCurrentIndex > liSize) liCurrentIndex = 0; String lsStringValue = aStringList.get(liCurrentIndex); if (lsStringValue == null) lsStringValue = EMPTY; lsStringValue = lsStringValue.trim(); return lsStringValue; }//eof getStringFromTheList
/** *
- @param aIntegerList
- @param aIndex
- @return */ private Integer getIntegerFromTheList(List<Integer> aIntegerList, int aIndex) { logMessage(" aIntegerList -> "+aIntegerList); if (aIntegerList == null) throw new VanquishRuntimeException(EMPTY_VALUE_PROVIDED); int liCurrentIndex = aIndex; int liSize = aIntegerList.size(); liSize = liSize - 1; //if (liSize == 0) throw new VanquishRuntimeException(EMPTY_VALUE_PROVIDED); //Let us take the first one if not provided if (liCurrentIndex > liSize) liCurrentIndex = 0; Integer lsIntegerValue = aIntegerList.get(liCurrentIndex); return lsIntegerValue; }//eof getIntegerFromTheList
/** *
-
@param aStringValue
-
@return */ private List<String> getAsListStringWithSemicolon(String aStringValue) { logMessage(" -> getAsListStringWithSemicolon() "+this.getClass().getName()); List<String> loStringValueList = new LinkedList<String>(); if (aStringValue == null) return loStringValueList; if (aStringValue.trim().length() == 0) return loStringValueList;
StringTokenizer loTokenizer = new StringTokenizer(aStringValue, SEMICOLON);
while (loTokenizer.hasMoreTokens()) { String lsToken = loTokenizer.nextToken(); loStringValueList.add(lsToken); }//eof while logMessage(" <- getAsListStringWithSemicolon() "+this.getClass().getName()); return loStringValueList; }//eof getAsListString
/** *
-
@param aStringValue
-
@return */ private List<Integer> getAsListInteger(String aStringValue) { logMessage(" -> getAsListInteger() "+this.getClass().getName()); List<Integer> loIntegerValueList = new LinkedList<Integer>(); if (aStringValue == null) return loIntegerValueList; if (aStringValue.trim().length() == 0) return loIntegerValueList;
StringTokenizer loTokenizer = new StringTokenizer(aStringValue, COMMA);
while (loTokenizer.hasMoreTokens()) { String lsToken = loTokenizer.nextToken(); if (lsToken != null)lsToken = lsToken.trim(); Integer loTokenInt = Integer.parseInt(lsToken); loIntegerValueList.add(loTokenInt); }//eof while logMessage(" <- getAsListInteger() "+this.getClass().getName()); return loIntegerValueList; }//eof getAsListString
/** *
-
@param aStringValue
-
@return */ private Long getAsLongValue(String aStringValue) { Long loLongValue = new Long(-1); if (aStringValue == null) return loLongValue; if (aStringValue.trim().length() == 0) return loLongValue;
String lsLongString = aStringValue.trim(); loLongValue = new Long(Long.parseLong(lsLongString)); return loLongValue; }//eof getAsListString
/** *
- @param aStringValue
- @return */ private boolean getAsBoolean(String aStringValue) { if (aStringValue == null) aStringValue = EMPTY; aStringValue = aStringValue.trim(); if (aStringValue.equalsIgnoreCase(TRUE)) return true; if (aStringValue.equalsIgnoreCase(YES)) return true; return false; }//eof getAsBoolean
/**
- Log message method used to log the messages from.
- @param lsMessage - log messages. */ private void logMessage(String lsMessage) { LOGGER.info(lsMessage); }
}