Spring Batch taking too long - spring

i am new spring batch. i recently tried a batch which will read records from file and insert into MariaDB. But for inserting 10k records its taking 2min 30sec.
I know its too much time. Table have only 3 columns without any Keys.
Here is my job-XML
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
">
<import resource="../../context.xml" />
<import resource="../../database.xml" />
<bean id="itemProcessor" class="com.my.sbatch.processors.CustomItemProcessor" />
<batch:job id="file_to_db">
<batch:step id="step1">
<batch:tasklet transaction-manager="transactionManager" start-limit="100">
<batch:chunk reader="cvsFileItemReader"
writer="databaseItemWriter" commit-interval="10">
</batch:chunk>
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="multiResourceReader"
class=" org.springframework.batch.item.file.MultiResourceItemReader">
<property name="resources"
value="file:batch/csv/processing/*.csv" />
<property name="delegate" ref="cvsFileItemReader" />
</bean>
<bean id="mappingBean" class="com.my.sbatch.bean.Batch1Bean"
scope="prototype" />
<bean name="customFieldSetMapper" class="com.my.sbatch.core.CustomFieldSetMapper">
<property name="classObj" ref="mappingBean"/>
</bean>
<bean id="cvsFileItemReader" class="com.my.sbatch.customReader.CustomItemReader" scope="step">
<property name="resource" value="file:#{jobParameters['inputFile']}" />
<property name="lineMapper">
<bean class="com.my.sbatch.core.CustomLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="#{jobParameters['delimiter']}" />
</bean>
</property>
<property name="fieldSetMapper" ref="customFieldSetMapper" />
</bean>
</property>
</bean>
<bean id="databaseItemWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter" scope="step">
<property name="dataSource" ref="dataSource" />
<property name="sql">
<value>
<![CDATA[
#{jobParameters['insert_JobQuery']}
]]>
</value>
</property>
<property name="ItemPreparedStatementSetter">
<bean class="com.my.sbatch.core.CustomPreparedStatement" />
</property>
Here is my context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
<!-- stored job-meta in memory -->
<!--
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
-->
<!-- stored job-meta in database -->
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseType" value="mysql" />
</bean>
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
In com.my.sbatch.core.CustomFieldSetMapper, com.my.sbatch.core.CustomPreparedStatement classes i am using reflections for mapping fields from File -> bean and Bean -> DB(Prepared statement).
Can you please advice me any solution for why it is taking too much time

In this example, your batch process is executed by a single thread. This may be the reason it takes so long. I recommend you use multhreading with TaskExecutor bean.
For example:
<batch:job id="file_to_db">
<batch:step id="step1">
<batch:tasklet task-executor="taskExecutor" transaction-manager="transactionManager" start-limit="100">
<batch:chunk reader="cvsFileItemReader"
writer="databaseItemWriter" commit-interval="10">
</batch:chunk>
</batch:tasklet>
</batch:step>
This is the simplest solution for multithreading but you may have problems in concurrent environments with access to information.
I recommend that you read this information to see the different scalability strategies.
More information about scalability here

Related

JobRepositoryFactoryBean error spring batch

I started to learn spring batch and I have a problem that when i want to
persist the state of the job in a database using JobRepositoryFactoryBean.
compiler displays :
"Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository' defined in class path resource [springConfig.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/simple/ParameterizedRowMapper"
but not error when i use MapJobRepositoryFactoryBean
I'm using spring 5
springconfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<context:component-scan base-package="springbatch" />
<context:annotation-config />
<bean id="personneReaderCSV" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="input/personnes.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="," />
<property name="names" value="id,nom,prenom,civilite" />
</bean>
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="targetType" value="springbatch.entities.Personne" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean name="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/spring_test" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>springbatch.entities.Personne</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<job id="importPersonnes" xmlns="http://www.springframework.org/schema/batch">
<step id="readWritePersonne">
<tasklet>
<chunk reader="personneReaderCSV"
processor="personProcessor"
writer="personWriter"
commit-interval="2" />
</tasklet>
</step>
</job>
<bean id="daoPersonne" class="springbatch.dao.PersonneDaoImp">
<property name="factory" ref="sessionFactory"></property>
</bean>
<bean id="personWriter" class="springbatch.batch.PersonneWriter">
<property name="dao" ref="daoPersonne"></property>
</bean>
<bean id="personProcessor" class="springbatch.batch.PersonneProcess">
</bean>
<bean id="batchLauncher" class="springbatch.MyBean">
</bean>
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseType" value="Mysql" />
</bean>
<task:scheduled-tasks>
<task:scheduled ref="batchLauncher" method="message"
cron=" 59 * * * * * " />
</task:scheduled-tasks>
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="org/springframework/batch/core/schema-drop-mysql.sql" />
<jdbc:script location="org/springframework/batch/core/schema-mysql.sql" />
</jdbc:initialize-database>
</beans>
but not error when i use :
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
You are using Spring Batch v2.2 with Spring Framework 5. That's not going to work properly as ParameterizedRowMapper has been removed in Spring Framework 4.2+ (hence the exception).
I recommend that you use Spring Batch v4.1 (since v2.x is not maintained anymore) and your issue should be fixed.
The best way to manage Spring dependencies is to let Spring Boot do it for you either by generating a project from start.spring.io or by using the Spring Boot BOM. With both ways, you will have the correct Spring projects dependencies that are known to work well together.

