java - Spring Integration: send object in json to jms -


i'm bit confused , need clarification:

i'm trying transform object in json , send using jms each second.

here context.xml:

<bean id="connectionfactory"     class="org.springframework.jms.connection.cachingconnectionfactory">     <property name="targetconnectionfactory">         <bean class="org.apache.activemq.activemqconnectionfactory">             <property name="brokerurl" value="tcp://localhost:61616" />         </bean>     </property>     <property name="sessioncachesize" value="10" /> </bean> <bean id="requesttopic" class="org.apache.activemq.command.activemqtopic">     <constructor-arg value="testconf" /> </bean>  <bean id="confbean" class="demo.deviceconfiguration">     <property name="id" value="thermo_001" />     <property name="name" value="thermometer" /> </bean>  <int:channel id="deadchannel"/> <int:channel id="outboundchannel"/> <int:channel id="objecttojsonchannel" /> <int:channel id="outjmschannel" /> <int:channel id="requestchannel"/>  <int:gateway id="gateway"     default-request-timeout="5000"     default-reply-timeout="5000"     default-request-channel="requestchannel"     service-interface="demo.serviceconfgateway"> </int:gateway>  <int:payload-type-router input-channel="requestchannel" default-output-channel="deadchannel">     <int:mapping type="demo.deviceconfiguration" channel="objecttojsonchannel"/> </int:payload-type-router>  <int:object-to-json-transformer input-channel="objecttojsonchannel" output-channel="outjmschannel" />  <int-jms:outbound-channel-adapter id="jmsout" channel="outjmschannel" destination="requesttopic" /> 

in main class, i'm doing this:

    springapplication.run(demojmsapplication.class, args);     applicationcontext ctx = new classpathxmlapplicationcontext("context.xml");     final deviceconfiguration dc = ctx.getbean(deviceconfiguration.class);     final serviceconfgateway service = ctx.getbean(serviceconfgateway.class);      while (true) {         service.send(dc);         thread.sleep(1000);     } 

do need loop in main class? working think simplify it.

you can achieve same

<inbound-channel-adapter channel="requestchannel" expression="@dc">    <poller fixed-delay="1000"/> </inbound-channel-adapter> 

with don't need <payload-type-router> , <gateway> anymore because send need.

from other side: simpler ask?..


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -