optimization - High Efficient MDB using spring jms or ntegration -
i have requirement need receive message mq every seconds , message in xml format , need write high effecient mdb. problem here new mq,jms,spring jms , spring integration not spring tough.
based on google search far able write below code
mdb
import javax.jms.message; import javax.jms.messagelistener; import javax.jms.textmessage; public class mymessagelistener implements messagelistener{ @override public void onmessage(message m) { textmessage message=(textmessage)m; try{ system.out.println(message.gettext()); }catch (exception e) {e.printstacktrace(); } } }
xml config
<?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:jms="http://www.springframework.org/schema/jms" xmlns:p="http://www.springframework.org/schema/p" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd"> <bean id="connectionfactory" class="org.apache.activemq.activemqconnectionfactory" p:brokerurl="tcp://localhost:61616" /> <bean id="listener" class="com.springexample.mymessagelistener"></bean> <jms:listener-container container-type="default" connection-factory="connectionfactory" acknowledge="auto"> <jms:listener destination="myfirstqueue" ref="listener" method="onmessage"></jms:listener> </jms:listener-container> </beans>
i know have written basic 1 dont know efficient 1 , how provide transaction support , how handle such load going recieve message every seconds.
should use spring jms or spring integration appreciated.
the question asked use: go spring jms
Comments
Post a Comment