java - Spring integration - less boilerplate? -
i have started using spring-integration
listening on jms-queues, , it's working satisfactory, have of issue amount of xml-configuration required in order set listener. of boilerplate, changes jms-instance , name of queue listen to, , class , method invoke upon receiving message. here example:
<?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:int="http://www.springframework.org/schema/integration" xmlns:jms="http://www.springframework.org/schema/integration/jms" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd"> <bean id="jms.queue.myqueue" class="org.apache.activemq.command.activemqqueue"> <constructor-arg value="${myapplication.jms.queue.myqueue}" /> </bean> <bean id="jms.container.myjmslistender" class="org.springframework.jms.listener.defaultmessagelistenercontainer" destroy-method="destroy"> <property name="connectionfactory" ref="jmsconnectionfactory" /> <!-- defined elsewhere --> <property name="destination" ref="jms.queue.myqueue" /> <property name="sessiontransacted" value="true" /> </bean> <int:publish-subscribe-channel id="channel.myqueue" /> <jms:message-driven-channel-adapter id="channeladapter.myqueue" container="jms.container.myqueue" channel="channel.myqueue" acknowledge="transacted"/> <int:service-activator id="serviceactivator.myqueue" input-channel="channgel.myqueue" ref="myqueuejmslistener" method="handlemessage" /> </beans>
as can see, lot of config simple, , quite lot of jms-listeners becomes tedious, both read , write.
is there way configure listening queue spring-integration requires less boilerplate? i've looked creating own xml-tag, i'm kinda hoping there simpler solution.
you need external container if need configure properties not exposed on namespace.
<jms:message-driven-channel-adapter id="channeladapter.myqueue" destination="jms.queue.myqueue" connection-factory="jmsconnectionfactory" channel="channel.myqueue" acknowledge="transacted"/>
Comments
Post a Comment