Organizing Spring Batch Jobs

I would like to add a Spring Batch module to Java 1.8, Maven 3.3.3 project for running batch jobs.
The module(s) should be a Maven child
of this parent:
<parent>
<artifactId>portfolio-service-parent</artifactId>
<groupId>com.distributedfinance</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
At the moment I have three separate batch jobs. Is it better to organize all the batch jobs into one XML config file? Have three distinct modules each with it's own config file? One module with three distinct config files?
Thanks!
Here's the config file for the complex job:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/spring-util.xsd">
<bean name="jobParametersIncrementer" class="org.springframework.batch.core.launch.support.RunIdIncrementer"/>
<!-- BATCH-2351 workaround -->
<bean id="stepScope" class="org.springframework.batch.core.scope.StepScope">
<property name="autoProxy" value="true"/>
</bean>
<batch:job id="baiParseJob" incrementer="jobParametersIncrementer">
<batch:step id="baiParseStep" next="baiArchive">
<batch:tasklet transaction-manager="transactionManager">
<batch:chunk reader="baiItemReader"
processor="baiItemProcessor"
writer="baiItemWriter"
commit-interval="1"/>
</batch:tasklet>
</batch:step>
<batch:step id="baiArchive">
<batch:tasklet ref="fileArchivingTasklet"/>
</batch:step>
</batch:job>
<bean id="baiItemReader" class="com.distributedfinance.mbi.bai.reader.MultiLineBaiItemReader"
scope="step">
<property name="delegate" ref="flatFileItemReader"/>
<property name="baiFileFieldSetMapper">
<bean class="com.distributedfinance.mbi.bai.mapper.BaiFileFieldSetMapper"/>
</property>
<property name="baiGroupFieldSetMapper">
<bean class="com.distributedfinance.mbi.bai.mapper.BaiGroupFieldSetMapper"/>
</property>
<property name="baiAccountFieldSetMapper">
<bean class="com.distributedfinance.mbi.bai.mapper.BaiAccountFieldSetMapper">
<property name="parser">
<bean class="com.distributedfinance.mbi.bai.mapper.BaiTypeParser"/>
</property>
</bean>
</property>
<property name="baiTransactionFieldSetMapper">
<bean class="com.distributedfinance.mbi.bai.mapper.BaiTransactionFieldSetMapper"/>
</property>
</bean>
<bean id="flatFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
<property name="resource" value="#{jobParameters['input.file.url']}"/>
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"/>
</property>
<property name="fieldSetMapper">
<bean class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper"/>
</property>
</bean>
</property>
</bean>
<bean id="baiItemProcessor" class="com.distributedfinance.mbi.bai.processor.BaiItemProcessor">
<constructor-arg index="0" ref="accountLookup"/>
<constructor-arg index="1">
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyMMddHHmmss"/>
</bean>
</constructor-arg>
</bean>
<bean id="baiItemWriter" class="com.distributedfinance.mbi.bai.writer.BaiItemWriter"/>
<bean id="accountLookup" class="com.distributedfinance.mbi.bai.lookup.AccountLookup"/>
<bean id="fileArchivingTasklet" class="com.distributedfinance.mbi.bai.tasklet.FileArchivingTasklet">
<property name="downloadFileKey" value="input.file.url"/>
<property name="archiveDirectory" value="${bai.sftp.archive-dir}"/>
<property name="purgeDays" value="${bai.sftp.purge-days}"/>
</bean>
</beans>

