You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Doug Steigerwald <ds...@mcclatchyinteractive.com> on 2007/06/01 13:35:16 UTC

MySQL datastore

I'm currently trying to set up ActiveMQ to use MySQL as the data store.  ActiveMQ connects to the 
database and creates some tables if it needs to, but nothing is stored in the ACTIVEMQ_MSGS table 
when I send messages via stomp (we're going to be using perl and an extended Net::Stomp to connect 
and post messages).  We're only using queues at the moment.

Am I missing something?  We've been impressed with the performance we've seen when testing ActiveMQ 
using Kaha, but we really want a MySQL data store.

I'm using the ActiveMQ 4.2 snapshot from 5/30 and MySQL 4.1.2.  Here's my config.

<?xml version="1.0" encoding="UTF-8"?>
<beans>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
   <broker xmlns="http://activemq.org/config/1.0" useJmx="true" brokerName="broker" 
useShutdownHook="true" persistent="true" deleteAllMessagesOnStartup="false">
     <managementContext>
       <managementContext createConnector="true"/>
     </managementContext>

     <persistenceAdapter>
       <jdbcPersistenceAdapter dataSource="#dataSource" statements="#statements"/>
     </persistenceAdapter>

     <networkConnectors>
       <networkConnector name="default-nc" uri="multicast://default"/>
     </networkConnectors>

     <transportConnectors>
       <transportConnector uri="stomp://localhost:61613" />
     </transportConnectors>

   </broker>

   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
     <property name="url" value="jdbc:mysql://db_host/db_db?relaxAutoCommit=true"/>
     <property name="username" value="db_user"/>
     <property name="password" value="db_password"/>
     <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
     <property name="poolPreparedStatements" value="true"/>
   </bean>

   <bean id="statements" class="org.apache.activemq.store.jdbc.Statements">
   </bean>

   <commandAgent xmlns="http://activemq.org/config/1.0"/>
   <jetty xmlns="http://mortbay.com/schemas/jetty/1.0">
     <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" />
     </handlers>
   </jetty>
</beans>


Thanks.
-- 
Doug Steigerwald

-- 
Doug Steigerwald
Software Developer
McClatchy Interactive
dsteigerwald@mcclatchyinteractive.com
919.861.1287

Re: MySQL datastore

Posted by Tom Samplonius <to...@samplonius.org>.
----- "James Strachan" <ja...@gmail.com> wrote:
> On 6/1/07, Doug Steigerwald <ds...@mcclatchyinteractive.com>
> wrote:
> > I'm currently trying to set up ActiveMQ to use MySQL as the data
> store.  ActiveMQ connects to the
> > database and creates some tables if it needs to, but nothing is
> stored in the ACTIVEMQ_MSGS table
> > when I send messages via stomp (we're going to be using perl and an
> extended Net::Stomp to connect
> > and post messages).  We're only using queues at the moment.
> >
> > Am I missing something?  We've been impressed with the performance
> we've seen when testing ActiveMQ
> > using Kaha, but we really want a MySQL data store.
> 
> Are you sure you're sending a peristent message? Try adding the
> persistent header with stomp. (We should make persistence the
> default;
> can't remember what it is currently)...
> 
> see the stomp headers supported...
> 
> http://activemq.apache.org/stomp.html

  The default for Stomp in 4.1.1 and 4.2-SNAPSHOT is non-persistent

  With Net::Stomp, you need do something like this:

$stomp->send( { destination => '/queue/myqueue', persistent => 'true', body => $body } );


Unfortunately, the Net::Stomp documentation does not mention how to add headers to messages.


> -- 
> James
> -------
> http://macstrac.blogspot.com/


Tom

Re: MySQL datastore

Posted by James Strachan <ja...@gmail.com>.
On 6/1/07, Doug Steigerwald <ds...@mcclatchyinteractive.com> wrote:
> I'm currently trying to set up ActiveMQ to use MySQL as the data store.  ActiveMQ connects to the
> database and creates some tables if it needs to, but nothing is stored in the ACTIVEMQ_MSGS table
> when I send messages via stomp (we're going to be using perl and an extended Net::Stomp to connect
> and post messages).  We're only using queues at the moment.
>
> Am I missing something?  We've been impressed with the performance we've seen when testing ActiveMQ
> using Kaha, but we really want a MySQL data store.

Are you sure you're sending a peristent message? Try adding the
persistent header with stomp. (We should make persistence the default;
can't remember what it is currently)...

see the stomp headers supported...

http://activemq.apache.org/stomp.html

-- 
James
-------
http://macstrac.blogspot.com/

Re: MySQL datastore

Posted by Doug Steigerwald <ds...@mcclatchyinteractive.com>.
Never mind, wasn't send the messages as persistent with stomp!

Doug Steigerwald

Doug Steigerwald wrote:
> I'm currently trying to set up ActiveMQ to use MySQL as the data store.  
> ActiveMQ connects to the database and creates some tables if it needs 
> to, but nothing is stored in the ACTIVEMQ_MSGS table when I send 
> messages via stomp (we're going to be using perl and an extended 
> Net::Stomp to connect and post messages).  We're only using queues at 
> the moment.
> 
> Am I missing something?  We've been impressed with the performance we've 
> seen when testing ActiveMQ using Kaha, but we really want a MySQL data 
> store.
> 
> I'm using the ActiveMQ 4.2 snapshot from 5/30 and MySQL 4.1.2.  Here's 
> my config.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <beans>
> <bean 
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> 
> 
>   <broker xmlns="http://activemq.org/config/1.0" useJmx="true" 
> brokerName="broker" useShutdownHook="true" persistent="true" 
> deleteAllMessagesOnStartup="false">
>     <managementContext>
>       <managementContext createConnector="true"/>
>     </managementContext>
> 
>     <persistenceAdapter>
>       <jdbcPersistenceAdapter dataSource="#dataSource" 
> statements="#statements"/>
>     </persistenceAdapter>
> 
>     <networkConnectors>
>       <networkConnector name="default-nc" uri="multicast://default"/>
>     </networkConnectors>
> 
>     <transportConnectors>
>       <transportConnector uri="stomp://localhost:61613" />
>     </transportConnectors>
> 
>   </broker>
> 
>   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
> destroy-method="close">
>     <property name="url" 
> value="jdbc:mysql://db_host/db_db?relaxAutoCommit=true"/>
>     <property name="username" value="db_user"/>
>     <property name="password" value="db_password"/>
>     <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
>     <property name="poolPreparedStatements" value="true"/>
>   </bean>
> 
>   <bean id="statements" class="org.apache.activemq.store.jdbc.Statements">
>   </bean>
> 
>   <commandAgent xmlns="http://activemq.org/config/1.0"/>
>   <jetty xmlns="http://mortbay.com/schemas/jetty/1.0">
>     <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" />
>     </handlers>
>   </jetty>
> </beans>
> 
> 
> Thanks.