我已经配置了位于 NAT 网关后面的 JBoss EAP 7.0。我的 JMS 客户机可以从同一服务器或同一网络的其他服务器成功连接到 JMS 队列,但是当同一个 JMS 客户机移出该网络并尝试通过 NAT 网关连接到 JMS 时,它无法连接到队列。在 VPC 中的开发环境和 AWS EC2 中都会遇到相同的行为。开发环境有一个NAT网关,我假设VPC也使用相同或类似的东西。
我从如何在 JBoss EAP 7 中配置 JMS 中找到的代码开始。这可以从同一服务器或同一网络进行连接,但不能通过NAT网关进行连接。
后来基于https://developer.jboss.org/message/933327#933327.修改了代码,但JMS客户机仍然没有成功
14:13:58.205 [Remoting "config-based-naming-client-endpoint" task-2] DEBUG org.jboss.remoting.remote.client - Client authentication failed for mechanism JBOSS-LOCAL-USER: javax.security.sasl.SaslException: Failed to read server challenge [Caused by java.io.FileNotFoundException: \home\xxxx\jboss-eap-7.0\standalone\tmp\auth\local4810015721206975876.challenge (The system cannot find the path specified)]
和
ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ119007: Cannot connect to server(s). Tried with all available servers.]
请查找服务器配置、JMS客户机代码和客户机控制台日志。这里的问题是什么?服务器以下列启动参数启动
./standalone.sh -c standalone-full.xml -b 192.168.1.154**
独立-完整.xml
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
<security-setting name="#">
<role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/>
</security-setting>
<address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/>
<http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/>
<http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
<http-acceptor name="http-acceptor" http-listener="default"/>
<http-acceptor name="http-acceptor-throughput" http-listener="default">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
<jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
<jms-queue name="fromNGSQueue" entries="java:/jboss/exported/jms/queue/fromNGS"/>
<jms-queue name="toNGSQueue" entries="java:/jboss/exported/jms/queue/toNGS"/>
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
<pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>
</server>
</subsystem>
客户端代码
private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
private static final String DEFAULT_DESTINATION = "jms/queue/toNGS";
private static final String DEFAULT_USERNAME = "user01";
private static final String DEFAULT_PASSWORD = "password01";
private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
private static final String PROVIDER_URL = "http-remoting://<pubic ip>:<public port>";
public static void main(String[] args) throws JMSException, NamingException {
Context namingContext = null;
// Set up the namingContext for the JNDI lookup
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, PROVIDER_URL);
env.put(Context.SECURITY_PRINCIPAL, DEFAULT_USERNAME);
env.put(Context.SECURITY_CREDENTIALS, DEFAULT_PASSWORD);
namingContext = new InitialContext(env);
Map<String, Object> connectionParams = new HashMap<String, Object>();
connectionParams.put(TransportConstants.HOST_PROP_NAME, "192.168.1.154");// <-- PUT THE NATTED IP HERE!
connectionParams.put(TransportConstants.PORT_PROP_NAME, "8080");
connectionParams.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, "true");
connectionParams.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, "http-acceptor");
TransportConfiguration transportConfiguration = new TransportConfiguration(
"org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory", connectionParams);
ConnectionFactory connectionFactory = ActiveMQJMSClient
.createConnectionFactoryWithoutHA(JMSFactoryType.QUEUE_CF, transportConfiguration);
Destination destination = (Destination) namingContext.lookup(DEFAULT_DESTINATION);
JMSContext context = connectionFactory.createContext();
JMSConsumer consumer = context.createConsumer(destination);
for (int i = 0; i < 2; i++) {
TextMessage text = (TextMessage) consumer.receive();
System.out.println(text.getText());
}
}
JMS客户端控制台日志
12:27:55.678 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
12:27:55.724 [main] DEBUG org.jboss.naming.remote.client.InitialContextFactory - Looking for jboss-naming-client.properties using classloader sun.misc.Launcher$AppClassLoader@14dad5dc
12:27:55.726 [main] DEBUG org.jboss.naming.remote.client.InitialContextFactory - jboss.naming.client.endpoint.create.options. has the following options {}
12:27:55.728 [main] DEBUG org.jboss.naming.remote.client.InitialContextFactory - jboss.naming.client.remote.connectionprovider.create.options. has the following options {}
12:27:55.755 [main] INFO org.xnio - XNIO version 3.3.6.Final
12:27:55.773 [main] INFO org.xnio.nio - XNIO NIO Implementation Version 3.3.6.Final
12:27:55.952 [Remoting "config-based-naming-client-endpoint" I/O-1] DEBUG org.xnio.nio - Started channel thread 'Remoting "config-based-naming-client-endpoint" I/O-1', selector sun.nio.ch.WindowsSelectorImpl@7c489b29
12:27:55.952 [Remoting "config-based-naming-client-endpoint" Accept] DEBUG org.xnio.nio - Started channel thread 'Remoting "config-based-naming-client-endpoint" Accept', selector sun.nio.ch.WindowsSelectorImpl@5a04f9ae
12:27:55.982 [main] INFO org.jboss.remoting - JBoss Remoting version 4.0.0.Final
12:27:56.004 [main] DEBUG org.jboss.naming.remote.client.InitialContextFactory - jboss.naming.client.connect.options. has the following options {}
12:27:56.118 [main] DEBUG org.apache.activemq.artemis.logs - using dummy address ffffffbf:ffffff8d:3:ffffffdf:fffffff8:118
12:27:57.212 [Remoting "config-based-naming-client-endpoint" task-2] DEBUG org.jboss.remoting.remote.client - Client authentication failed for mechanism JBOSS-LOCAL-USER: javax.security.sasl.SaslException: Failed to read server challenge [Caused by java.io.FileNotFoundException: \home\janaka\jboss-eap-7.0\standalone\tmp\auth\local5820875048219302259.challenge (The system cannot find the path specified)]
12:27:58.444 [main] DEBUG org.apache.activemq.artemis.core.client - Trying reconnection attempt 0/1
12:27:58.444 [main] DEBUG org.apache.activemq.artemis.core.client - Trying to connect with connector = org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory@402c4085, parameters = {httpUpgradeEnabled=true, port=8080, httpPpgradeEndpoint=http-acceptor, host=192.168.1.154} connector = null
12:27:58.458 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
12:27:58.461 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
12:27:58.461 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
12:27:58.462 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
12:27:58.462 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
12:27:58.463 [main] DEBUG io.netty.util.internal.PlatformDependent - Platform: Windows
12:27:58.464 [main] DEBUG io.netty.util.internal.PlatformDependent - Java version: 8
12:27:58.464 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false
12:27:58.464 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
12:27:58.464 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noJavassist: false
12:27:58.465 [main] DEBUG io.netty.util.internal.PlatformDependent - Javassist: unavailable
12:27:58.465 [main] DEBUG io.netty.util.internal.PlatformDependent - You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes. Please check the configuration for better performance.
12:27:58.465 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: C:\Users\user\AppData\Local\Temp (java.io.tmpdir)
12:27:58.466 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
12:27:58.466 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
12:27:58.468 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetectionLevel: simple
12:27:58.486 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
12:27:58.507 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
12:27:58.507 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
12:27:58.533 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 8
12:27:58.534 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 8
12:27:58.534 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
12:27:58.534 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
12:27:58.534 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
12:27:58.534 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512
12:27:58.534 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
12:27:58.534 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
12:27:58.534 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
12:27:58.534 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
12:27:58.549 [main] DEBUG org.apache.activemq.artemis.core.client - Started Netty Connector version 4.0.30.Final
12:27:58.549 [main] DEBUG org.apache.activemq.artemis.core.client - Remote destination: /192.168.1.154:8080
12:27:58.563 [main] DEBUG io.netty.util.internal.ThreadLocalRandom - -Dio.netty.initialSeedUniquifier: 0x438dd4a4617cb338 (took 1 ms)
12:27:58.594 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: unpooled
12:27:58.594 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 65536
12:28:19.630 [main] DEBUG org.apache.activemq.artemis.core.client - Connector towards NettyConnector [host=192.168.1.154, port=8080, httpEnabled=false, httpUpgradeEnabled=true, useServlet=false, servletPath=/messaging/ActiveMQServlet, sslEnabled=false, useNio=true] failed
12:28:19.672 [Remoting "config-based-naming-client-endpoint" task-9] DEBUG org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1 - Channel end notification received, closing channel Channel ID d05ad3fd (outbound) of Remoting connection 69856e6c to vishuo.ddns.net/203.116.141.46:1800
Exception in thread "main" javax.jms.JMSRuntimeException: Failed to create session factory
at org.apache.activemq.artemis.jms.client.JmsExceptionUtils.convertToRuntimeException(JmsExceptionUtils.java:88)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:262)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:248)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:238)
at com.vishuo.icmdb.ngs.jms.HelloWorldJMSConsumer2.main(HelloWorldJMSConsumer2.java:68)
Caused by: javax.jms.JMSException: Failed to create session factory
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:727)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:255)
... 3 more
Caused by: ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ119007: Cannot connect to server(s). Tried with all available servers.]
at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:775)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:724)
... 4 more
设置到外部IP的出站套接字绑定。< br >在“socket-binding-group”标记下添加以下行:
<outbound-socket-binding name="jms-http">
<remote-destination host="220.110.33.69" port="8080"/>
</outbound-socket-binding>
并将http-connector socket-binding分配给“subsystem xmlns = urn:JBoss:domain:messaging-ActiveMQ:1.0”标记下的“jms-http”:
<http-connector name="http-connector" endpoint="http-acceptor" socket-binding="jms-http"/>
<socket-binding-group ...>
...
<outbound-socket-binding name="http-external-jms">
<remote-destination host="${env.EXTERNAL_HOST}" port="${env.EXTERNAL_PORT}"/>
</outbound-socket-binding>
<outbound-socket-binding name="https-external-jms">
<remote-destination host="${env.EXTERNAL_HOST}" port="${env.EXTERNAL_PORT_SSL}"/>
</outbound-socket-binding>
</socket-binding-group>
<http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http-external-jms"/>
<http-connector name="https-connector" endpoint="https-acceptor" socket-binding="https-external-jms">
<param name="ssl-enabled" value="true"/>
</http-connector>
我正在使用spring boot连接到solace队列。我使用下面的教程连接到solace JMS队列。https://www.devglan.com/spring-boot/spring-jms-solace-example它能够连接到solace队列。当应用程序启动并且与solace队列的连接正常工作时,我们遇到了一个问题,但在solace队列停止运行一段时间后,spring boot应用程序
我很难弄清楚如何实现Spring Boot JMS Listener,在JBoss应用程序服务器中监听ActiveMQ队列。因此,我选择发布一个问题并用我的最终解决方案回答它,希望它可以为您节省几个小时。
问题内容: 我需要为响应创建一个临时队列,但是我需要知道是否可以通过消息的setJMSReplyTo方法发送响应队列对象而不连接到临时队列,因为回复线程根本无法得到该对象。 问题答案: 我通过使用InitialContext对象将临时队列绑定到jndi,以便可以从需要使用临时队列的线程中查找临时队列。 要获取临时队列,您只需要在需要使用它的代码中查找它:
我无法连接到具有SEDA队列的骆驼路线。在服务器端,我有以下配置: 我正在尝试从这样的独立客户端访问此路由: 但我的制作人无法连接到seda队列。无法按我的路线排队。无法在我的bean属性中添加camelContext。我正在获取“bean类的属性'camelContext'无效”。如果我将正文发送到SEDA队列,则消息将发送到那里,但不会发送到路由的下一个元素
我正在开发我的第一个Azure实现,我已经设置了我的Azure帐户,并且我使用NuGet为我的应用程序安装了正确的DLL和配置。当我将我的WCF客户端设置为指向服务总线队列并运行该方法时,会出现以下异常: 微软。ServiceBus.服务器错误 我的endpoint配置是: 我的行为是: 这个错误消息非常通用,我不确定我应该首先查看哪个位置
如果在发送接收到的消息时发生异常,则会丢失已接收到的消息。