MultiResourcePartitioning same speed as without partitioning in spring batch

Batch Job:
read from a txt file(50k records)
split it into 10 txt files(5k records each)
for each record in the txt create an xml file
The problem is that the same job without the splitting-partitioning(reading from original txt) takes the same amount of time
My configuration:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:batch="http://www.springframework.org/schema/batch" xmlns:task="http://www.springframework.org/schema/task"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<!-- My beans -->
<bean id="task" class="com.example.model.MyModel" scope="prototype" />
<bean id="noInputException" class="com.example.listener.NoWorkFoundStepExecutionListener"/>
<bean id="idNameListener" class="com.example.listener.IdNameListener">
<property name="mriw" ref="multiResourceItemWriter"></property>
</bean>
<bean id="txtsuffix" class="com.example.filename.TxtSuffix"/>
<bean id="headerCallback" class="com.example.listener.HeaderCallBack"/>
<bean id="partitioner"
class="org.springframework.batch.core.partition.support.MultiResourcePartitioner"
scope="step">
<property name="keyName" value="inputFile" />
<property name="resources" value="file:../xml/xmlfiles/*.txt" />
</bean>
<bean id="taskExecutor" class="org.springframework.core.task.SyncTaskExecutor" >
</bean>
<!--<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="10" />
<property name="maxPoolSize" value="10" />
</bean>-->
<!-- Batch Job declaration -->
<batch:job id="txttoxml">
<batch:step id="step1" next="step2master">
<batch:tasklet>
<batch:chunk reader="fileReader" writer="TXTExporter" commit-interval="1000">
</batch:chunk>
<batch:listeners>
<batch:listener ref="noInputException"/>
<batch:listener ref="idNameListener"/>
</batch:listeners>
</batch:tasklet>
</batch:step>
<batch:step id="step2master">
<partition step="step2" partitioner="partitioner">
<handler grid-size="10" task-executor="taskExecutor"/>
</partition>
</batch:step>
</batch:job>
<batch:step id="step2">
<batch:tasklet>
<batch:chunk reader="fileReaderstep2" writer="multiResourceItemWriter" commit-interval="1">
</batch:chunk>
<batch:listeners>
<batch:listener ref="noInputException"/>
<batch:listener ref="idNameListener"/>
</batch:listeners>
</batch:tasklet>
</batch:step>
<!-- step1 writer -->
<bean id="TXTExporter"
class="org.springframework.batch.item.file.MultiResourceItemWriter">
<property name="resource" value="file:../xml/xmlfiles/xml"></property>
<property name="delegate" ref="flatFileItemWriter"></property>
<property name="itemCountLimitPerResource" value="5000"/>
<property name="resourceSuffixCreator" ref="xmlsuffix"/>
</bean>
<bean id="flatFileItemWriter"
class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="lineAggregator">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<property name="delimiter" value="£"/>
<property name="fieldExtractor">
<bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<property name="names" value="ID,TYPE,NAME,DATESTARTED,DATEENDED" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="fileReaderstep2"
class="org.springframework.batch.item.file.FlatFileItemReader"
autowire-candidate="false" scope="step">
<property name="resource" value="#{stepExecutionContext[inputFile]}" />
<property name="lineMapper" ref="lineMapper"/>
</bean>
<bean id="multiResourceItemWriter"
class="org.springframework.batch.item.file.MultiResourceItemWriter">
<property name="resource" value="file:../xml/P" />
<property name="delegate" ref="XMLwriter"/>
<property name="itemCountLimitPerResource" value="1"/>
</bean>
<bean id="XMLwriter"
class="org.springframework.batch.item.xml.StaxEventItemWriter">
<property name="marshaller" ref="taskUnmarshaller" />
<property name="rootTagName" value="Task" />
</bean>
<bean id="taskUnmarshaller"
class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="aliases">
<map>
<entry key="Task"
value="com.example.model.MyModel" />
</map>
</property>
</bean>
<!-- txt format -->
<bean id="fileReader"
class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="lineMapper" ref="lineMapper"/>
<property name="resource" value="file:../original.txt"/>
<property name="strict" value="false"/>
<!-- <property name="linesToSkip" value="1"/> -->
</bean>
<bean id="lineMapper"
class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="fieldSetMapper" ref="fieldSetMapper"/>
<property name="lineTokenizer" ref="lineTokenizer"/>
</bean>
<bean id="lineTokenizer"
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="£"/>
<property name="names" value="ID,TYPE,NAME,DATESTARTED,DATEENDED"/>
<property name="strict" value="false"></property>
</bean>
<bean id="fieldSetMapper"
class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="targetType" value="com.example.model.MyModel"/>
</bean>
</beans>
Is there any way to increase performance?

