Camel integration with existing web application -
i have web application providing rest full service , standalone (jar) application doing soap request response (using camel)
can give me pointers me how integrate 2 applications
specifically around how kick camel routes when war file deployed in tomcat, , how re-run routes when specific http request arrives.
i using camel dsl (xml) , spring.
update 1: have followed this
checked web.xml has following lines:
<context-param> <param-name>contextclass</param-name> <param-value>org.springframework.web.context.support.annotationconfigwebapplicationcontext</param-value> </context-param> <context-param> <param-name>contextconfiglocation</param-name> <param-value>com.mycompany.server.binder</param-value> </context-param> <context-param> <param-name>log4jconfiglocation</param-name> <param-value>/web-inf/classes/log4j.properties</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener>
created /web-inf/applicationcontext.xml file , put routes , beans in (btw have beans.xml file in src/main/resources getting read spring).
<?xml version="1.0" encoding="utf-8"?> <beans xmlns:camel="http://camel.apache.org/schema/spring" xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://www.springframework.org/schema/beans" xsi:schemalocation=" http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd "> <!-- camel applicationcontext --> <!-- import needed bring in cxf classes --> <import resource="classpath:meta-inf/cxf/cxf.xml" /> <bean id="properties" class="org.apache.camel.component.properties.propertiescomponent"> <property name="location" value="classpath:${env}/my.properties" /> </bean> <bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="locations"> <list> <value>classpath:${env}/my.properties</value> </list> </property> </bean> <camel:camelcontext id="camelcontext"> <camel:contextscan/> <camel:template id="serviceconsumertemplate" defaultendpoint="direct:start" /> <camel:threadpoolprofile defaultprofile="true" id="defaultthreadpool" poolsize="10" maxpoolsize="15" /> <camel:route id="servicegetaccount"> <camel:from uri="timer://kickoff?repeatcount=1"/> <camel:to uri="bean:servicegetaccountprocessor" /> <camel:to uri="bean:servicerequestheadercreator" /> <camel:to uri="cxf:bean:servicegetaccountendpoint?dataformat=pojo" /> <camel:to uri="bean:servicegetaccountresponseprocessor" /> </camel:route> </camel:camelcontext> <bean id="servicerequestheadercreator" class="com.mycompany.service.soap.soarequestheadercreator"> <property name="servicename" value="service" /> <property name="spnvalue" value="${nj.spn}" /> <property name="securitytokenenabled" value="true" /> <property name="sendingapplication" value="nj service" /> <property name="serviceversion" value="3.0.2" /> <property name="sendinghost" ref="localhostname"/> </bean> <cxf:cxfendpoint id="servicegetaccountendpoint" address="${request.endpoint}/serviceaccountrequestresponsept" endpointname="s:serviceaccountrequestresponseport" servicename="s:serviceaccountrequestresponsehttp" xmlns:s="http://soa.mycompany.com/services/service/wsdl/v3" serviceclass="com.mycompany.services.service.wsdl.v3.serviceaccountrequestresponsept" loggingfeatureenabled="true"> </cxf:cxfendpoint> <bean id="servicegetaccountprocessor" class="com.mycompany.service.servicegetaccountprocessor"/> <bean id="servicegetaccountresponseprocessor" class="com.mycompany.service.servicegetaccountresponseprocessor"/> </beans>
- up logging level of log4j.logger.org.apache.camel=debug
however not see camel log lines of routes starting.
update 2: not doing mvn clean generate-sources. once started doing mvn clean , rebuilding war file, camel kicked in.
seems spring context not fire. make sure is! there should spring info log events telling this.
try adding this:
<context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/applicationcontext.xml</param-value> </context-param>
Comments
Post a Comment