spring - ActiveMQ maven plugin configuration -
i have problem using activemq in spring project. trying integrate activemq maven plugin project use in integration tests. here configuration:
<?xml version="1.0" encoding="utf-8"?> <!-- licensed apache software foundation (asf) under 1 or more contributor license agreements. see notice file distributed work additional information regarding copyright ownership. asf licenses file under apache license, version 2.0 (the "license"); may not use file except in compliance license. may obtain copy of license @ http://www.apache.org/licenses/license-2.0 unless required applicable law or agreed in writing, software distributed under license distributed on "as is" basis, without warranties or conditions of kind, either express or implied. see license specific language governing permissions , limitations under license. --> <!-- start snippet: example --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:amq="http://activemq.apache.org/schema/core" xmlns:cam ="http://camel.apache.org/schema/spring" xmlns:jetty ="http://mortbay.com/schemas/jetty/1.0" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd http://mortbay.com/schemas/jetty/1.0 http://jetty.mortbay.org/jetty.xsd"> <!-- location schema doesn't work, dont know schema located xmlns:jetty ="http://mortbay.com/schemas/jetty/1.0" http://mortbay.com/schemas/jetty/1.0 http://jetty.mortbay.org/jetty.xsd --> <!-- allows use system properties variables in configuration file --> <bean class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="locations"> <value>file:///${activemq.base}/conf/credentials.properties</value> </property> </bean> <amq:broker xmlns="http://activemq.apache.org/schema/core" brokername="localhost" datadirectory="${activemq.base}/data"> <!-- destination specific policies using destination names or wildcards --> <destinationpolicy> <policymap> <policyentries> <policyentry queue=">" memorylimit="5mb"/> <policyentry topic=">" memorylimit="5mb"> <!-- can add other policies such these <dispatchpolicy> <strictorderdispatchpolicy/> </dispatchpolicy> <subscriptionrecoverypolicy> <lastimagesubscriptionrecoverypolicy/> </subscriptionrecoverypolicy> --> </policyentry> </policyentries> </policymap> </destinationpolicy> <!-- use following configure how activemq exposed in jmx --> <managementcontext> <managementcontext createconnector="false"/> </managementcontext> <!-- store , forward broker networks activemq listen --> <networkconnectors> <!-- default auto discover other brokers --> <networkconnector name="default-nc" uri="multicast://default"/> <!-- example of static configuration: <networkconnector name="host1 , host2" uri="static://(tcp://host1:61616,tcp://host2:61616)"/> --> </networkconnectors> <persistenceadapter> <amqpersistenceadapter synconwrite="false" directory="${activemq.base}/data" maxfilelength="20 mb"/> </persistenceadapter> <!-- use following if wish configure journal jdbc --> <!-- <persistenceadapter> <journaledjdbc datadirectory="${activemq.base}/data" datasource="#postgres-ds"/> </persistenceadapter> --> <!-- or if want use pure jdbc without journal --> <!-- <persistenceadapter> <jdbcpersistenceadapter datasource="#postgres-ds"/> </persistenceadapter> --> <sslcontext> <sslcontext keystore="file:${activemq.base}/conf/broker.ks" keystorepassword="password" truststore="file:${activemq.base}/conf/broker.ts" truststorepassword="password"/> </sslcontext> <!-- maximum of space broker use before slowing down producers --> <systemusage> <systemusage> <memoryusage> <memoryusage limit="20 mb"/> </memoryusage> <storeusage> <storeusage limit="1 gb" name="foo"/> </storeusage> <tempusage> <tempusage limit="100 mb"/> </tempusage> </systemusage> </systemusage> <!-- transport connectors activemq listen --> <transportconnectors> <!--<transportconnector name="openwire" uri="tcp://localhost:61616" discoveryuri="multicast://default"/>--> <!--<transportconnector name="default-nc" uri="multicast://default"/>--> <transportconnector name="openwire" uri="tcp://localhost:61616" /> <transportconnector name="ssl" uri="ssl://localhost:61617"/> <transportconnector name="stomp" uri="stomp://localhost:61613"/> <transportconnector name="xmpp" uri="xmpp://localhost:61222"/> </transportconnectors> </amq:broker> <!-- ** lets deploy enterprise integration patterns inside activemq message broker ** more details see ** ** http://activemq.apache.org/enterprise-integration-patterns.html --> <cam:camelcontext id="camel"> <!-- can use <package> element each root package search java routes --> <cam:package>org.foo.bar</cam:package> <!-- can use spring xml syntax define routes here using <route> element --> <cam:route> <cam:from uri="activemq:example.a"/> <cam:to uri="activemq:example.b"/> </cam:route> </cam:camelcontext> <!-- ** lets configure camel endpoints ** ** http://activemq.apache.org/camel/components.html --> <!-- configure camel activemq component use current broker --> <bean id="activemq" class="org.apache.activemq.camel.component.activemqcomponent" > <property name="connectionfactory"> <bean class="org.apache.activemq.activemqconnectionfactory"> <property name="brokerurl" value="vm://localhost?create=false&waitforstart=10000" /> <property name="username" value="${activemq.username}"/> <property name="password" value="${activemq.password}"/> </bean> </property> </bean> <!-- uncomment create command agent respond message based admin commands on activemq.agent topic --> <!-- <commandagent xmlns="http://activemq.apache.org/schema/core" brokerurl="vm://localhost" username="${activemq.username}" password="${activemq.password}"/> --> <!-- embedded servlet engine serving admin console --> <jetty:jetty> <connectors> <nioconnector port="8161"/> </connectors> <handlers> <webappcontext contextpath="/admin" resourcebase="${activemq.base}/webapps/admin" logurlonstart="true"/> <webappcontext contextpath="/demo" resourcebase="${activemq.base}/webapps/demo" logurlonstart="true"/> <webappcontext contextpath="/fileserver" resourcebase="${activemq.base}/webapps/fileserver" logurlonstart="true"/> </handlers> </jetty:jetty> <!-- xbean configuration file supports standard spring xml configuration options --> </beans>
the problem have using jetty namespace. schema cannot found , downloaded: http://jetty.mortbay.org/jetty.xsd here link apache activemq: http://activemq.apache.org/complex-single-broker-configuration-stomp-only.html
there not specified location schema. activemq starts without having schema location if use schema validator in eclipse tells me have error in file , schema location cannot found.
any idea can find schema jetty element ?
i ran problem , lost whole hour find solution.
essentially the example in documentation outdated.
the dependencies required enable jetty activemq-maven-plugin follows:
<dependency> <groupid>org.mortbay.jetty</groupid> <artifactid>jetty-xbean</artifactid> <version>6.1.25</version> <exclusions> <exclusion> <groupid>org.springframework</groupid> <artifactid>spring</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>org.eclipse.jetty.aggregate</groupid> <artifactid>jetty-all-server</artifactid> <version>7.6.7.v20120910</version> </dependency>
following complete configuration of activemq-maven-plugin:
<plugin> <groupid>org.apache.activemq.tooling</groupid> <artifactid>activemq-maven-plugin</artifactid> <version>5.8.0</version> <configuration> <configuri>${configuri}</configuri> <fork>false</fork> <systemproperties> <property> <name>javax.net.ssl.keystorepassword</name> <value>password</value> </property> <property> <name>org.apache.activemq.default.directory.prefix</name> <value>./target/</value> </property> </systemproperties> </configuration> <dependencies> <dependency> <groupid>org.apache.activemq</groupid> <artifactid>activemq-spring</artifactid> <version>5.8.0</version> </dependency> <dependency> <groupid>org.mortbay.jetty</groupid> <artifactid>jetty-xbean</artifactid> <version>6.1.25</version> <exclusions> <exclusion> <groupid>org.springframework</groupid> <artifactid>spring</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>org.eclipse.jetty.aggregate</groupid> <artifactid>jetty-all-server</artifactid> <version>7.6.7.v20120910</version> </dependency> <dependency> <groupid>org.apache.activemq</groupid> <artifactid>activemq-leveldb-store</artifactid> <version>5.8.0</version> </dependency> </dependencies> <executions> <execution> <id>start-activemq</id> <goals> <goal>run</goal> </goals> <phase>pre-integration-test</phase> </execution> </executions> </plugin>
then enable jetty enough import jetty configuration file activemq configuration file.
the following snippet taken file ${activemq_home}/conf/activemq.xml in activemq latest release @ time of writing (5.8.0):
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> <!-- <broker> element used configure activemq broker. --> <broker xmlns="http://activemq.apache.org/schema/core" brokername="localhost" datadirectory="${activemq.data}"> ... </broker> <!-- enable web consoles, rest , ajax apis , demos take @ ${activemq_home}/conf/jetty.xml more details --> <import resource="jetty.xml"/> </beans>
cheers,
domenico
Comments
Post a Comment