Spring JMS message redelivery is not working

I am not sure what i am missing, when consumer is not able to process messsage it throws JMSException but i see failed messages are not getting redeliver otherwise below code is working fine , please help me what i am missing ?
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-3.0.xsd">
<!-- Use Springs JNDI support to look up JMS Connection Factory and Queue definitions from the
container. This means that specific connection details are not embedded in the application
-->
<bean id="mqConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>vm://localhost:61616</value>
</property>
<property name="nonBlockingRedelivery" value="true"/>
<property name="redeliveryPolicy">
<bean class="org.apache.activemq.RedeliveryPolicy">
<property name="initialRedeliveryDelay" value="5000" />
<property name="backOffMultiplier" value="2" />
<property name="queue" value="*" />
<property name="useExponentialBackOff" value="true" />
<property name="redeliveryDelay" value="5000" />
<property name="maximumRedeliveries" value="20"/>
</bean>
</property>
</bean>
</property>
</bean>
<bean id="mqProducerConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>vm://localhost:61616</value>
</property>
</bean>
</property>
</bean>
<bean id="test_queue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="test_queue" />
</bean>
<bean id="testConsumer" class="com.test.jms.listener.TestConsumer">
</bean>
<bean id="poiMessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref ="mqConnectionFactory" />
<property name="destination" ref ="test_queue"/>
<property name="messageListener" ref ="testConsumer"/>
<property name="concurrentConsumers" value="1" />
<property name="sessionTransacted" value="true"/>
</bean>
<bean id="testProducer" class="com.test.jms.producer.testProducer">
<property name="destination" ref="test_queue"/>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="mqProducerConnectionFactory" />
</bean>
<jms:listener-container
container-type="default"
connection-factory="mqConnectionFactory"
acknowledge="transacted">
<jms:listener destination="test_queue" ref="testConsumer" method="onMessage" />
</jms:listener-container>
</beans>
Above code is working fine but it does not work for message re-delivery

JMS queue with spring

My springcontext-notification XML:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<bean
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="notificationJmsConnectionFactory" />
<property name="destinationName" value="${bpm.task.queue}" />
<property name="messageListener" ref="taskMessageReceiver" />
<property name="sessionTransacted" value="true" />
<property name="clientId" value="BPMTaskMessageLisetners" />
<property name="transactionManager" ref="transactionManager" />
<property name="maxConcurrentConsumers" value="${bpm.task.queue.listener.concurrency}" />
</bean>
<bean id="taskMessageReceiver"
class="com.sterling.ag.jms.impl.TaskMessageListenerImpl">
</bean>
<bean id="notificationJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="notificationJmsConnectionFactory" />
<property name="sessionTransacted" value="true" />
</bean>
<jee:jndi-lookup id="notificationJmsConnectionFactory"
jndi-name="java:/JmsXA">
<!--
<jee:environment>java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory</jee:environment>
-->
</jee:jndi-lookup>
<alias name="notificationJmsTemplate" alias="auditJmsTemplate" />
<alias name="notificationJmsTemplate" alias="historyExchangeJmsTemplate" />
</beans>
I have added another queue. How should i configure it in the above XML??
You need to create a separate container and listener
<bean
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="notificationJmsConnectionFactory" />
<property name="destinationName" value="${bpm.task.queue2}" />
<property name="messageListener" ref="taskMessageReceiver2" />
<property name="sessionTransacted" value="true" />
<property name="clientId" value="BPMTaskMessageLisetners" />
<property name="transactionManager" ref="transactionManager" />
<property name="maxConcurrentConsumers" value="${bpm.task.queue.listener.concurrency2}" />
</bean>
<bean id="taskMessageReceiver2"
class="com.sterling.ag.jms.impl.TaskMessageListenerImpl2">
</bean>

Resources