java - Using Spring integration for messaging between two classes in the same application -


i trying pass string messages 1 class (from class1 class2) within same application trying solve using spring integration.

my context.xml file looks below:

    <?xml version="1.0" encoding="utf-8"?>     <beans xmlns="http://www.springframework.org/schema/beans"       xmlns:p="http://www.springframework.org/schema/p"       xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"       xmlns:context="http://www.springframework.org/schema/context"       xsi:schemalocation="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-3.1.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"         xmlns:int="http://www.springframework.org/schema/integration"       xmlns:int-jms="http://www.springframework.org/schema/integration/jms">      <int:channel id="processempchannel">         <int:queue/>     </int:channel>      <int-jms:inbound-channel-adapter         channel="processempchannel" connection-factory="connectionfactory"         destination-name="empqueue">         <int:poller fixed-delay="500" />     </int-jms:inbound-channel-adapter>      <bean id="connectionfactory"         class="org.springframework.jms.connection.cachingconnectionfactory">         <property name="targetconnectionfactory">             <bean class="org.apache.activemq.activemqconnectionfactory">                 <property name="brokerurl" value="vm://localhost?broker.persistent=false" />             </bean>         </property>         <property name="sessioncachesize" value="10" />         <property name="cacheproducers" value="false" />     </bean>     <bean id="jmstemplate" class="org.springframework.jms.core.jmstemplate">         <property name="connectionfactory" ref="connectionfactory" />     </bean>      <bean id="springintexample"         class="com.distributed.analyzer.manager">         <property name="jmstemplate" ref="jmstemplate" />     </bean>      <int:service-activator input-channel="processempchannel" ref="springintexample" method="processmessage">         <int:poller fixed-delay="500"/>     </int:service-activator> </beans> 

class class1:

package com.my.package;  public class class1 implements runnable {           @autowired         private applicationcontext appcontext;         private jmstemplate jmstemplate;          ...          public void somemethod() {              class1 c = (class1) appcontext.getbean("springintexample");              c.send();         }          public void send() {             getjmstemplate().convertandsend("empqueue", "one message test");         }          public jmstemplate getjmstemplate() {             return jmstemplate;         }          public void setjmstemplate(jmstemplate jmstemplate) {             this.jmstemplate = jmstemplate;         }          ...     } 

class class2:

package com.my.package;  public class class2 implements runnable {      ...      public void processmessage(string msg) {          system.out.println("message recived: " + msg);     }      ... } 

problem have:

if open context.xml file, below lines in context.xml marked cross (error):

<int:poller fixed-delay="500" /> 

anyway can build , execute application in run time exception message saying fixe-delay not allowed in int:poller appears.

also, implementation correct? not sure if after solving problem commented work. new in spring sorry.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -