You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Michal Singer <Mi...@expand.com> on 2008/02/03 13:42:55 UTC

Active MQ broker embedded with spring configuration problems

Hi. I am trying to raise an embedded Active MQ broker using spring
configuration file. I work with spring 2.0.6 & Active MQ 5.0.0. The only way
that works is this:
 <amq:broker brokerName="brokerFactory" useJmx="true" persistent="true">
   <amq:managementContext>
        <amq:managementContext connectorPort="1099"
jmxDomainName="org.apache.activemq"/>
    </amq:managementContext>
    <amq:transportConnectors>
      <amq:transportConnector name="openwire" uri="tcp://localhost:61616" />
    </amq:transportConnectors>
  </amq:broker>

With this way i have a few problems:
1. how do i define the active mq configuration file. i can't see any way?
2. I am trying to define: amq:networkConnectors but I get the following
error - 
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was
found starting with element 'amq:networkConnectors'. One of
'{WC[##other:"http://activemq.org/config/1.0"]}' is expected.

I use the following namespace and according to the documentation this
element should work:
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.org/config/1.0 
http://activemq.apache.org/snapshot-schema/activemq-core-5.0-SNAPSHOT.xsd

Any help would be highly appreciated.
Thanks

-- 
View this message in context: http://www.nabble.com/Active-MQ-broker-embedded-with-spring-configuration-problems-tp15253117s2354p15253117.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Active MQ broker embedded with spring configuration problems

Posted by tbenge <to...@gmail.com>.
I ran into the same problem.  The networkConnectors need to be first in the
XML declaration.

  <amq:broker brokerName="BrokerA" useJmx="true" persistent="true">
	<amq:networkConnectors>
  		<amq:networkConnector uri="static:(tcp://hostname:61616)"
dynamicOnly="false" conduitSubscriptions="false" networkTTL="5"/>
  	</amq:networkConnectors>
  	<amq:persistenceAdapter>
  		<amq:amqPersistenceAdapter
directory="/var/cache/tomcat5/work/activemq-data" maxFileLength="10485760"/>
  	</amq:persistenceAdapter>
  	<amq:transportConnectors>
  		<amq:transportConnector uri="tcp://localhost:61616"/>
  	</amq:transportConnectors>
  </amq:broker>


Michal Singer wrote:
> 
> Hi. I am trying to raise an embedded Active MQ broker using spring
> configuration file. I work with spring 2.0.6 & Active MQ 5.0.0. The only
> way that works is this:
>  <amq:broker brokerName="brokerFactory" useJmx="true" persistent="true">
>    <amq:managementContext>
>         <amq:managementContext connectorPort="1099"
> jmxDomainName="org.apache.activemq"/>
>     </amq:managementContext>
>     <amq:transportConnectors>
>       <amq:transportConnector name="openwire" uri="tcp://localhost:61616"
> />
>     </amq:transportConnectors>
>   </amq:broker>
> 
> With this way i have a few problems:
> 1. how do i define the active mq configuration file. i can't see any way?
> 2. I am trying to define: amq:networkConnectors but I get the following
> error - 
> org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was
> found starting with element 'amq:networkConnectors'. One of
> '{WC[##other:"http://activemq.org/config/1.0"]}' is expected.
> 
> I use the following namespace and according to the documentation this
> element should work:
> http://www.springframework.org/schema/beans 
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://activemq.org/config/1.0 
> http://activemq.apache.org/snapshot-schema/activemq-core-5.0-SNAPSHOT.xsd
> 
> Any help would be highly appreciated.
> Thanks
> 
> 

-- 
View this message in context: http://www.nabble.com/Active-MQ-broker-embedded-with-spring-configuration-problems-tp15253117s2354p15268990.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Active MQ broker embedded with spring configuration problems

Posted by Rob Davies <ra...@gmail.com>.
Thanks Andrew!

On 6 May 2009, at 15:33, ee7arh wrote:

>
> Please also fix this page too:
>
> http://activemq.apache.org/networks-of-brokers.html
>
> Order should be:
> networkConnectors
> persistenceAdapter
> transportConnectors
>
> Bregards
> Andrew
>
>
> Gary Tully wrote:
>>
>> Hi Andrew, thanks. No need to raise a jira issue. I just updated  
>> that page
>> to fix the order. That page was produced before schema validation was
>> enabled. As the broker element is a sequence, order is important.
>>
>> You can see the xml schema at
>> http://activemq.apache.org/xml-reference.html
>>
>> 2009/3/31 ee7arh <an...@2e-systems.com>
>>
>>>
>>>
>>> Hi,
>>>
>>> I had a very similar problem except that ActiveMQ complained  
>>> because my
>>> <persistenceAdapter> was declared after my <transportConnectors>.
>>>
>>> When I put the <persistenceAdapter> first then all worked fine.  
>>> What is
>>> confusing is that on the ActiveMQ docs it has an example showing  
>>> that
>>> this
>>> will work the other way around:
>>>
>>> http://activemq.apache.org/amq-message-store.html
>>> http://activemq.apache.org/amq-message-store.html
>>>
>>> Is this actually a bug in ActiveMQ? Should I raise an issue?
>>>
>>> Thanks
>>> Andrew
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Active-MQ-broker-embedded-with-spring-configuration-problems-tp15253117p22804988.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>> -- 
>> http://blog.garytully.com
>>
>> Open Source SOA
>> http://FUSESource.com
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Active-MQ-broker-embedded-with-spring-configuration-problems-tp15253117p23407600.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


Re: Active MQ broker embedded with spring configuration problems

Posted by ee7arh <an...@2e-systems.com>.
Please also fix this page too:

http://activemq.apache.org/networks-of-brokers.html

Order should be:
networkConnectors
persistenceAdapter
transportConnectors

Bregards
Andrew


Gary Tully wrote:
> 
> Hi Andrew, thanks. No need to raise a jira issue. I just updated that page
> to fix the order. That page was produced before schema validation was
> enabled. As the broker element is a sequence, order is important.
> 
> You can see the xml schema at
> http://activemq.apache.org/xml-reference.html
> 
> 2009/3/31 ee7arh <an...@2e-systems.com>
> 
>>
>>
>> Hi,
>>
>> I had a very similar problem except that ActiveMQ complained because my
>> <persistenceAdapter> was declared after my <transportConnectors>.
>>
>> When I put the <persistenceAdapter> first then all worked fine. What is
>> confusing is that on the ActiveMQ docs it has an example showing that
>> this
>> will work the other way around:
>>
>> http://activemq.apache.org/amq-message-store.html
>> http://activemq.apache.org/amq-message-store.html
>>
>> Is this actually a bug in ActiveMQ? Should I raise an issue?
>>
>> Thanks
>> Andrew
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Active-MQ-broker-embedded-with-spring-configuration-problems-tp15253117p22804988.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> http://blog.garytully.com
> 
> Open Source SOA
> http://FUSESource.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Active-MQ-broker-embedded-with-spring-configuration-problems-tp15253117p23407600.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Active MQ broker embedded with spring configuration problems

Posted by Gary Tully <ga...@gmail.com>.
Hi Andrew, thanks. No need to raise a jira issue. I just updated that page
to fix the order. That page was produced before schema validation was
enabled. As the broker element is a sequence, order is important.

You can see the xml schema at http://activemq.apache.org/xml-reference.html

2009/3/31 ee7arh <an...@2e-systems.com>

>
>
> Hi,
>
> I had a very similar problem except that ActiveMQ complained because my
> <persistenceAdapter> was declared after my <transportConnectors>.
>
> When I put the <persistenceAdapter> first then all worked fine. What is
> confusing is that on the ActiveMQ docs it has an example showing that this
> will work the other way around:
>
> http://activemq.apache.org/amq-message-store.html
> http://activemq.apache.org/amq-message-store.html
>
> Is this actually a bug in ActiveMQ? Should I raise an issue?
>
> Thanks
> Andrew
>
> --
> View this message in context:
> http://www.nabble.com/Active-MQ-broker-embedded-with-spring-configuration-problems-tp15253117p22804988.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
http://blog.garytully.com

Open Source SOA
http://FUSESource.com

Re: Active MQ broker embedded with spring configuration problems

Posted by ee7arh <an...@2e-systems.com>.

Hi,

I had a very similar problem except that ActiveMQ complained because my
<persistenceAdapter> was declared after my <transportConnectors>.

When I put the <persistenceAdapter> first then all worked fine. What is
confusing is that on the ActiveMQ docs it has an example showing that this
will work the other way around:

