You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "Paul.Tang" <xc...@hotmail.com> on 2006/10/25 10:33:14 UTC

Why not using MySQL JDBC persistence in embbed mode under Tomcat 5.5.20?


My Environment is:
Windows 2003 Server + Tomcat 5.5.20 + MySQL 5.0.26
I run ActiveMQ 4.0.1 under Tomcat 5.5.20 in embbed mode. I've configured
MySQL as JDBC persistence,But it doesn't take effect.
I used the same active-mq.xml, But it works well when ActiveMQ runs
standalone.

Here's the content of file webapps/cenep/META-INF/context.xml:
-------------------------------------------------------------------------------------------
<Context antiJARLocking="true">

    <Resource name="jdbc/Portal"
        auth="Container"
        type="javax.sql.DataSource"
        validationQuery="select 1 from id_table"
        maxActive="100" maxIdle="30" maxWait="10000"
        removeAbandoned="true" removeAbandonedTimeout="60"
logAbandoned="true"
        username="root" password="mysql"
        driverClassName="com.mysql.jdbc.Driver"
       
url="jdbc:mysql://localhost:3316/epdata?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=gbk"
/>

    <Resource name="jms/ConnectionFactory"
        auth="Container"
        type="org.apache.activemq.ActiveMQConnectionFactory"
        description="JMS Connection Factory"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory"
       
brokerURL="tcp://localhost:61616?brokerConfig=xbean:file:C:/ctivemq.xml"
        brokerName="LocalActiveMQBroker"
        useEmbeddedBroker="true" />

    <Resource name="jms/jmsTopic"
        auth="Container"
        type="org.apache.activemq.command.ActiveMQTopic"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory"
        physicalName="JMS_TOPIC.Portal" />

    <Resource name="jms/jmsQueue"
        auth="Container"
        type="org.apache.activemq.command.ActiveMQQueue"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory"
        physicalName="JMS_QUEUE.Portal" />
        
</Context>

Here's the part content of file C:/active-mq.xml:
-------------------------------------------------------------------------------------------
    <persistenceAdapter>
      <!-- 
        <journaledJDBC journalLogFiles="5"
dataDirectory="${catalina.home}/activemq-data"/>
      -->
      <!-- To use a different datasource, use the following syntax : -->
      <!-- 
      <journaledJDBC useJournal="false" journalLogFiles="5"
dataDirectory="${catalina.home}/activemq-data" dataSource="#mysql-ds"
statements="#statements"/>
      -->
      <jdbcPersistenceAdapter dataSource="#mysql-ds"
statements="#statements"/>

    </persistenceAdapter>

  <!-- MySql DataSource 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:3316/activemq?relaxAutoCommit=true"/>
    <property name="username" value="activemq"/>
    <property name="password" value="activemq"/>
    <property name="poolPreparedStatements" value="true"/>
  </bean>

  <bean id="statements" class="org.apache.activemq.store.jdbc.Statements">
    <property name="stringIdDataType" value="VARCHAR(128)"/>
    ......
  </bean>


