我使用的是WildFly 11,我已经将其配置为将消息持久保存到数据库中,但我已经创建了表,当服务器启动时,它会给出以下错误:
10:50:06,787 ERROR [org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver] (ServerService Thread Pool -- 74)
SQL STATEMENTS:
CREATE TABLE PAGE_STORE (ID BIGSERIAL, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA BYTEA, PRIMARY KEY(ID))
SQL EXCEPTIONS:
SQLState: 42P07 ErrorCode: 0 Message: ERROR: relation "page_store" already exists
10:50:06,950 WARN [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 74) AMQ222010: Critical IO Error, shutting down the server. file=NULL, message=Unable to start database driver: org.postgresql.util.PSQLException: ERROR: relation "page_store" already exists
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2422)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2167)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270)
at org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:244)
at org.jboss.jca.adapters.jdbc.WrappedStatement.executeUpdate(WrappedStatement.java:430)
at org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.createTableIfNotExists(AbstractJDBCDriver.java:194) [artemis-jdbc-store-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.createTable(AbstractJDBCDriver.java:112) [artemis-jdbc-store-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver.createSchema(JDBCSequentialFileFactoryDriver.java:69) [artemis-jdbc-store-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.start(AbstractJDBCDriver.java:82) [artemis-jdbc-store-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactory.start(JDBCSequentialFileFactory.java:127) [artemis-jdbc-store-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryDatabase.start(PagingStoreFactoryDatabase.java:124) [artemis-server-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.core.paging.impl.PagingStoreFactoryDatabase.<init>(PagingStoreFactoryDatabase.java:100) [artemis-server-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.getPagingStoreFactory(ActiveMQServerImpl.java:1854) [artemis-server-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.createPagingManager(ActiveMQServerImpl.java:1848) [artemis-server-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.initialisePart1(ActiveMQServerImpl.java:2015) [artemis-server-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation.run(LiveOnlyActivation.java:62) [artemis-server-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.internalStart(ActiveMQServerImpl.java:518) [artemis-server-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.start(ActiveMQServerImpl.java:466) [artemis-server-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl.start(JMSServerManagerImpl.java:413) [artemis-jms-server-1.5.5.jbossorg-008.jar:1.5.5.jbossorg-008]
at org.wildfly.extension.messaging.activemq.jms.JMSService.doStart(JMSService.java:205) [wildfly-messaging-activemq-11.0.0.Final.jar:11.0.0.Final]
at org.wildfly.extension.messaging.activemq.jms.JMSService.access$000(JMSService.java:64) [wildfly-messaging-activemq-11.0.0.Final.jar:11.0.0.Final]
at org.wildfly.extension.messaging.activemq.jms.JMSService$1.run(JMSService.java:99) [wildfly-messaging-activemq-11.0.0.Final.jar:11.0.0.Final]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_241]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_241]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_241]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_241]
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_241]
at org.jboss.threads.JBossThread.run(JBossThread.java:320) [jboss-threads-2.2.1.Final.jar:2.2.1.Final]
这是activemq服务器:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
<journal datasource="PostgresLocalDS"/>
<security-setting name="#">
<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
</security-setting>
<address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>
<http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
<http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
<http-acceptor name="http-acceptor" http-listener="default"/>
<http-acceptor name="http-acceptor-throughput" http-listener="default">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
<jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" connectors="http-connector" entries="java:jboss/exported/jms/RemoteConnectionFactory"/>
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
</server>
</subsystem>
我阅读了关于ActiveMQ子系统的模型参考,没有发现任何禁用自动创建日志表的属性。
删除SQL模板或从$JBOSS_HOME/modules/system/layers/base/org/wildfly/extension/messaging-activemq/main/database/journal-sql.properties
中删除文件的内容—它不起作用。
那么,有没有办法禁用自动创建?
没有办法禁用模式创建,但是AbstractJDBCDriver在创建表之前会检查表是否存在,请参阅代码。也许用于连接到数据库的用户没有获取元数据的权限。
在我的情况下,用户有权获取元数据,但基于@Domenico Francesco Bruscino的回答,我开始在AbstractJDBCDriver的代码中寻找,我开始调试并发现了该方法-检查表是否存在,查找大写的表名(这是默认值(,但在Postgres中创建的表是小写的,所以我将配置更改为:
<journal datasource="PostgresLocalDS" database="postgres" messages-table="messages"
bindings-table="bindings" large-messages-table="large_messages"
page-store-table="page_store" jms-bindings-table="jms_bindings"/>