Wildfly集群中的Eclipselink缓存协调

时间:2019-07-12 09:55:17

标签: wildfly eclipselink

我希望在运行于不同计算机上的Wildfly实例之间建立eclipselink缓存协调。我目前有一个主从设置,似乎可以在大多数方面使用。

在单个计算机上使用多个实例来实现这一点相对简单,我只需创建一个jms-topicconnection-factory并按如下所示设置persistence.xml即可。

我遇到了类似的问题:How to set up Eclipselink cache coordination with Wildfly,但对此并没有任何高兴。我尝试将jms.host的值设置为两台计算机的ip都没有成功。

我在下面附上了我认为是相关的代码。让我知道是否还有其他有用的方法。

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
            http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
             version="2.1">

    <persistence-unit name="ApplicationPu">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>application.datasource</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode>

        <properties>
            <property name="eclipselink.persistence-context.flush-mode" value="commit"/>
            <property name="eclipselink.jdbc.batch-writing" value="jdbc"/>
            <property name="eclipselink.jdbc.batch-writing.size" value="500"/>
            <property name="eclipselink.session-event-listener"
                      value="com.demo.app.common.eclipselink.GeometryInitializer"/>
            <property name="eclipselink.cache.coordination.protocol" value="jms" />
            <property name="eclipselink.cache.coordination.jms.topic" value="java:jboss/exported/jms/EclipseLinkCacheTopic" />
            <property name="eclipselink.cache.coordination.jms.factory" value="java:jboss/exported/jms/EclipseLinkCacheConnectionFactory" />
            <property name="eclipselink.cache.coordination.jms.reuse-topic-publisher" value="true" />
            <property name="eclipselink.cache.coordination.jms.host" value="XX.XX.XXX.XX:80" />

        </properties>
    </persistence-unit>

</persistence>

domain.xml

<subsystem xmlns="urn:jboss:domain:messaging-activemq:5.0">
    <server name="default">
        <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" redistribution-delay="1000"/>
        ...
        <http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/>
        <http-acceptor name="http-acceptor" http-listener="default"/>
        ...
        <jms-topic name="EclipseLinkCacheTopic" entries="java:jboss/exported/jms/EclipseLinkCacheTopic"/>
        <connection-factory name="EclipseLinkCacheConnectionFactory" entries="java:jboss/exported/jms/EclipseLinkCacheConnectionFactory" connectors="http-connector" ha="true" block-on-acknowledge="true" reconnect-attempts="-1"/>
    </server>
</subsystem>
.
.
.
<socket-binding-group name="full-ha-sockets" default-interface="public">
    <socket-binding name="http" port="${jboss.http.port:80}"/>
    <socket-binding name="https" port="${jboss.https.port:8443}"/>
    <socket-binding name="modcluster" multicast-address="${jboss.modcluster.multicast.address:224.0.1.105}" multicast-port="23364"/>
    <socket-binding name="jgroups-mping" interface="private" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/>
    <socket-binding name="jgroups-tcp" interface="private" port="7600"/>
    <socket-binding name="jgroups-udp" interface="private" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/>
    <socket-binding name="iiop" interface="unsecure" port="3528"/>
    <socket-binding name="iiop-ssl" interface="unsecure" port="3529"/>
    <socket-binding name="txn-recovery-environment" port="4712"/>
    <socket-binding name="txn-status-manager" port="4713"/>
    <outbound-socket-binding name="mail-smtp">
        <remote-destination host="localhost" port="25"/>
    </outbound-socket-binding>
</socket-binding-group>

当我在一台机器上更新对象时,另一台机器无法通过缓存协调工作检测到预期的更改。日志中没有错误,也没有任何迹象表明它不起作用。

如果有人有任何想法,或者我错过了明显的事情,我将不胜感激。

0 个答案:

没有答案