Here's the part content of Log
-------------------------------------------------------------------------------------------
[2006-10-25 16:12:35.308 DEBUG] - GET
client=org.apache.activemq.web.WebClient@153b2cb
session=B67789683FB7C7CAD227B6C5171AAC15 uri=/activemq-web-demo-4.0.1/amq
query=timeout=0&_=
[2006-10-25 16:12:35.318 DEBUG] - doMessage timeout=0
[2006-10-25 16:12:35.418 DEBUG] - GET
client=org.apache.activemq.web.WebClient@153b2cb
session=B67789683FB7C7CAD227B6C5171AAC15 uri=/activemq-web-demo-4.0.1/amq
query=null
[2006-10-25 16:12:35.418 DEBUG] - doMessage timeout=25000
[2006-10-25 16:12:39.264 DEBUG] - POST
client=org.apache.activemq.web.WebClient@153b2cb
session=B67789683FB7C7CAD227B6C5171AAC15 info=null
contentType=application/x-www-form-urlencoded
[2006-10-25 16:12:39.934  INFO] - ActiveMQ 4.0.1 JMS Message Broker
(localhost) is starting
[2006-10-25 16:12:39.934  INFO] - For help or more information please see:
http://incubator.apache.org/activemq/
[2006-10-25 16:12:47.185  INFO] - Database driver recognized:
[apache_derby_embedded_jdbc_driver]
[2006-10-25 16:12:50.249 DEBUG] - Executing SQL: CREATE TABLE
ACTIVEMQ_MSGS(ID INTEGER NOT NULL, CONTAINER VARCHAR(250), MSGID_PROD
VARCHAR(250), MSGID_SEQ INTEGER, EXPIRATION BIGINT, MSG BLOB, PRIMARY KEY (
ID ) )
[2006-10-25 16:12:51.741 DEBUG] - Could not create JDBC tables; The message
table already existed. Failure was: CREATE TABLE ACTIVEMQ_MSGS(ID INTEGER
NOT NULL, CONTAINER VARCHAR(250), MSGID_PROD VARCHAR(250), MSGID_SEQ
INTEGER, EXPIRATION BIGINT, MSG BLOB, PRIMARY KEY ( ID ) ) Message:
Table/View 'ACTIVEMQ_MSGS' already exists in Schema 'APP'. SQLState: X0Y32
Vendor code: 20000


-- 
View this message in context: http://www.nabble.com/Why-not-using-MySQL-JDBC-persistence-in-embbed-mode-under-Tomcat-5.5.20--tf2506291.html#a6988116
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Why not using MySQL JDBC persistence in embbed mode under Tomcat 5.5.20?

Posted by James Strachan <ja...@gmail.com>.
could you provide your entire activemq.xml file so we can figure out
whats wrong. Are you sure its reading the fiile you think  it is?

On 10/25/06, Paul.Tang <xc...@hotmail.com> wrote:
>
>
> My Environment is:
> Windows 2003 Server + Tomcat 5.5.20 + MySQL 5.0.26
> I run ActiveMQ 4.0.1 under Tomcat 5.5.20 in embbed mode. I've configured
> MySQL as JDBC persistence,But it doesn't take effect.
> I used the same active-mq.xml, But it works well when ActiveMQ runs
> standalone.
>
> Here's the content of file webapps/cenep/META-INF/context.xml:
> -------------------------------------------------------------------------------------------
> <Context antiJARLocking="true">
>
>     <Resource name="jdbc/Portal"
>         auth="Container"
>         type="javax.sql.DataSource"
>         validationQuery="select 1 from id_table"
>         maxActive="100" maxIdle="30" maxWait="10000"
>         removeAbandoned="true" removeAbandonedTimeout="60"
> logAbandoned="true"
>         username="root" password="mysql"
>         driverClassName="com.mysql.jdbc.Driver"
>
> url="jdbc:mysql://localhost:3316/epdata?autoReconnect=true&useUnicode=true&characterEncoding=gbk"
> />
>
>     <Resource name="jms/ConnectionFactory"
>         auth="Container"
>         type="org.apache.activemq.ActiveMQConnectionFactory"
>         description="JMS Connection Factory"
>         factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>
> brokerURL="tcp://localhost:61616?brokerConfig=xbean:file:C:/ctivemq.xml"
>         brokerName="LocalActiveMQBroker"
>         useEmbeddedBroker="true" />
>
>     <Resource name="jms/jmsTopic"
>         auth="Container"
>         type="org.apache.activemq.command.ActiveMQTopic"
>         factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>         physicalName="JMS_TOPIC.Portal" />
>
>     <Resource name="jms/jmsQueue"
>         auth="Container"
>         type="org.apache.activemq.command.ActiveMQQueue"
>         factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>         physicalName="JMS_QUEUE.Portal" />
>
> </Context>
>
> Here's the part content of file C:/active-mq.xml:
> -------------------------------------------------------------------------------------------
>     <persistenceAdapter>
>       <!--
>         <journaledJDBC journalLogFiles="5"
> dataDirectory="${catalina.home}/activemq-data"/>
>       -->
>       <!-- To use a different datasource, use the following syntax : -->
>       <!--
>       <journaledJDBC useJournal="false" journalLogFiles="5"
> dataDirectory="${catalina.home}/activemq-data" dataSource="#mysql-ds"
> statements="#statements"/>
>       -->
>       <jdbcPersistenceAdapter dataSource="#mysql-ds"
> statements="#statements"/>
>
>     </persistenceAdapter>
>
>   <!-- MySql DataSource 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:3316/activemq?relaxAutoCommit=true"/>
>     <property name="username" value="activemq"/>
>     <property name="password" value="activemq"/>
>     <property name="poolPreparedStatements" value="true"/>
>   </bean>
>
>   <bean id="statements" class="org.apache.activemq.store.jdbc.Statements">
>     <property name="stringIdDataType" value="VARCHAR(128)"/>
>     ......
>   </bean>
>
>
> Here's the part content of Log
> -------------------------------------------------------------------------------------------
> [2006-10-25 16:12:35.308 DEBUG] - GET
> client=org.apache.activemq.web.WebClient@153b2cb
> session=B67789683FB7C7CAD227B6C5171AAC15 uri=/activemq-web-demo-4.0.1/amq
> query=timeout=0&_=
> [2006-10-25 16:12:35.318 DEBUG] - doMessage timeout=0
> [2006-10-25 16:12:35.418 DEBUG] - GET
> client=org.apache.activemq.web.WebClient@153b2cb
> session=B67789683FB7C7CAD227B6C5171AAC15 uri=/activemq-web-demo-4.0.1/amq
> query=null
> [2006-10-25 16:12:35.418 DEBUG] - doMessage timeout=25000
> [2006-10-25 16:12:39.264 DEBUG] - POST
> client=org.apache.activemq.web.WebClient@153b2cb
> session=B67789683FB7C7CAD227B6C5171AAC15 info=null
> contentType=application/x-www-form-urlencoded
> [2006-10-25 16:12:39.934  INFO] - ActiveMQ 4.0.1 JMS Message Broker
> (localhost) is starting
> [2006-10-25 16:12:39.934  INFO] - For help or more information please see:
> http://incubator.apache.org/activemq/
> [2006-10-25 16:12:47.185  INFO] - Database driver recognized:
> [apache_derby_embedded_jdbc_driver]
> [2006-10-25 16:12:50.249 DEBUG] - Executing SQL: CREATE TABLE
> ACTIVEMQ_MSGS(ID INTEGER NOT NULL, CONTAINER VARCHAR(250), MSGID_PROD
> VARCHAR(250), MSGID_SEQ INTEGER, EXPIRATION BIGINT, MSG BLOB, PRIMARY KEY (
> ID ) )
> [2006-10-25 16:12:51.741 DEBUG] - Could not create JDBC tables; The message
> table already existed. Failure was: CREATE TABLE ACTIVEMQ_MSGS(ID INTEGER
> NOT NULL, CONTAINER VARCHAR(250), MSGID_PROD VARCHAR(250), MSGID_SEQ
> INTEGER, EXPIRATION BIGINT, MSG BLOB, PRIMARY KEY ( ID ) ) Message:
> Table/View 'ACTIVEMQ_MSGS' already exists in Schema 'APP'. SQLState: X0Y32
> Vendor code: 20000
>
>
> --
> View this message in context: http://www.nabble.com/Why-not-using-MySQL-JDBC-persistence-in-embbed-mode-under-Tomcat-5.5.20--tf2506291.html#a6988116
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/