activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Ashworth" <ma...@cibecs.com>
Subject RE: Postgres persistence in Tomcat
Date Mon, 11 Sep 2006 14:10:42 GMT
Place the xbean-spring-2.2.jar in the WEB-INF/lib directory



-----Original Message-----
From: petera [mailto:peter.anderson@egsgroup.com] 
Sent: 11 September 2006 11:43 AM
To: activemq-users@geronimo.apache.org
Subject: Re: Postgres persistence in Tomcat


James,

I am trying to configure the broker with activemq.xml file i.e.

       brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"

I am not using spring for development but have placed the spring jar
(spring-1.2.6.jar) in my WEB_INF/lib directory.

When I try to produce some messages I get the following error:

      Could not connect to broker URL:
vm://localhost?brokerConfig=xbean:activemq.xml. Reason: java.io.IOException:
Could load xbean factory:java.lang.NoClassDefFoundError

What I am missing ?

TIA Peter

activemq.xml setup for persisting to Postgres database:


<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
   
    http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<!-- START SNIPPET: example -->
<beans>

  <!-- Allows us to use system properties as variables in this configuration
file -->
   
  <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigure
r"/>
 
  
  <broker useJmx="true" xmlns="http://activemq.org/config/1.0">
  
    <!--  Use the following to set the broker memory limit 
    <memoryManager>  
        <usageManager id="memory-manager" limit="20 MB"/>
    </memoryManager>
    -->
    
    <!-- Use the following to configure how ActiveMQ is exposed in JMX
    <managementContext>
       <managementContext connectorPort="1099"
jmxDomainName="org.apache.activemq"/>
    </managementContext>
    -->

    <!-- In ActiveMQ 4, you can setup destination policies -->  
    <destinationPolicy>
      <policyMap><policyEntries>
        
          <policyEntry topic="FOO.>">
            <dispatchPolicy>
              <strictOrderDispatchPolicy />
            </dispatchPolicy>
            <subscriptionRecoveryPolicy>
              <lastImageSubscriptionRecoveryPolicy />
            </subscriptionRecoveryPolicy>
          </policyEntry>

      </policyEntries></policyMap>
    </destinationPolicy>
  
  
    <persistenceAdapter>
<!--  
        <journaledJDBC journalLogFiles="5"
dataDirectory="${activemq.home}/activemq-data"/>
-->        
      <!-- To use a different datasource, use the following syntax : -->
      <journaledJDBC journalLogFiles="5" dataDirectory="../activemq-data"
dataSource="#postgres-ds"/>
    </persistenceAdapter>
  
    <transportConnectors>
       <transportConnector name="default" uri="tcp://localhost:61616"
discoveryUri="multicast://default"/>
       <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
    </transportConnectors>
    
    <networkConnectors>
      <!-- by default just auto discover the other brokers -->
      <networkConnector name="default" uri="multicast://default"/>
      <!--
      <networkConnector name="host1 and host2"
uri="static://(tcp://host1:61616,tcp://host2:61616)" failover="true"/>
      -->
    </networkConnectors>
    
  </broker>
  
  <!--  This xbean configuration file supports all the standard spring xml
configuration options -->
  
  <!-- Postgres DataSource Sample Setup -->
  <bean id="postgres-ds" class="org.postgresql.ds.PGPoolingDataSource">
    <property name="serverName" value="localhost"/>
    <property name="databaseName" value="activemq"/>
    <property name="portNumber" value="0"/>
    <property name="user" value="activemq"/>
    <property name="password" value="activemq"/>
    <property name="dataSourceName" value="postgres"/>
    <property name="initialConnections" value="1"/>
    <property name="maxConnections" value="10"/>
  </bean>
  
  <!-- MySql DataSource Sample Setup -->
  <!-- 
  <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url"
