如何配置activemq以使用informix数据库?

时间:2013-04-12 11:33:18

标签: java-ee activemq informix

我正在使用apache activemq 5.8。这是我做的:

1)将informix jdbc jar(ifxjdbc-3.70-JC3.jar)放入activemq / libs / optional

2)在activemq.xml中声明bean:

 <bean id="informix-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.informix.jdbc.IfxDriver"/>
    <property name="url" value="jdbc:informix-sqli://192.168.7.30:21893/activemq_nightly:informixserver=ol_informix1170_1;IFX_LOCK_MODE_WAIT=20;IFX_ISOLATION_LEVEL=TRANSACTION_READ_UNCOMMITTED"/>
    <property name="username" value="XXXX" />
    <property name="password" value="XXXX" />
    <property name="maxActive" value="200" />
    <property name="poolPreparedStatements" value="true"/>
</bean>

3)更改activemq.xml中的持久性适配器:

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

我在informix连接字符串中设置了隔离级别,因为我得到了&#34;事务不受支持&#34;启动activemq时出错。 现在我得到了这个例外:

2013-04-12 14:21:23,196 | ERROR | Failed to start Apache ActiveMQ (localhost, null). Reason: java.io.IOException: Cannot create PoolableConnectionFactory (Transaction not available.) | org.apache.activemq.broker.BrokerService | main

java.io.IOException:无法创建PoolableConnectionFactory(交易不可用。)     at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:45)     at org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:65)     在org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.loadAdapter(JDBCPersistenceAdapter.java:440)     在org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(JDBCPersistenceAdapter.java:423)     在org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBCPersistenceAdapter.java:368)     在org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.init(JDBCPersistenceAdapter.java:289)     at org.apache.activemq.broker.LockableServiceSupport.preStart(LockableServiceSupport.java:79)     在org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:54)     在org.apache.activemq.broker.BrokerService.doStartPersistenceAdapter(BrokerService.java:623)     在org.apache.activemq.broker.BrokerService.startPersistenceAdapter(BrokerService.java:612)     在org.apache.activemq.broker.BrokerService.start(BrokerService.java:577)     at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:58)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     在java.lang.reflect.Method.invoke(Method.java:597)     在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1546)     在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1487)     在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)     在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)     在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)     at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:293)     在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)     在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)     在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)     在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)     在org.apache.xbean.spring.context.ResourceXmlApplicationContext。(ResourceXmlApplicationContext.java:64)     在org.apache.xbean.spring.context.ResourceXmlApplicationContext。(ResourceXmlApplicationContext.java:52)     在org.apache.activemq.xbean.XBeanBrokerFactory $ 1.(XBeanBrokerFactory.java:102)     at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:102)     在org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:66)     在org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)     在org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)     在org.apache.activemq.console.command.StartCommand.startBroker(StartCommand.java:115)     在org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:74)     在org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)     在org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:148)     在org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)     在org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:90)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     在java.lang.reflect.Method.invoke(Method.java:597)     在org.apache.activemq.console.Main.runTaskClass(Main.java:262)     在org.apache.activemq.console.Main.main(Main.java:115) 引起:org.apache.commons.dbcp.SQLNestedException:无法创建PoolableConnectionFactory(交易不可用。)     在org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)     在org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)     在org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)     at org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:58)     ......还有45个 引起:java.sql.SQLException:事务不可用。     在com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:413)     在com.informix.jdbc.IfxSqli.a(IfxSqli.java:3550)     在com.informix.jdbc.IfxSqli.E(IfxSqli.java:3871)     在com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2662)     在com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2578)     在com.informix.jdbc.IfxSqli.c(IfxSqli.java:1512)     at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2493)     在com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2430)     在com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:393)     在com.informix.jdbc.IfxStatement.a(IfxStatement.java:1326)     at com.informix.jdbc.IfxStatement.executeImpl(IfxStatement.java:1296)     在com.informix.jdbc.IfxStatement.c(IfxStatement.java:1007)     at com.informix.jdbc.IfxStatement.execute(IfxStatement.java:893)     at com.informix.jdbc.IfxSqliConnect.setServerIsolationLevel(IfxSqliConnect.java:6976)     在com.informix.jdbc.IfxSqliConnect.j(IfxSqliConnect.java:6947)     在com.informix.jdbc.IfxSqliConnect。(IfxSqliConnect.java:1766)     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)     在com.informix.jdbc.IfxDriver.connect(IfxDriver.java:254)     在org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)     在org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)     在org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)     在org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)     ......还有48个 引起:java.sql.SQLException     在com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:413)     在com.informix.jdbc.IfxSqli.E(IfxSqli.java:3876)

当我启动activemq时,我收到以下错误:

2 个答案:

答案 0 :(得分:2)

1)下载最新的activemq版本

2)vi ACTIVEMQ_HOME / conf / activemq.xml

3)添加以下bean配置以配置informix ds:

<bean id="informix-ds" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.informix.jdbc.IfxDriver"/>
<property name="jdbcUrl" value="jdbc:informix-sqli://192.168.7.30:21893/XXX:informixserver=ol_informix1170_1;IFX_LOCK_MODE_WAIT=20;IFX_ISOLATION_LEVEL=TRANSACTION_READ_UNCOMMITTED"/>
<property name="user" value="XXXXX" />
<property name="password" value="XXXX" />

                  

注意:Informix连接字符串应包含:IFX_ISOLATION_LEVEL = TRANSACTION_READ_UNCOMMITTED。数据源实现应该是com.mchange.v2.c3p0.ComboPooledDataSource

4)将ds寄存为持久性适配器:

    <persistenceAdapter>

- &GT;                   5)下载并复制c3p0-0.8.4.5.jar和ifxjdbc-3.70-JC3.jar到ACTIVEMQ_HOME / lib / optional

6)启动activemq并享受!

注意:如果activemq抱怨缺少db表,请检查数据库是否使用单字节字符集,或者手动创建具有适当约束的缺失表(仅适用于dev env)。

答案 1 :(得分:0)

一个好的猜测是informix help

中描述的内容
  

-122 ISAM错误:交易不可用。

     

已要求ISAM处理器标记a的开头或结尾   事务,但事务日志记录不起作用。对于C-ISAM   程序,此文件未通过日志记录打开。查看电话   isopen,并确保包含ISTRANS参数。对于SQL   产品,此数据库不支持事务日志记录。如果你   正在使用数据库服务器,拥有数据库服务器管理员   启用此数据库的日志记录。否则,请使用START DATABASE   用于开始事务记录的语句。在所有情况下,应该记录日志   仅在数据库完全备份后立即启动。