You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Dave cawthorn <da...@empired.com> on 2006/05/10 12:46:46 UTC

ActiveMQ and Sequoia Database -autocommit issue

Hi All,

I'm trying to get activemq 4.0 to work with sequoia (was previously c-jdbc)
but am running into a problem asociated with autocomit mode connections
trying to be commited when the broker starts up. I tried the solution that
works with mysql but the sequoia driver seems to ignore it.

here's a partial trace

ACTIVEMQ_HOME: C:\install\incubator-activemq-4.0\bin\..
Loading message broker from: xbean:activemq.xml
INFO  BrokerService                  - ActiveMQ 4.0 JMS Message Broker
(localhos
t) is starting
INFO  BrokerService                  - For help or more information please
see:
http://incubator.apache.org/activemq/
WARN  JDBCPersistenceAdapter         - Database driver NOT recognized:
[sequoia_
generic_driver].  Will use default JDBC implementation.
ERROR BrokerService                  - Failed to start ActiveMQ JMS Message
Brok
er. Reason: java.io.IOException: Trying to commit a connection in autocommit
mod
e
java.io.IOException: Trying to commit a connection in autocommit mode
        at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport
.java:42)
        at
org.apache.activemq.store.jdbc.TransactionContext.close(TransactionCo
ntext.java:125)
        at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(J
DBCPersistenceAdapter.java:253)
        at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBC
PersistenceAdapter.java:213)
        at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersi

here are the parts of my config

 <persistenceAdapter>
      <jdbcPersistenceAdapter dataSource="#sequoia-ds" />
    </persistenceAdapter>    


 <!-- Sequoia DataSource -->
<bean id="sequoia-ds" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
    <property name="driverClassName"
value="org.continuent.sequoia.driver.Driver"/>
    <property name="url"
value="jdbc:sequoia://localhost/vieo_ccs?relaxAutoCommit=true"/>
    <property name="username" value="postgres"/>
    <property name="password" value="postgres"/>
    <property name="poolPreparedStatements" value="true"/>
    <property name="defaultAutoCommit" value="true"/>
</bean>

any ideas on how to get the persistence adapter to set the connection to
autocommit=false? (the default connection for sequoia is autocommit=true)

regards
Dave

--
View this message in context: http://www.nabble.com/ActiveMQ-and-Sequoia-Database--autocommit-issue-t1590803.html#a4317014
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ and Sequoia Database -autocommit issue

