我试图在wildfly 8.2上配置jmsbridge以连接两台远程服务器。
第一台服务器将消息放入本地队列JMSBridgeSourceQ,然后桥接器将消息移动到位于server2上的另一个队列JMSBridgeTargetQ。
我按照此示例http://everything-jboss.blogspot.it/2013/07/remote-jms-messaging-with-hornetq-on.html设置了standalone-full-ha.xml。
服务器1上的(源)我有以下消息传递部分:
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
<hornetq-server>
<!-- <security-enabled>false</security-enabled> -->
<!-- <cluster-password>${jboss.messaging.cluster.password:CHANGE ME!!}</cluster-password> -->
<cluster-password>********</cluster-password>
<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>
<netty-connector name="netty-remote" socket-binding="messaging-remote"/>
<in-vm-connector name="in-vm" server-id="0"/>
</connectors>
<acceptors>
<http-acceptor http-listener="default" name="http-acceptor"/>
<http-acceptor http-listener="default" 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>
<broadcast-groups>
<broadcast-group name="bg-group1">
<socket-binding>messaging-group</socket-binding>
<connector-ref>
http-connector
</connector-ref>
</broadcast-group>
</broadcast-groups>
<discovery-groups>
<discovery-group name="dg-group1">
<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>
<address-setting match="#">
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
<expiry-address>jms.queue.ExpiryQueue</expiry-address>
<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>
<redistribution-delay>1000</redistribution-delay>
</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">
<connectors>
<connector-ref connector-name="http-connector"/>
</connectors>
<entries>
<entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
</entries>
<ha>true</ha>
<block-on-acknowledge>true</block-on-acknowledge>
<reconnect-attempts>-1</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"/>
<entry name="java:jboss/DefaultJMSConnectionFactory"/>
</entries>
</pooled-connection-factory>
<pooled-connection-factory name="hornetq-ra-remote">
<transaction mode="xa"/>
<connectors>
<connector-ref connector-name="netty-remote"/>
</connectors>
<entries>
<entry name="java:/RemoteJmsXA"/>
</entries>
</pooled-connection-factory>
</jms-connection-factories>
<jms-destinations>
<jms-queue name="ExpiryQueue">
<entry name="java:/jms/queue/ExpiryQueue"/>
</jms-queue>
<jms-queue name="DLQ">
<entry name="java:/jms/queue/DLQ"/>
</jms-queue>
<jms-queue name="LocalServer1Q">
<entry name="queue/LocalServer1Q"/>
<entry name="java:jboss/exported/jms/queues/LocalServer1Q"/>
</jms-queue>
<jms-queue name="JMSBridgeSourceQ">
<entry name="queue/JMSBridgeSourceQ"/>
<entry name="java:jboss/exported/jms/queues/JMSBridgeSourceQ"/>
</jms-queue>
</jms-destinations>
</hornetq-server>
<jms-bridge name="simple-jms-bridge">
<source>
<connection-factory name="ConnectionFactory"/>
<destination name="queue/JMSBridgeSourceQ"/>
</source>
<target>
<connection-factory name="jms/RemoteConnectionFactory"/>
<destination name="jms/queues/JMSBridgeTargetQ"/>
<user>jmsuser</user>
<password>******</password>
<context>
<property key="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"/>
<property key="java.naming.provider.url" value="http-remoting://192.168.5.138:8080"/>
</context>
</target>
<quality-of-service>AT_MOST_ONCE</quality-of-service>
<failure-retry-interval>10000</failure-retry-interval>
<max-retries>-1</max-retries>
<max-batch-size>10</max-batch-size>
<max-batch-time>100</max-batch-time>
</jms-bridge>
</subsystem>
并添加outbound-socket-binding:
<outbound-socket-binding name="messaging-remote">
<remote-destination host="192.168.5.138" port="8080"/>
</outbound-socket-binding>
在server2(目标)上我只配置了队列:
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
<hornetq-server>
<!-- <cluster-password>${jboss.messaging.cluster.password:CHANGE ME!!}</cluster-password> -->
<cluster-password>*****</cluster-password>
<journal-file-size>102400</journal-file-size>
<!-- ### -->
<security-enabled>true</security-enabled>
<!-- ### -->
<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>
<connector-ref>http-connector</connector-ref>
</broadcast-group>
</broadcast-groups>
<discovery-groups>
<discovery-group name="dg-group1">
<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">
<connectors>
<connector-ref connector-name="http-connector"/>
</connectors>
<entries>
<entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
</entries>
<ha>true</ha>
<block-on-acknowledge>true</block-on-acknowledge>
<reconnect-attempts>-1</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="java:/jms/queue/ExpiryQueue"/>
</jms-queue>
<jms-queue name="DLQ">
<entry name="java:/jms/queue/DLQ"/>
</jms-queue>
<!-- ### -->
<jms-queue name="LocalServer2Q">
<entry name="queue/LocalServer2Q"/>
<entry name="java:jboss/exported/jms/queues/LocalServer2Q"/>
</jms-queue>
<jms-queue name="JMSBridgeTargetQ">
<entry name="queue/JMSBridgeTargetQ"/>
<entry name="java:jboss/exported/jms/queues/JMSBridgeTargetQ"/>
</jms-queue>
<!-- ### -->
</jms-destinations>
</hornetq-server>
</subsystem>
结果是当我启动server1时出现以下错误:
18:15:53,892 ERROR [org.jboss.remoting.remote.connection] (Remoting "config-based-naming-client-endpoint" I/O-1) JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: the server presented no authentication mechanisms
18:15:53,892 WARN [org.hornetq.jms.server] (pool-4-thread-1) HQ122010: Failed to connect JMS Bridge: javax.naming.AuthenticationException: Failed to connect to any server. Servers tried: [http-remoting://192.168.5.138:8080 (Authentication failed: the server presented no authentication mechanisms)] [Root exception is javax.security.sasl.SaslException: Authentication failed: the server presented no authentication mechanisms]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:238) [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(Unknown Source) [rt.jar:1.7.0_75]
at javax.naming.InitialContext.lookup(Unknown Source) [rt.jar:1.7.0_75]
at org.hornetq.jms.bridge.impl.JNDIFactorySupport.createObject(JNDIFactorySupport.java:56) [hornetq-jms-server-2.4.5.Final.jar:]
at org.hornetq.jms.bridge.impl.JNDIDestinationFactory.createDestination(JNDIDestinationFactory.java:38) [hornetq-jms-server-2.4.5.Final.jar:]
at org.hornetq.jms.bridge.impl.JMSBridgeImpl.setupJMSObjects(JMSBridgeImpl.java:1233) [hornetq-jms-server-2.4.5.Final.jar:]
at org.hornetq.jms.bridge.impl.JMSBridgeImpl.setupJMSObjectsWithRetry(JMSBridgeImpl.java:1471) [hornetq-jms-server-2.4.5.Final.jar:]
at org.hornetq.jms.bridge.impl.JMSBridgeImpl.access$2200(JMSBridgeImpl.java:76) [hornetq-jms-server-2.4.5.Final.jar:]
at org.hornetq.jms.bridge.impl.JMSBridgeImpl$FailureHandler.run(JMSBridgeImpl.java:2079) [hornetq-jms-server-2.4.5.Final.jar:]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_75]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_75]
Caused by: javax.security.sasl.SaslException: Authentication failed: the server presented no authentication mechanisms
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:388)
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:242)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.3.0.Final.jar:3.3.0.Final]
at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:199) [xnio-api-3.3.0.Final.jar:3.3.0.Final]
at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:113) [xnio-api-3.3.0.Final.jar:3.3.0.Final]
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.3.0.Final.jar:3.3.0.Final]
at org.xnio.ChannelListeners$DelegatingChannelListener.handleEvent(ChannelListeners.java:1092) [xnio-api-3.3.0.Final.jar:3.3.0.Final]
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.3.0.Final.jar:3.3.0.Final]
at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) [xnio-api-3.3.0.Final.jar:3.3.0.Final]
at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:539)
at ...asynchronous invocation...(Unknown Source)
at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:272)
at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:253)
at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:351)
at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:335)
at org.jboss.naming.remote.client.EndpointCache$EndpointWrapper.connect(EndpointCache.java:111) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:197) [jboss-remote-naming-2.0.1.Final.jar:2.0.1.Final]
... 16 more
在两台服务器上都有jmsuser,在ApplicationRealm中注册了相同的密码,但我认为这不是导致此错误的原因。
感谢任何帮助。
谢谢!
答案 0 :(得分:2)
我在WildFly 8.1上遇到了同样的问题。我通过在上下文中添加用户名和密码来解决这个问题。
<context>
<property key="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"/>
<property key="java.naming.provider.url" value="http-remoting://example.com:80"/>
<property key="java.naming.security.principal" value="user"/>
<property key="java.naming.security.credentials" value="password"/>
</context>