HornetQ 在与 WildFly 8.1 集群一起使用时使用 JNDI / 远程处理

HornetQ using JNDI / remoting when used with WildFly 8.1 cluster

之前 2 JBoss 6 个服务器(主服务器和从服务器)以 2 个不同的 IP 地址(127.0.0.1 和 127.0.0.2)启动,并且这 2 个服务器实例 运行 处于域模式。这些实例使用 HornetQ 来传达 Hibernate Search 的索引作业。 我正在尝试使用 Wildfly 而不是 JBoss.

创建类似的配置

主实例 运行 具有以下配置(仅发布片段)使用 port-offset = "220":

domain.xml-师傅:

<server-group name="other-server-group" profile="full-ha">
    <jvm name="default">
        <heap size="256m" max-size="1303m"/>
        <permgen max-size="256m"/>
    </jvm>
    <socket-binding-group ref="full-ha-sockets"/>
    <deployments>
        <deployment name="mc-ds.xml" runtime-name="mc-ds.xml"/>
        <deployment name="abc.ear" runtime-name="abc.ear"/>
    </deployments>
</server-group>

我正在尝试使用 Undertow 来处理 JMS 的连接和 HornetQ,配置如下:

  <subsystem xmlns="urn:jboss:domain:messaging:2.0">
            <hornetq-server>
                <security-enabled>false</security-enabled>
                <cluster-password>${jboss.messaging.cluster.password:root}</cluster-password>
                <journal-file-size>102400</journal-file-size>

                <connectors>
                    <http-connector name="http-connector" socket-binding="messaging">
                        <param key="http-upgrade-endpoint" value="http-acceptor"/>
                    </http-connector>
                    <http-connector name="http-connector-throughput" socket-binding="messaging-throughput">
                        <param key="http-upgrade-endpoint" value="http-acceptor-throughput"/>
                        <param key="batch-delay" value="50"/>
                    </http-connector>
                    <in-vm-connector name="in-vm" server-id="0"/>
                </connectors>

                <acceptors>
                    <http-acceptor http-listener="acceptors-messaging" name="http-acceptor"/>
                    <http-acceptor http-listener="acceptors-messaging-throughput" name="http-acceptor-throughput">
                        <param key="batch-delay" value="50"/>
                        <param key="direct-deliver" value="false"/>
                    </http-acceptor>
                    <in-vm-acceptor name="in-vm" server-id="0"/>
                </acceptors>




            ...
        <subsystem xmlns="urn:jboss:domain:undertow:1.1">
            <buffer-cache name="default"/>
            <server name="default-server">
                <ajp-listener name="ajp" socket-binding="ajp"/>
                <http-listener name="default" socket-binding="http"/>
                <http-listener name="remoting-connector" socket-binding="remoting"/>
                <http-listener name="acceptors-messaging" socket-binding="messaging"/>
                <http-listener name="acceptors-messaging-throughput" socket-binding="messaging-throughput"/>
                <host name="default-host" alias="localhost">
                    <location name="/" handler="welcome-content"/>
                    <filter-ref name="server-header"/>
                    <filter-ref name="x-powered-by-header"/>
                </host>
            </server>
            <servlet-container name="default">
                <jsp-config/>
            </servlet-container>
            <handlers>
                <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
            </handlers>
            <filters>
                <response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
                <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
            </filters>
        </subsystem>

           ...
        <socket-binding name="messaging" port="5445"/>
        <socket-binding name="messaging-throughput" port="5455"/>

我对远程处理也是如此。

<subsystem xmlns="urn:jboss:domain:remoting:2.0">
    <endpoint worker="default"/>
    <http-connector name="http-remoting-connector" connector-ref="remoting-connector" security-realm="ApplicationRealm"/>
</subsystem>

            ...
<socket-binding name="remoting" port="${jboss.http.port:4447}"/>
<socket-binding name="messaging-group" port="0" multicast-address="${jboss.messaging.group.address:231.7.7.7}" multicast-port="${jboss.messaging.group.port:9876}"/>

这允许我启动主实例并部署应用程序。该实例侦听端口 4667(4447 + 端口偏移量 220)。

然而,在从属实例上部署应用程序失败,因为它似乎无法连接到主实例。失败只发生在 Wildfly 而不是 JBoss.

即使也配置了 in-vm 连接器,从属实例也应该使用网络接口进行连接。

host.xml - 奴隶

