JBoss Wildfly JMS 客户端抛出服务器连接失败错误

Posted

技术标签:

【中文标题】JBoss Wildfly JMS 客户端抛出服务器连接失败错误【英文标题】:JBoss Wildfly JMS client throws Server connection failure error 【发布时间】:2015-04-20 20:28:39 【问题描述】:

我正在尝试在 JBoss WildFly 中配置 JMS 集群,并有一个我想运行和测试我的配置的客户端代码(实际上是用于 JBoss 7)。我在其中一篇文章中看到 WildFly 中不再提供“remote://”URL,因此我们必须使用“http-remoting://localhost:8080”。当我使用旧代码时,它最初抛出错误说“http-remoting”不可用。但是当我升级并再次运行时,我收到以下错误:

javax.naming.NamingException: Failed to connect to any server. Servers tried: [http-remoting://127.0.0.1:8080]

我的standalone-full-ha.xml相关栏目:

    <socket-binding name="management-http" interface="management" port="$jboss.management.http.port:9990"/>
    <socket-binding name="management-https" interface="management" port="$jboss.management.https.port:9993"/>
    <socket-binding name="ajp" port="$jboss.ajp.port:8009"/>
    <socket-binding name="http" port="$jboss.http.port:8080"/>
    <socket-binding name="https" port="$jboss.https.port:8443"/>
    <socket-binding name="jacorb" interface="unsecure" port="3528"/>
    <socket-binding name="jacorb-ssl" interface="unsecure" port="3529"/>
    <socket-binding name="jgroups-mping" port="0" multicast-address="$jboss.default.multicast.address:230.0.0.4" multicast-port="45700"/>
    <socket-binding name="jgroups-tcp" port="7600"/>
    <socket-binding name="jgroups-tcp-fd" port="57600"/>
    <socket-binding name="jgroups-udp" port="55200" multicast-address="$jboss.default.multicast.address:230.0.0.4" multicast-port="45688"/>
    <socket-binding name="jgroups-udp-fd" port="54200"/>
    <socket-binding name="messaging-group" port="0" multicast-address="$jboss.messaging.group.address:231.7.7.7" multicast-port="$jboss.messaging.group.port:9876"/>
    <socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/>
    <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>

    <hornetq-server>
            <clustered>true</clustered>
            <shared-store>true</shared-store>
            <cluster-user>admin</cluster-user>
            <cluster-password>changeit</cluster-password>
            <failover-on-shutdown>true</failover-on-shutdown>
            <journal-file-size>102400</journal-file-size>
            <connectors>
                <http-connector name="http-connector" socket-binding="http">
                    <param key="http-upgrade-endpoint" value="http-acceptor"/>
                </http-connector>
                <http-connector name="http-connector-throughput" socket-binding="http">
                    <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 name="http-acceptor" http-listener="default"/>
                <http-acceptor name="http-acceptor-throughput" http-listener="default">
                    <param key="batch-delay" value="50"/>
                    <param key="direct-deliver" value="false"/>
                </http-acceptor>
                <in-vm-acceptor name="in-vm" server-id="0"/>
            </acceptors>
            <broadcast-groups>
                <broadcast-group name="bg-group1">
                    <socket-binding>messaging-group</socket-binding>
                     <broadcast-period>2000</broadcast-period>
                    <connector-ref>http-connector</connector-ref>
                </broadcast-group>
            </broadcast-groups>
            <discovery-groups>
                <discovery-group name="dg-group1">
                    <refresh-timeout>10000</refresh-timeout>
                    <socket-binding>messaging-group</socket-binding>
                </discovery-group>
            </discovery-groups>
            <cluster-connections>
                <cluster-connection name="my-cluster">
                    <address>jms</address>
                    <connector-ref>http-connector</connector-ref>
                    <discovery-group-ref discovery-group-name="dg-group1"/>
                </cluster-connection>
            </cluster-connections>
            <security-settings>
                <security-setting match="#">
                    <permission type="send" roles="guest"/>
                    <permission type="consume" roles="guest"/>
                    <permission type="createNonDurableQueue" roles="guest"/>
                    <permission type="deleteNonDurableQueue" roles="guest"/>
                </security-setting>
            </security-settings>
            <address-settings>
                <!--default for catch all-->
                <address-setting match="#">
                    <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                    <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                    <redistribution-delay>1000</redistribution-delay>
                    <max-size-bytes>10485760</max-size-bytes>
                    <page-size-bytes>2097152</page-size-bytes>
                    <message-counter-history-day-limit>10</message-counter-history-day-limit>
                </address-setting>
            </address-settings>
            <jms-connection-factories>
                <connection-factory name="InVmConnectionFactory">
                    <connectors>
                        <connector-ref connector-name="in-vm"/>
                    </connectors>
                    <entries>
                        <entry name="java:/ConnectionFactory"/>
                    </entries>
                </connection-factory>
                <connection-factory name="RemoteConnectionFactory">
                    <discovery-group-ref discovery-group-name="dg-group1"/>
                    <entries>
                        <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                    </entries>
                    <ha>true</ha>
                    <client-failure-check-period>10</client-failure-check-period>
                    <retry-interval>1000</retry-interval>
                    <retry-interval-multiplier>1.5</retry-interval-multiplier>
                    <max-retry-interval>60000</max-retry-interval>
                    <reconnect-attempts>1000</reconnect-attempts>
                </connection-factory>
                <pooled-connection-factory name="hornetq-ra">
                    <transaction mode="xa"/>
                    <connectors>
                        <connector-ref connector-name="in-vm"/>
                    </connectors>
                    <entries>
                        <entry name="java:/JmsXA"/>
                        <!-- Global JNDI entry used to provide a default JMS Connection factory to EE application -->
                        <entry name="java:jboss/DefaultJMSConnectionFactory"/>
                    </entries>
                </pooled-connection-factory>
            </jms-connection-factories>
            <jms-destinations>
                <jms-queue name="ExpiryQueue">
                    <entry name="jms/queue/ExpiryQueue"/>
                    <entry name="jboss/exported/jms/queue/ExpiryQueue"/>
                </jms-queue>
                <jms-queue name="DLQ">
                    <entry name="jms/queue/DLQ"/>
                    <entry name="jboss/exported/jms/queue/DLQ"/>
                </jms-queue>
            </jms-destinations>
   </hornetq-server>

我们是否必须在 standalone-full-ha.xml 中配置一些额外的东西来解决“http-remoting”的问题?

谢谢, 稻谷

PS:我不知道 *** 是否允许附加文件,但我的编辑器没有显示任何附加选项,所以请耐心等待。

【问题讨论】:

【参考方案1】:

socket-binding-group 中添加以下行解决了这个问题。

<socket-binding name="remoting" port="$jboss.http.port:8080"/>

问候, 稻谷

【讨论】:

以上是关于JBoss Wildfly JMS 客户端抛出服务器连接失败错误的主要内容,如果未能解决你的问题,请参考以下文章

wildfly / jboss-eap:如何命名 JMS 资源以匹配 EJB2 ejb-jar.xml

在 jboss wildfly 应用程序上部署抛出警告

如何使用 ActiveMQ Artemis 在 Wildfly 24 服务上配置 jms-queue

Wildfly10中JMS队列的JNDI名称格式

Java EE 远程客户的访问EJB实现实例(Jboss wildfly)

集群 Wildfly 抛出 java.lang.IllegalAccessError