http://activemq.apache.org/amq-message-store.html
http://activemq.apache.org/amq-message-store.html 

Is this actually a bug in ActiveMQ? Should I raise an issue?

Thanks
Andrew

-- 
View this message in context: http://www.nabble.com/Active-MQ-broker-embedded-with-spring-configuration-problems-tp15253117p22804988.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Active MQ broker embedded with spring configuration problems

Posted by ttmdev <jo...@ttmsolutions.com>.
Here's a sample spring cfg file that I've used to start an 'embedded'
ActiveMQ broker. Note how the connectionFactory bean points the embedded
broker to an external ActiveMQ broker cfg file, which I have also included
below. Within the broker cfg file you can define your transport and network
connector elements. In this example, the broker's cfg file should be in the
classpath. I am using the latest 5.1 SNAPSHOT. Hope this helps - Joe

<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.org/config/1.0"
  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-2.0.xsd
  http://activemq.org/config/1.0
http://activemq.apache.org/schema/activemq-core.xsd
  http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd" > 
 
  
  <!-- An AMQ connection factory bean that starts an embedded broker and
points the 
        broker to a broker cfg file. -->
  <bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
     <property name="brokerURL"
value="vm://embeddedbroker?brokerConfig=xbean:activemq_clt.xml"/>            
  </bean>
  
  <!-- Specify a destination -->
  <bean id="myDestination"
class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg index="0" value="Q.TEST"/>        
  </bean>
  
  <!-- Wire this JMS template to the appropriate connection factory and
destination -->
  <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">    
    <property name="connectionFactory" ref="connectionFactory"/>    
    <property name="defaultDestination" ref="myDestination"/>
  </bean>
   
  <!-- This is the send bean, which we wire to the JMS template --> 
  <bean id="sendBean" class="spring.SendBean">
    <property name="jmsTemplate" ref="jmsTemplate"/>  
    <property name="destination" ref="myDestination"/>  
  </bean> 

</beans>


**** The broker's cfg file (activemq_clt.xml) ****

<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.org/config/1.0"
  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-2.0.xsd
  http://activemq.org/config/1.0
http://activemq.apache.org/schema/activemq-core.xsd
  http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

  <!-- Allows us to use system properties as variables in this configuration
file -->
  <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
  
  <broker xmlns="http://activemq.org/config/1.0" brokerName="embeddedbroker"
useJmx="true">
  
    <transportConnectors>
       <transportConnector name="tcp" uri="tcp://localhost:61616"/>       
    </transportConnectors>

    <networkConnectors>      
       <networkConnector name="pool" uri="static:(tcp://localhost:61617)" />
    </networkConnectors>
   
    <managementContext>
       <managementContext connectorPort="1100"
jmxDomainName="org.apache.activemq"/>
    </managementContext>
    
  </broker>  
</beans>



Michal Singer wrote:
> 
> Hi. I am trying to raise an embedded Active MQ broker using spring
> configuration file. I work with spring 2.0.6 & Active MQ 5.0.0. The only
> way that works is this:
>  <amq:broker brokerName="brokerFactory" useJmx="true" persistent="true">
>    <amq:managementContext>
>         <amq:managementContext connectorPort="1099"
> jmxDomainName="org.apache.activemq"/>
>     </amq:managementContext>
>     <amq:transportConnectors>
>       <amq:transportConnector name="openwire" uri="tcp://localhost:61616"
> />
>     </amq:transportConnectors>
>   </amq:broker>
> 
> With this way i have a few problems:
> 1. how do i define the active mq configuration file. i can't see any way?
> 2. I am trying to define: amq:networkConnectors but I get the following
> error - 
> org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was
> found starting with element 'amq:networkConnectors'. One of
> '{WC[##other:"http://activemq.org/config/1.0"]}' is expected.
> 
> I use the following namespace and according to the documentation this
> element should work:
> http://www.springframework.org/schema/beans 
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://activemq.org/config/1.0 
> http://activemq.apache.org/snapshot-schema/activemq-core-5.0-SNAPSHOT.xsd
> 
> Any help would be highly appreciated.
> Thanks
> 
> 

-- 
View this message in context: http://www.nabble.com/Active-MQ-broker-embedded-with-spring-configuration-problems-tp15253117s2354p15269038.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.