...
<property name="hibernate.search.default.worker.jndi.java.naming.provider.url" value="remote://127.0.0.1:4667"/>
...

slave无法加载消息队列,因为与JNDI的连接失败,如slave的server.log所示。在本地测试设置中,slave 运行 与 master 在同一台机器上。

尽管在下面的日志中发现“ConnectException:操作失败,状态在 5000 毫秒后等待”,但捕获网络流量表明主机确认 (TCP ACK) 连接到其端口 4667。

如有任何指点或提示,我们将不胜感激。

来自 server.log 的错误消息 - 从站:

2015-03-26 09:34:43,226 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 59) MSC000001: Failed to start service jboss.persistenceunit."abc.ear/web.war#mc": org.jboss.msc.service.StartException in service jboss.persistenceunit."abc.ear/web.war#mc": org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager AssetDerivate

    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:172) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_40]
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_40]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_40]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_40]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager AssetDerivate
at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:265) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:528) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManagers(IndexManagerHolder.java:495) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.indexes.impl.IndexManagerHolder.buildEntityIndexBinding(IndexManagerHolder.java:104) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:363) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:219) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:143) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:74) [hibernate-search-orm-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:52) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:588) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.perform(EntityManagerFactoryBuilderImpl.java:850) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.perform(EntityManagerFactoryBuilderImpl.java:843) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:397) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) [jipijapa-hibernate4-3-1.0.1.Final.jar:]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.run(PersistenceUnitServiceImpl.java:154) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
... 8 more
Caused by: org.hibernate.search.SearchException: HSEARCH000164: Unable to lookup Search queue 'queue/hibernatesearch' and connection factory 'jms/RemoteConnectionFactory' for index 'AssetDerivate'
at org.hibernate.search.backend.impl.jms.JndiJMSBackendQueueProcessor.initializeJMSQueueConnectionFactory(JndiJMSBackendQueueProcessor.java:56) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.backend.impl.jms.JmsBackendQueueProcessor.initialize(JmsBackendQueueProcessor.java:77) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.backend.BackendFactory.createBackend(BackendFactory.java:85) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.backend.BackendFactory.createBackend(BackendFactory.java:53) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.createBackend(DirectoryBasedIndexManager.java:204) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:102) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:261) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
... 24 more
Caused by: javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://127.0.0.1:4667 (Operation failed with status WAITING after 5000 MILLISECONDS)] [Root exception is java.net.ConnectException: Operation failed with status WAITING after 5000 MILLISECONDS]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:240) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:87) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:129) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_40]
at javax.naming.InitialContext.lookup(InitialContext.java:417) [rt.jar:1.8.0_40]
at org.hibernate.search.backend.impl.jms.JndiJMSBackendQueueProcessor.initializeJMSQueueConnectionFactory(JndiJMSBackendQueueProcessor.java:53) [hibernate-search-engine-4.5.1.Final.jar:4.5.1.Final]
... 30 more
Caused by: java.net.ConnectException: Operation failed with status WAITING after 5000 MILLISECONDS
at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:97) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:198) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
... 38 more


ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([("deployment" => "abc.ear")]) - failure description: {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"abc.ear/web.war#mc\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"abc.ear/web.war#mc\": org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager AssetDerivate


Caused by: org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager AssetDerivate
Caused by: org.hibernate.search.SearchException: HSEARCH000164: Unable to lookup Search queue 'queue/hibernatesearch' and connection factory 'jms/RemoteConnectionFactory' for index 'AssetDerivate'
Caused by: javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://127.0.0.1:4667 (Operation failed with status WAITING after 5000 MILLISECONDS)] [Root exception is java.net.ConnectException: Operation failed with status WAITING after 5000 MILLISECONDS]
Caused by: java.net.ConnectException: Operation failed with status WAITING after 5000 MILLISECONDS"}}

搜索此消息时

Failed to connect to any server. Servers tried: [remote://127.0.0.1 

从你的堆栈跟踪中我发现这个问题听起来很相似:

As remoting port is not enabled anymore in Wildfly Beta1, you will need to use the http-remoting protocol and point to port 8080. https://developer.jboss.org/message/843963#843963

另一个类似的查询也指向 8080 作为 http-remoting 的新端口: https://developer.jboss.org/thread/239301?start=0&tstart=0

您可以尝试改用 8080(+ 您的端口偏移量)进行配置吗?