java - Camel routing XML with JMS/ActiveMQ -
i trying larn how integrate jms/activemq spring xml based routing in camel. trying post simple message activemq topic , using routing in camel move queue endpoint log message console sent.
it seems simple plenty having issues far it. able post message queue using java class problem lies route not picking message , logging screen, post re-create of java class posting topic , re-create of route using.
any help or tips appreciated, if there improve way of doing activemq more open suggestions. give thanks you!
package com.backend; import javax.jms.*; import org.apache.activemq.activemqconnection; import org.apache.activemq.activemqconnectionfactory; public class testmessageproducer { private static string url = activemqconnection.default_broker_url; public static void main(string[] args) throws jmsexception { connectionfactory connectionfactory = new activemqconnectionfactory(url); connection connection = connectionfactory.createconnection(); connection.start(); session session = connection.createsession(false, session.auto_acknowledge); topic topic = session.createtopic("my.testemail"); messageproducer producer = session.createproducer(topic); // send text message'hello jms' textmessage message = session.createtextmessage(); message.settext("hello jms"); producer.send(message); system.out.println("sent message '" + message.gettext() + "'"); connection.close(); }
} route below <?xml version="1.0" encoding="utf-8"?> <spring:beans xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://camel.apache.org/schema/spring" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:alch="http://service.alchemy.kobie.com/" xsi:schemalocation="http://www.springframework.org/schema/beans classpath:meta-inf/spring/spring-beans.xsd http://camel.apache.org/schema/spring classpath:meta-inf/spring/camel-spring.xsd"> <!-- load properties activemq --> <spring:bean id="jmsconnectionfactory" class="org.apache.activemq.activemqconnectionfactory"> <spring:property name="brokerurl" value="tcp://localhost:8161" /> </spring:bean> <spring:bean id="pooledconnectionfactory" class="org.apache.activemq.pool.pooledconnectionfactory" init-method="start" destroy-method="stop"> <spring:property name="maxconnections" value="8" /> <spring:property name="maximumactive" value="500" /> <spring:property name="connectionfactory" ref="jmsconnectionfactory" /> </spring:bean> <spring:bean id="jmsconfig" class="org.apache.camel.component.jms.jmsconfiguration"> <spring:property name="connectionfactory" ref="pooledconnectionfactory"/> <spring:property name="transacted" value="false"/> <spring:property name="concurrentconsumers" value="10"/> </spring:bean> <spring:bean id="activemq" class="org.apache.activemq.camel.component.activemqcomponent"> <spring:property name="configuration" ref="jmsconfig"/> </spring:bean> <!-- http client configure --> <spring:bean id="httpconfig" class="com.backend.httpconfig"> <spring:property name="sotimeout" value="5000" /> <spring:property name="connectiontimeout" value="5000" /> <spring:property name="retries" value="0" /> </spring:bean> <!-- camel configuration --> <camelcontext xmlns="http://camel.apache.org/schema/spring"> <route id="queuetotarget" streamcache="true"> <from uri = "activemq:topic:my.testemail" /> <to uri = "seda:etintegration" /> </route> <route> <from uri = "seda:etintegration" /> <log message="received : ${in.body}" /> </camelcontext>
java jms activemq apache-camel
No comments:
Post a Comment