value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
    <property name="username" value="activemq"/>
    <property name="password" value="activemq"/>
    <property name="poolPreparedStatements" value="true"/>
  </bean>
  -->  
   
  <!-- Oracle DataSource Sample Setup -->
  <!--
  <bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
    <property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver"/>
    <property name="url" value="jdbc:oracle:thin:@localhost:1521:AMQDB"/>
    <property name="username" value="scott"/>
    <property name="password" value="tiger"/>
    <property name="poolPreparedStatements" value="true"/>
  </bean>
  -->
        
  <!-- Embedded Derby DataSource Sample Setup -->
  <!-- 
  <bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
    <property name="databaseName" value="derbydb"/>
    <property name="createDatabase" value="create"/>
  </bean>
  -->  

</beans>
<!-- END SNIPPET: example -->






James.Strachan wrote:
> 
> Just create a valid login/pwd so that there is an empty database then
> ActiveMQ will do the rest
> 
> On 9/7/06, petera <peter.anderson@egsgroup.com> wrote:
>>
>> Adrian,
>>
>> Thanks for your help. The documentation is a bit patchy on actually
>> setting
>> up the messaging database.
>>
>> Do I just create an activemq database in postgres and then activemq
>> automatically creates the tables it requires. Or do I
>> need to create some tables for it to use ?
>>
>> TIA Peter
>>
>>
>>
>> Adrian Co wrote:
>> >
>> > Hi,
>> >
>> > One way I could think of is to configure your broker using an external
>> > config file (i.e. activemq.xml) and just change the dataSource of the
>> > persistence adapter to postgres. Example:
>> >
>>
https://svn.apache.org/repos/asf/incubator/activemq/trunk/assembly/src/relea
se/conf/activemq.xml
>> >
>> > Just uncomment the postgres-ds bean and uncomment the reference in the
>> > persistence adapter.
>> >
>> > And use that config file to configure your embedded broker. i.e.
>> > brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml" <- assuming
>> > activemq.xml is in the classpath
>> >
>> > or
>> >
>> > brokerURL="vm://localhost?brokerConfig=xbean:file:c:/activemq.xml" <-
>> > for file path referencing
>> >
>> > Hope this helps.
>> >
>> > Regards,
>> > Adrian Co
>> >
>> > petera wrote:
>> >> Hi,
>> >>
>> >> I am using ActiveMQ 4.0.1 running under Tomcat 5.5.17. I would like to
>> >> persist the messages to a Postgres database rather than the default
>> >> apache-derby database.
>> >>
>> >> What additional config parameters do I need to set in my context.xml
>> >> file.
>> >>
>> >>
>> >> TIA Peter
>> >>
>> >>
>> >> context.xml:
>> >>
>> >> <Context antiJARLocking="true">
>> >>
>> >>     <Resource
>> >>         name="jms/ConnectionFactory"
>> >>         auth="Container"
>> >>         type="org.apache.activemq.ActiveMQConnectionFactory"
>> >>         description="JMS Connection Factory"
>> >>         factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>> >>         brokerURL="vm://localhost"
>> >>         brokerName="LocalActiveMQBroker"
>> >>         useEmbeddedBroker="false"/>
>> >>
>> >>     <Resource name="jms/MyTopic"
>> >>         auth="Container"
>> >>         type="org.apache.activemq.command.ActiveMQTopic"
>> >>         factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>> >>         physicalName="MY.TEST.FOO"/>
>> >>
>> >>     <Resource name="jms/MyQueue"
>> >>         auth="Container"
>> >>         type="org.apache.activemq.command.ActiveMQQueue"
>> >>         factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>> >>         physicalName="MY.TEST.BAR"/>
>> >>
>> >> </Context>
>> >>
>> >>
>> >>
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>>
http://www.nabble.com/Postgres-persistence-in-Tomcat-tf2225497.html#a6186145
>> Sent from the ActiveMQ - User forum at Nabble.com.
>>
>>
> 
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context:
http://www.nabble.com/Postgres-persistence-in-Tomcat-tf2225497.html#a6243677
Sent from the ActiveMQ - User forum at Nabble.com.



Mime
View raw message