简体   繁体   English

ActiveMQ具有正确的方言,但SQL语句不正确AUTO_INCREMENT而不是IDENTITY表创建

[英]ActiveMQ has correct dialect but the SQL statements are incorrect AUTO_INCREMENT instead of IDENTITY tables creation

I'm using the following: 我正在使用以下内容:

  • JBoss Wildfly 15.0.1.Final JBoss Wildfly 15.0.1.Final
  • MSSQL JDBC connector (ie mssql-jdbc-7.2.2.jre11.jar) MSSQL JDBC连接器(即mssql-jdbc-7.2.2.jre11.jar)
  • standalone-full.xml 独立-full.xml

I believe I have setup everything correctly. 我相信我已经正确设置了一切。 The MSSQL JDBC jar is in the modules directory with its associated module.xml . MSSQL JDBC jar位于modules目录及其关联的module.xml The datasource is correctly defined and functional. 数据源已正确定义并正常运行。 ActiveMQ Artemis has been setup (works fine using the file system). 已设置ActiveMQ Artemis(使用文件系统正常工作)。 However when I attempt to have it use JDBC it fails trying to create the necessary tables with the following error: 但是,当我尝试使用JDBC时,尝试使用以下错误创建必要的表失败:

SQLState: S0001 ErrorCode: 102 Message: Incorrect syntax near AUTO_INCREMENT'.

So I'm wondering what is wrong. 所以我想知道出了什么问题。 ActiveMQ says it supports SQL Server, and it automatically figures out which SQL dialect to use based on the return value of the driver (I've checked that name with an 6.0 version of the driver and it is the same), also in the debug output it says ActiveMQ表示它支持SQL Server,并根据驱动程序的返回值自动确定要使用哪种SQL方言(我已经使用6.0版本的驱动程序检查了该名称,并且它是相同的),也在调试中输出它说

[org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl] ServerService Thread Pool -- 80) Detect database dialect as 'MSSQL'".

So that looks good. 所以看起来不错。 So I'm a bit confused on what is wrong and would like to get it to work. 所以我对错误感到困惑,并想让它发挥作用。 I'm providing the critical elements that I have in the standalone-full.xml . 我在standalone-full.xml提供了我所拥有的关键元素。 Is there any other setup I need or is this a bug? 我还需要其他任何设置,还是这个bug?

Is this also a symptom of a problem? 这也是问题的症状吗? (ie see the log output...the broker is not initialized with correct driver/url that was specified by the datasource definition) (即查看日志输出...未使用数据源定义指定的正确驱动程序/ URL初始化代理)

AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,jdbcDriverClassName=org.apache.derby.jdbc.EmbeddedDriver,jdbcConnectionUrl=null,messageTableName=AMQ_MESSAGES,bindingsTableName=AMQ_BINDINGS,largeMessageTableName=AMQ_LARGE_MESSAGES,pageStoreTableName=AMQ_PSTORE,)

excerpts from the standalone-full.xml settings 摘自standalone-full.xml设置

<extensions> 
   <extension module="org.wildfly.extension.messaging-activemq"/>
</extensions>

<datasources> 

<datasource jndi-name="java:/RMBM-DEFAULT-DS" pool-name="RMBM-DEFAULT-DS" enabled="true">
 <connection-url>jdbc:sqlserver://${rmbm.default.ds.host}:${rmbm.default.ds.port:1433};DatabaseName=${rmbm.default.ds.dbname}
 </connection-url>
<driver>SQLSVR</driver>
</datasource>

<drivers>
   <driver name="SQLSVR" module="com.microsoft.sqlserver.jdbc">
      <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver- class>
   </driver>
</drivers>

<subsystem xmlns="urn:jboss:domain:messaging-activemq:5.0">
  <server name="default">
    <journal datasource="RMBM-DEFAULT-DS" messages-table="AMQ_MESSAGES" bindings-table="AMQ_BINDINGS" 
      jms-bindings-table="AMQ_JMS_BINDINGS" large-messages-table="AMQ_LARGE_MESSAGES" page-store-table="AMQ_PGSTORE"/> 
</server>
</subsystem>

Here is a portion of the log output: 以下是日志输出的一部分:

18:36:27,116 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-8) WFLYMSGAMQ0001: AIO wasn't located on this platform, it will fall back to using pure Java NIO.
18:36:27,665 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:443
18:36:27,808 INFO  [org.jboss.ws.common.management] (MSC service thread 1-7) JBWS022052: Starting JBossWS 5.2.4.Final (Apache CXF 3.2.5.jbossorg-1) 
18:36:27,964 DEBUG [org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl] (MSC service thread 1-8) Detect database dialect as 'MSSQL'.
18:36:27,968 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-8) use JDBC store for Artemis server, bindingsTable:AMQ_BINDINGS
18:36:28,065 DEBUG [org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl] (ServerService Thread Pool -- 80) Starting server ActiveMQServerImpl::
18:36:28,069 DEBUG [org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl] (ServerService Thread Pool -- 80) Detected no Shared Store HA options on JDBC store
18:36:28,121 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,jdbcDriverClassName=org.apache.derby.jdbc.EmbeddedDriver,jdbcConnectionUrl=null,messageTableName=AMQ_MESSAGES,bindingsTableName=AMQ_BINDINGS,largeMessageTableName=AMQ_LARGE_MESSAGES,pageStoreTableName=AMQ_PSTORE,)
18:36:28,306 DEBUG [org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl] (ServerService Thread Pool -- 80) Detect database dialect as 'MSSQL'.
18:36:28,398 ERROR [org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver] (ServerService Thread Pool -- 80) 
SQL STATEMENTS: 
CREATE TABLE AMQ_LARGE_MESSAGES (ID BIGINT AUTO_INCREMENT, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA BLOB, PRIMARY KEY(ID))
SQL EXCEPTIONS: 
SQLState: S0001 ErrorCode: 102 Message: Incorrect syntax near 'AUTO_INCREMENT'.
18:36:28,425 WARN  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ222010: Critical IO Error, shutting down the server. file=NULL, message=Unable to start database driver: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'AUTO_INCREMENT'.
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1621)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:868)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:768)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2935)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:248)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:223)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(SQLServerStatement.java:711)
    at org.jboss.ironjacamar.jdbcadapters@1.4.11.Final//org.jboss.jca.adapters.jdbc.WrappedStatement.executeUpdate(WrappedStatement.java:430)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.createTableIfNotExists(AbstractJDBCDriver.java:258)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.createTable(AbstractJDBCDriver.java:118)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver.createSchema(JDBCSequentialFileFactoryDriver.java:69)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.start(AbstractJDBCDriver.java:83)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactory.start(JDBCSequentialFileFactory.java:131)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager.init(JDBCJournalStorageManager.java:92)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.<init>(AbstractJournalStorageManager.java:229)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager.<init>(JournalStorageManager.java:106)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager.<init>(JDBCJournalStorageManager.java:55)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.createStorageManager(ActiveMQServerImpl.java:2155)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.initialisePart1(ActiveMQServerImpl.java:2296)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation.run(LiveOnlyActivation.java:64)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.internalStart(ActiveMQServerImpl.java:535)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.start(ActiveMQServerImpl.java:474)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl.start(JMSServerManagerImpl.java:376)
    at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService.doStart(JMSService.java:206)
    at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService.access$000(JMSService.java:65)
    at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService$1.run(JMSService.java:100)

It appears that even though the dialect is correctly detected as MSSQL the broker doesn't have the corresponding SQL statements to properly support it. 看来即使方言被正确检测为MSSQL ,代理也没有相应的SQL语句来正确支持它。 The SQL statements for MSSQL were added in ActiveMQ Artemis 2.6.4 via ARTEMIS-2202 . MSSQL的SQL语句通过ARTEMIS-2202添加到ActiveMQ Artemis 2.6.4中。 You're using 2.6.3 so you don't have those. 您正在使用2.6.3,因此您没有这些。

Upgrading ActiveMQ Artemis in Wildfly can sometimes fail due to the tight coupling between the two so if you don't want to try upgrading you could theoretically crack open the artemis-jdbc-store jar file and add/replace these lines to journal-sql.properties 在Wildfly中升级ActiveMQ Artemis有时会因为两者之间的紧密耦合而失败,所以如果您不想尝试升级,理论上可以破解artemis-jdbc-store jar文件并将这些行添加/替换为journal-sql.properties

# MSSQL SQL statements
create-file-table.mssql=CREATE TABLE %s (ID BIGINT NOT NULL IDENTITY, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA VARBINARY(max), PRIMARY KEY(ID))
create-journal-table.mssql=CREATE TABLE %s(id BIGINT,recordType SMALLINT,compactCount SMALLINT,txId BIGINT,userRecordType SMALLINT,variableSize INTEGER,record VARBINARY(max),txDataSize INTEGER,txData VARBINARY(max),txCheckNoRecords INTEGER,seq BIGINT NOT NULL, PRIMARY KEY(seq))
max-blob-size.mssql=2147483647

Regarding the AMQ221000 log message that indicates there is an incorrect JDBC driver configuration...This is due to the fact that the ActiveMQ Artemis broker has its own JDBC driver configuration for when it's running standalone. 关于AMQ221000 ,指示JDBC驱动程序配置不正确...这是因为ActiveMQ Artemis代理在独立运行时具有自己的JDBC驱动程序配置。 When it's embedded in Wildfly and configured to use a datasource via JNDI then the standalone JDBC driver configuration isn't used. 当它嵌入Wildfly并配置为通过JNDI使用datasource ,则不使用独立的JDBC驱动程序配置。 It will simply look up the specified datasource and use that. 它将只查找指定的数据源并使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM