Клиент JMS для ActiveMQ на сервере Red Hat JBoss EAP 7.3 на Java

Я пишу клиент Java для подключения к моему серверу JBoss EAP 7.3, на котором запущен ActiveMQ, и получаю различные ответы на подключение при изменении параметров. Помогите пожалуйста поправить параметры / код. Я получил:

09:46:57.227 [main] INFO org.xnio.nio - XNIO NIO Implementation Version 3.4.6.Final
09:46:57.606 [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@17ab1d7e                                 ...
jboss.naming.client.connect.options. has the following options {}
09:46:57.763 [main] DEBUG org.jboss.naming.remote.client.HaRemoteNamingStore - Failed to connect to server http-remoting://127.0.0.1:8080
java.lang.RuntimeException: java.io.IOException: For now upgrade responses must have a content length of zero.
    at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:95)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:198)
...    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:146)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at com.goprecise.ams.demo.SendJmsToProcess.main(SendJmsToProcess.java:46)
Caused by: java.io.IOException: For now upgrade responses must have a content length of zero.
...     at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
    at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
    at org.xnio.nio.WorkerThread.run(WorkerThread.java:571)
...     at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:335)
    at org.jboss.naming.remote.client.EndpointCache$EndpointWrapper.connect(EndpointCache.java:122)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:197)
    ... 8 common frames omitted
javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [http-remoting://127.0.0.1:8080 (java.io.IOException: For now upgrade responses must have a content length of zero.)]
    at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)
    at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)

Это клиентский код Java в блоке try catch, который пытается подключиться:

            Properties env = new Properties();
            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
            env.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");  
            env.put(Context.SECURITY_PRINCIPAL,adminUser);
            env.put(Context.SECURITY_CREDENTIALS, adminPassword);
            Context  namingContext = new InitialContext(env);

            String CONNECTION_FACTORY = "java:jboss/exported/jms/RemoteConnectionFactory"; 
                        ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(CONNECTION_FACTORY);
            System.out.println("Got ConnectionFactory");

            Destination destination = (Destination) namingContext.lookup(QUEUE);  // Sure QUEUE is correct
            System.out.println("Got JMS Endpoint " + QUEUE);

            JMSContext context = connectionFactory.createContext(adminUser, adminPassword);
            context.createProducer().send(destination, xmlContent);
            System.out.println("Got JMS destination");

И это мои значения дерева JNDI в консоли управления EAP для java: jboss / exported ›› JMS ››

URI                    java:jboss/exported/jms/RemoteConnectionFactory
Class Name             org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory
Value                  ActiveMQConnectionFactory [serverLocator=ServerLocatorImpl 
                       [initialConnectors=[TransportConfiguration(name=http-connector, 
                       factory=org-apache-activemq-artemis-core-remoting-impl-netty-
                       NettyConnectorFactory) ?httpUpgradeEndpoint=http-                    
                       acceptor&activemqServerName=default&httpUpgradeEnabled=true&port=
                       8080&host=kubernetes-docker-internal], discoveryGroupConfiguration=null], 
                       clientID=null, consumerWindowSize = 1048576, dupsOKBatchSize=1048576, 
                       transactionBatchSize=1048576, readOnly=falseEnableSharedClientID=true]

person Dr Dave    schedule 18.11.2020    source источник


Ответы (1)


Мне кажется, вы используете неправильную реализацию InitialContextFactory. Попробуйте использовать org.wildfly.naming.client.WildFlyInitialContextFactory вместо org.jboss.naming.remote.client.InitialContextFactory.

Вы можете найти полный пример клиента JMS для JBoss EAP 7.3 здесь.

person Justin Bertram    schedule 18.11.2020
comment
Спасибо. Сделал несколько модификаций и не понимаю, как я получаю Attempting to acquire destination "java:/jms/queue/DLQ" javax.naming.NameNotFoundException: jms/queue/DLQ -- service jboss.naming.context.java.jboss.exported.jms.queue.DLQ at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207) заданный URI java:/jms/queue/DLQ Class Name org.apache.activemq.artemis.jms.client.ActiveMQQueue Value ActiveMQQueue[jms.queue.DLQ] в дереве JNDI сервера. - person Dr Dave; 18.11.2020
comment
Теперь это звучит как другая проблема. Я рекомендую вам создать новый вопрос с соответствующими деталями вместе с вашим messaging XML-файлом конфигурации подсистемы. - person Justin Bertram; 18.11.2020