Posted by Dave cawthorn <da...@empired.com>.
I traced through the code to see why I was getting an error reporting that i
was trying to commit a transaction when a connection was in autocommit mode.
I found that in the TransactionContext class's getConnection method the code
inspects the inTx boolean and sets the autocommit property depending on its
value. If it is not in a transaction the connection is left in autocommit
mode. Then I found that in the close method of the TransactionContext the
following:

 if( !inTx ) {
            try {
                executeBatch();
                
                /**
                 * we are not in a transaction so should not be committing
??
                 * This was previously commented out - but had
                 * adverse affects on testing - so it's back!
                 * 
                 */
                try{
                    executeBatch();
                } finally {
                    if (connection != null){
                        connection.commit();
                    }
                }

which was crashing when it got to the commit because the connection was in
autocommit. I suspect there is a query executed at startup that is not
inside a transaction so the autocommit property is not being set to false
and then when close method executes I get an error from the Sequoia driver
cause we are trying to commit on a connection that is set to autocommit.

May I suggest that the TransactionContexts close method be altered to:

 if( !inTx ) {
            try {
                executeBatch();
                
                /**
                 * we are not in a transaction so should not be committing
??
                 * This was previously commented out - but had
                 * adverse affects on testing - so it's back!
                 * 
                 */
                try{
                    executeBatch();
                } finally {
                    if (connection != null && !connection.getAutoCommit()) {
                        connection.commit();
                    }
                }

This fixed the problem for me and i was able to start the broker :-) But i
don't know enough about the code to be aware of any negative side effects...

Dave
--
View this message in context: http://www.nabble.com/ActiveMQ-and-Sequoia-Database--autocommit-issue-t1590803.html#a4389185
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ and Sequoia Database -autocommit issue

Posted by James Strachan <ja...@gmail.com>.
On 5/10/06, Dave cawthorn <da...@empired.com> wrote:
> Thanks James,
>
> I did a quick test of setting a Sequoia connection's autocommit property to
> false using
>  con.setAutoCommit(false); and both commits and rollbacks seem to work.

Hmm - autocommit seems to work fine for other databases though.

> I will go through the activemq source to see if i can see any other reason
> why its bombing.
>
> I was going to have a look at master/slave but from reading the forum there
> is no way to resume a master without stopping the slave and copying its data
> back to the master. So correct me if I'm wrong but eventually you have to
> down the service cause you only get one failover?

Yes - though the clients can auto-reconnect to another broker. So you
could bring a new broker up, let folks use that - then bring the old
master back on line when its all in sync again - then you have
continuous availability and no message loss.

The only missing feature is we don't have automatic old-master <->
slave-now-a-master synchronisation. Thats a manual process right now.


> I'm currently planning on using a replicated message store and having
> activemq as a hasingleton in a jboss cluster. This way only one broker will
> ever be active but messages will be replicated on two machines and I will be
> able to "fail back" to the first node if the second node fails because i
> have the ability to resync the masters message store when it comes back up.

Cool

> PS message groups do rock!

I *love* messsage groups!
-- 

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

Re: ActiveMQ and Sequoia Database -autocommit issue

Posted by Dave cawthorn <da...@empired.com>.
Thanks James,

I did a quick test of setting a Sequoia connection's autocommit property to
false using
 con.setAutoCommit(false); and both commits and rollbacks seem to work. 

I will go through the activemq source to see if i can see any other reason
why its bombing.

I was going to have a look at master/slave but from reading the forum there
is no way to resume a master without stopping the slave and copying its data
back to the master. So correct me if I'm wrong but eventually you have to
down the service cause you only get one failover?

I'm currently planning on using a replicated message store and having
activemq as a hasingleton in a jboss cluster. This way only one broker will
ever be active but messages will be replicated on two machines and I will be
able to "fail back" to the first node if the second node fails because i
have the ability to resync the masters message store when it comes back up. 

PS message groups do rock!
--
View this message in context: http://www.nabble.com/ActiveMQ-and-Sequoia-Database--autocommit-issue-t1590803.html#a4335276
Sent from the ActiveMQ - User forum at Nabble.com.


Re: ActiveMQ and Sequoia Database -autocommit issue

Posted by James Strachan <ja...@gmail.com>.
We use the JDBC API to set auto commit to be false; so it sounds like
sequoia might not be implementing JDBC properly. It might be worth
pinging the sequoia mail lists to see if they've got any bright ideas.

BTW another alternative if you want to replicate messages to two
locations is to use Master/Slave
http://activemq.org/MasterSlave


On 5/10/06, Dave cawthorn <da...@empired.com> wrote:
>
> Hi All,
>
> I'm trying to get activemq 4.0 to work with sequoia (was previously c-jdbc)
> but am running into a problem asociated with autocomit mode connections
> trying to be commited when the broker starts up. I tried the solution that
> works with mysql but the sequoia driver seems to ignore it.
>
> here's a partial trace
>
> ACTIVEMQ_HOME: C:\install\incubator-activemq-4.0\bin\..
> Loading message broker from: xbean:activemq.xml
> INFO  BrokerService                  - ActiveMQ 4.0 JMS Message Broker
> (localhos
> t) is starting
> INFO  BrokerService                  - For help or more information please
> see:
> http://incubator.apache.org/activemq/
> WARN  JDBCPersistenceAdapter         - Database driver NOT recognized:
> [sequoia_
> generic_driver].  Will use default JDBC implementation.
> ERROR BrokerService                  - Failed to start ActiveMQ JMS Message
> Brok
> er. Reason: java.io.IOException: Trying to commit a connection in autocommit
> mod
> e
> java.io.IOException: Trying to commit a connection in autocommit mode
>         at
> org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport
> .java:42)
>         at
> org.apache.activemq.store.jdbc.TransactionContext.close(TransactionCo
> ntext.java:125)
>         at
> org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(J
> DBCPersistenceAdapter.java:253)
>         at
> org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBC
> PersistenceAdapter.java:213)
>         at
> org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersi
>
> here are the parts of my config
>
>  <persistenceAdapter>
>       <jdbcPersistenceAdapter dataSource="#sequoia-ds" />
>     </persistenceAdapter>
>
>
>  <!-- Sequoia DataSource -->
> <bean id="sequoia-ds" class="org.apache.commons.dbcp.BasicDataSource"
> destroy-method="close">
>     <property name="driverClassName"
> value="org.continuent.sequoia.driver.Driver"/>
>     <property name="url"
> value="jdbc:sequoia://localhost/vieo_ccs?relaxAutoCommit=true"/>
>     <property name="username" value="postgres"/>
>     <property name="password" value="postgres"/>
>     <property name="poolPreparedStatements" value="true"/>
>     <property name="defaultAutoCommit" value="true"/>
> </bean>
>
> any ideas on how to get the persistence adapter to set the connection to
> autocommit=false? (the default connection for sequoia is autocommit=true)
>
> regards
> Dave
>
> --
> View this message in context: http://www.nabble.com/ActiveMQ-and-Sequoia-Database--autocommit-issue-t1590803.html#a4317014
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


--

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