[英]Infinispan JDBC Cache Store
我想使用Infinispan JDBC缓存存储而不是LevelDb缓存存储。
以下是我的配置:
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
xmlns="urn:infinispan:config:6.0"
xmlns:jdbc="urn:infinispan:config:jdbc:6.0" >
<global>
<globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>
</global>
<!-- Define the cache loaders (i.e., cache stores). Passivation is false
because we want *all* data to be persisted, not just what doesn't fit
into memory. -->
<persistence>
<mixedKeyedJdbcStore fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<simpleConnection connectionUrl="jdbc:postgresql://localhost:5432/infinispan_binary_based" driverClass="org.postgresql.Driver" username="postgres" password="postgres"/>
<stringKeyedTable prefix="ISPN_MIXED_STR_TABLE" createOnStart="true" dropOnExit="true">
<idColumn name="ID_COLUMN" type="VARCHAR(255)" />
<dataColumn name="DATA_COLUMN" type="BINARY" />
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
</stringKeyedTable>
<binaryKeyedTable prefix="ISPN_MIXED_BINARY_TABLE" createOnStart="true" dropOnExit="true">
<idColumn name="ID_COLUMN" type="VARCHAR(255)" />
<dataColumn name="DATA_COLUMN" type="BINARY" />
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
</binaryKeyedTable>
</mixedKeyedJdbcStore>
</persistence>
</namedCache>
但我不断收到此异常:
Message: Unexpected element '{urn:infinispan:config:jdbc:6.0}mixedKeyedJdbcStore'
at org.infinispan.configuration.parsing.ParserRegistry.parseElement(ParserRegistry.java:139) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]
at org.infinispan.configuration.parsing.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:37) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]
at org.infinispan.configuration.parsing.Parser60.parsePersistence(Parser60.java:558) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]
我从依赖项中删除了leveldb缓存存储罐,并用jdbc缓存存储罐替换了它。
你能告诉我是否错过了什么吗? 请帮助?
先感谢您。
您在声明一个名为jdbc的名称空间,但未使用它。 您需要在blendKeyedJdbcStore中的所有标签前面加上jdbc:前缀,或使用如下所示的默认名称空间:
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
xmlns="urn:infinispan:config:6.0"
xmlns:jdbc="urn:infinispan:config:jdbc:6.0" >
<global>
<globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>
</global>
<!-- Define the cache loaders (i.e., cache stores). Passivation is false
because we want *all* data to be persisted, not just what doesn't fit
into memory. -->
<namedCache name="testCache">
<persistence>
<mixedKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<simpleConnection connectionUrl="jdbc:postgresql://localhost:5432/infinispan_binary_based" driverClass="org.postgresql.Driver" username="postgres" password="postgres"/>
<stringKeyedTable prefix="ISPN_MIXED_STR_TABLE" createOnStart="true" dropOnExit="true">
<idColumn name="ID_COLUMN" type="VARCHAR(255)" />
<dataColumn name="DATA_COLUMN" type="BINARY" />
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
</stringKeyedTable>
<binaryKeyedTable prefix="ISPN_MIXED_BINARY_TABLE" createOnStart="true" dropOnExit="true">
<idColumn name="ID_COLUMN" type="VARCHAR(255)" />
<dataColumn name="DATA_COLUMN" type="BINARY" />
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
</binaryKeyedTable>
</mixedKeyedJdbcStore>
</persistence>
</namedCache>
您的配置也缺少起始的namedCache标记,但是我认为这是一个复制粘贴错误,否则错误消息将有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.