Getting "channel has already failed" exception publishing a message to ActiveMQ Artemis from Spring Boot using SSL

huangapple go评论55阅读模式
英文:

Getting "channel has already failed" exception publishing a message to ActiveMQ Artemis from Spring Boot using SSL

问题

我正在尝试使用Spring Boot通过SSL发布/监听ActiveMQ Artemis。关于如何做这个没有真正的文档。但是我在启动时遇到了一个异常,尝试连接到ActiveMQ,异常为channel has already failed。我该如何识别这个问题?

我遵循的步骤如下:

我创建了一个带有证书的密钥库/受信任的密钥库,如此处所述:

1. 使用keytool为经纪人创建证书:
keytool -genkey -alias broker -keyalg RSA -keystore broker.ks

2. 导出经纪人的证书以与客户共享:
keytool -export -alias broker -keystore broker.ks -file broker_cert

3. 为客户创建证书/密钥库:
keytool -genkey -alias client -keyalg RSA -keystore client.ks

4. 为客户创建一个信任库,并导入经纪人的证书。这建立了客户对经纪人的信任:
keytool -import -alias broker -keystore client.ts -file broker_cert

broker.xml中,通过acceptor添加了使用AMQP协议和sslEnabled的端口5671。存储和密码也提供了。密钥库和信任库也已复制到经纪人。如果我更改acceptor中的路径值,启动时会出错,因此我相信它们在正确的位置,经纪人可以访问它们。(我在末尾包含了完整的broker.xml

我的Spring Boot应用程序:

  • ActiveMQConfig.java定义了具有密钥库/受信任库和密码的连接工厂
  • Producer.java使用@Autowired的Spring JmsTemplate发送消息
  • AmqpsDemoApplication.java是一个空的@SpringBootApplication,带有main方法
  • application.properties为空
  • broker.ksclient.ts文件从上述创建中复制

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.5</version>
        <relativePath/>
    </parent>
    <groupId>demo</groupId>
    <artifactId>amqps-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

ActiveMQConfig.java设置了安全连接工厂:

import org.apache.activemq.ActiveMQConnectionConsumer;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQSslConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.core.JmsTemplate;

import javax.jms.ConnectionFactory;

@Configuration
@EnableJms
public class ActiveMQConfig {

    String BROKER_URL = "tcp://localhost:5671"; // 5671是我在broker.xml中配置的AMQP+SSL端口
    String BROKER_USERNAME = "admin";
    String BROKER_PASSWORD = "admin";

    @Bean
    public ActiveMQConnectionFactory connectionFactory() {
        final ActiveMQSslConnectionFactory f = new ActiveMQSslConnectionFactory(BROKER_URL);
        f.setUserName(BROKER_USERNAME);
        f.setPassword(BROKER_PASSWORD);
        f.setBrokerURL(BROKER_URL);

        try {
            f.setKeyStore("client.ts");
            f.setTrustStore("broker.ks");
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
        f.setKeyStorePassword("password");
        f.setTrustStorePassword("password");
        return f;
    }
}

Producer.java尝试将消息添加到队列

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class Producer {

    @Autowired
    JmsTemplate jmsTemplate;

    @PostConstruct    //在启动后触发发布一个虚拟消息
    public void sendMessage() {
        System.out.println("Sending myValue");
        jmsTemplate.send("inbound.queue", session -> session.createTextMessage("myValue"));
    }
}

完整的ActiveMQ broker.xml 如下:

<?xml version='1.0'?>
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
	<core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq:core ">
		<name>0.0.0.0</name>
		<persistence-enabled>true</persistence-enabled>
		<journal-type>NIO</journal-type>
		<paging-directory>data/paging</paging-directory>
		<bindings-directory>data/bindings</bindings-directory>
		<journal-directory>data/journal</journal-directory>
		<large-messages-directory>data/large-messages</large-messages-directory>
		<journal-datasync>true</journal-datasync>
		<journal-min-files>2</journal-min-files>
		<journal-pool-files>10</journal-pool-files>
		<journal-device-block-size>4096</journal-device-block-size>
		<journal-file-size>10M</journal-file-size>
		<journal-buffer-timeout

<details>
<summary>英文:</summary>

I am trying to publish/listen to ActiveMQ Artemis with Spring Boot using SSL. There is not really any documentation on how to do this.

But I am getting an exception on startup trying to connect to ActiveMQ with `channel has already failed`. How do I go about identifying the issue?

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'producer': Invocation of init method failed; nested exception is org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Cannot send, channel has already failed: tcp://127.0.0.1:5671
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.23.jar:5.3.23]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.23.jar:5.3.23]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.5.jar:2.7.5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.5.jar:2.7.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.5.jar:2.7.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.5.jar:2.7.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.5.jar:2.7.5]
at AmqpsDemoApplication.main(AmqpsDemoApplication.java:12) ~[classes/:na]
Caused by: org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Cannot send, channel has already failed: tcp://127.0.0.1:5671
at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:311) ~[spring-jms-5.3.23.jar:5.3.23]
at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:185) ~[spring-jms-5.3.23.jar:5.3.23]
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:507) ~[spring-jms-5.3.23.jar:5.3.23]
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:584) ~[spring-jms-5.3.23.jar:5.3.23]
at queues.Producer.sendMessage(Producer.java:17) ~[classes/:na]
at queues.Producer.doIt(Producer.java:22) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.3.23.jar:5.3.23]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.3.23.jar:5.3.23]
... 17 common frames omitted
Caused by: javax.jms.JMSException: Cannot send, channel has already failed: tcp://127.0.0.1:5671
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:80) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1423) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1488) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.ActiveMQConnection.createSession(ActiveMQConnection.java:332) ~[activemq-client-5.16.5.jar:5.16.5]
at org.springframework.jms.support.JmsAccessor.createSession(JmsAccessor.java:208) ~[spring-jms-5.3.23.jar:5.3.23]
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:495) ~[spring-jms-5.3.23.jar:5.3.23]
... 27 common frames omitted
Caused by: org.apache.activemq.transport.InactivityIOException: Cannot send, channel has already failed: tcp://127.0.0.1:5671
at org.apache.activemq.transport.AbstractInactivityMonitor.doOnewaySend(AbstractInactivityMonitor.java:328) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.transport.AbstractInactivityMonitor.oneway(AbstractInactivityMonitor.java:317) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.java:94) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:116) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:86) ~[activemq-client-5.16.5.jar:5.16.5]
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1394) ~[activemq-client-5.16.5.jar:5.16.5]
... 31 common frames omitted

The steps I followed are outlined below:

I created a keystore/trusted keystore with certs as outlined [here][1]:
  1. Using keytool, create a certificate for the broker:
    keytool -genkey -alias broker -keyalg RSA -keystore broker.ks

  2. Export the broker’s certificate so it can be shared with clients:
    keytool -export -alias broker -keystore broker.ks -file broker_cert

  3. Create a certificate/keystore for the client:
    keytool -genkey -alias client -keyalg RSA -keystore client.ks

  4. Create a truststore for the client, and import the broker’s certificate. This establishes that the client “trusts” the broker:
    keytool -import -alias broker -keystore client.ts -file broker_cert

In the `broker.xml` an `acceptor` was added on port `5671` with an AMQP protocol + `sslEnabled` and the stores and passwords provided. The keystore and truststores has been copied over to the broker as well. If I do change the paths values in the `acceptor` I get an error on startup hence I believe that they are in the correct place and that the broker can access them. (I have included a full `broker.xml` at the end)
```xml
&lt;acceptor name=&quot;amqps&quot;&gt;tcp://0.0.0.0:5671?protocols=AMQP;sslEnabled=true;keyStorePath=/opt/app/store/broker.ks;keyStorePassword=password;trustStorePath=/opt/app/store/client.ts;trustStorePassword=password;;enabledProtocols=TLSv1.2;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;useEpoll=true;amqpCredits=1000;amqpMinCredits=300&lt;/acceptor&gt;

My Spring Boot application:

Getting "channel has already failed" exception publishing a message to ActiveMQ Artemis from Spring Boot using SSL

  • ActiveMQConfig.java defines the connection factory with keystore/trustedstore & passwords
  • Producer.java sends a message using an @Autowired Spring JmsTemplate
  • AmqpsDemoApplication.java is an empty @SpringBootApplication with the main method
  • application.properties are empty
  • broker.ks and client.ts files are copied from the creation as outlined above

pom.xml

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;parent&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
        &lt;version&gt;2.7.5&lt;/version&gt;
        &lt;relativePath/&gt;
    &lt;/parent&gt;
    &lt;groupId&gt;demo&lt;/groupId&gt;
    &lt;artifactId&gt;amqps-demo&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;properties&gt;
        &lt;java.version&gt;17&lt;/java.version&gt;
    &lt;/properties&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-activemq&lt;/artifactId&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;

    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;
&lt;/project&gt;

ActiveMQConfig.java sets up the secure connection factory:

import org.apache.activemq.ActiveMQConnectionConsumer;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQSslConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.core.JmsTemplate;

import javax.jms.ConnectionFactory;

@Configuration
@EnableJms
public class ActiveMQConfig {

    String BROKER_URL = &quot;tcp://localhost:5671&quot;; // 5671 which is my AMQP+SSL config in my broker.xml
                                                // changing the port back to 61616 still works but that bypasses SSL
    String BROKER_USERNAME = &quot;admin&quot;;
    String BROKER_PASSWORD = &quot;admin&quot;;

    @Bean
    public ActiveMQConnectionFactory connectionFactory() {
        final ActiveMQSslConnectionFactory f = new ActiveMQSslConnectionFactory(BROKER_URL);
        f.setUserName(BROKER_USERNAME);
        f.setPassword(BROKER_PASSWORD);
        f.setBrokerURL(BROKER_URL);

        try {
            f.setKeyStore(&quot;client.ts&quot;);
            f.setTrustStore(&quot;broker.ks&quot;);
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
        f.setKeyStorePassword(&quot;password&quot;);
        f.setTrustStorePassword(&quot;password&quot;);
        return f;
    }
}

Producer.java which tries to add a message to a queue

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class Producer {

    @Autowired
    JmsTemplate jmsTemplate;

    @PostConstruct    //Triggers publishing a dummy message after startup
    public void sendMessage() {
        System.out.println(&quot;Sending myValue&quot;);
        jmsTemplate.send(&quot;inbound.queue&quot;, session -&gt; session.createTextMessage(&quot;myValue&quot;));
    }
}

The full ActiveMQ broker.xml is as follows:

&lt;?xml version=&#39;1.0&#39;?&gt;
&lt;configuration xmlns=&quot;urn:activemq&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xi=&quot;http://www.w3.org/2001/XInclude&quot; xsi:schemaLocation=&quot;urn:activemq /schema/artemis-configuration.xsd&quot;&gt;
	&lt;core xmlns=&quot;urn:activemq:core&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;urn:activemq:core &quot;&gt;
		&lt;name&gt;0.0.0.0&lt;/name&gt;
		&lt;persistence-enabled&gt;true&lt;/persistence-enabled&gt;
		&lt;journal-type&gt;NIO&lt;/journal-type&gt;
		&lt;paging-directory&gt;data/paging&lt;/paging-directory&gt;
		&lt;bindings-directory&gt;data/bindings&lt;/bindings-directory&gt;
		&lt;journal-directory&gt;data/journal&lt;/journal-directory&gt;
		&lt;large-messages-directory&gt;data/large-messages&lt;/large-messages-directory&gt;
		&lt;journal-datasync&gt;true&lt;/journal-datasync&gt;
		&lt;journal-min-files&gt;2&lt;/journal-min-files&gt;
		&lt;journal-pool-files&gt;10&lt;/journal-pool-files&gt;
		&lt;journal-device-block-size&gt;4096&lt;/journal-device-block-size&gt;
		&lt;journal-file-size&gt;10M&lt;/journal-file-size&gt;
		&lt;journal-buffer-timeout&gt;4040000&lt;/journal-buffer-timeout&gt;
		&lt;journal-max-io&gt;1&lt;/journal-max-io&gt;
		&lt;disk-scan-period&gt;5000&lt;/disk-scan-period&gt;
		&lt;max-disk-usage&gt;90&lt;/max-disk-usage&gt;
		&lt;critical-analyzer&gt;true&lt;/critical-analyzer&gt;
		&lt;critical-analyzer-timeout&gt;120000&lt;/critical-analyzer-timeout&gt;
		&lt;critical-analyzer-check-period&gt;60000&lt;/critical-analyzer-check-period&gt;
		&lt;critical-analyzer-policy&gt;HALT&lt;/critical-analyzer-policy&gt;
		&lt;page-sync-timeout&gt;4040000&lt;/page-sync-timeout&gt;
		&lt;global-max-messages&gt;-1&lt;/global-max-messages&gt;
		&lt;acceptors&gt;
			&lt;!-- AMQPS Acceptor.  Here the stores and passwords are specified.--&gt;
			&lt;acceptor name=&quot;amqps&quot;&gt;tcp://0.0.0.0:5671?protocols=AMQP;sslEnabled=true;keyStorePath=/opt/app/store/broker.ks;keyStorePassword=password;trustStorePath=/opt/app/store/client.ts;trustStorePassword=password;;enabledProtocols=TLSv1.2;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;useEpoll=true;amqpCredits=1000;amqpMinCredits=300&lt;/acceptor&gt;
			&lt;acceptor name=&quot;amqp&quot;&gt;tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpMinLargeMessageSize=102400;amqpDuplicateDetection=true&lt;/acceptor&gt;
		&lt;/acceptors&gt;
		&lt;security-settings&gt;
			&lt;security-setting match=&quot;#&quot;&gt;
				&lt;permission type=&quot;createNonDurableQueue&quot; roles=&quot;amq&quot;/&gt;
				&lt;permission type=&quot;deleteNonDurableQueue&quot; roles=&quot;amq&quot;/&gt;
				&lt;permission type=&quot;createDurableQueue&quot; roles=&quot;amq&quot;/&gt;
				&lt;permission type=&quot;deleteDurableQueue&quot; roles=&quot;amq&quot;/&gt;
				&lt;permission type=&quot;createAddress&quot; roles=&quot;amq&quot;/&gt;
				&lt;permission type=&quot;deleteAddress&quot; roles=&quot;amq&quot;/&gt;
				&lt;permission type=&quot;consume&quot; roles=&quot;amq&quot;/&gt;
				&lt;permission type=&quot;browse&quot; roles=&quot;amq&quot;/&gt;
				&lt;permission type=&quot;send&quot; roles=&quot;amq&quot;/&gt;
				&lt;!-- we need this otherwise ./artemis data imp wouldn&#39;t work --&gt;
				&lt;permission type=&quot;manage&quot; roles=&quot;amq&quot;/&gt;
			&lt;/security-setting&gt;
		&lt;/security-settings&gt;
		&lt;address-settings&gt;
			&lt;!-- if you define auto-create on certain queues, management has to be auto-create --&gt;
			&lt;address-setting match=&quot;activemq.management#&quot;&gt;
				&lt;dead-letter-address&gt;DLQ&lt;/dead-letter-address&gt;
				&lt;expiry-address&gt;ExpiryQueue&lt;/expiry-address&gt;
				&lt;redelivery-delay&gt;0&lt;/redelivery-delay&gt;
				&lt;!-- with -1 only the global-max-size is in use for limiting --&gt;
				&lt;max-size-bytes&gt;-1&lt;/max-size-bytes&gt;
				&lt;message-counter-history-day-limit&gt;10&lt;/message-counter-history-day-limit&gt;
				&lt;address-full-policy&gt;PAGE&lt;/address-full-policy&gt;
				&lt;auto-create-queues&gt;true&lt;/auto-create-queues&gt;
				&lt;auto-create-addresses&gt;true&lt;/auto-create-addresses&gt;
			&lt;/address-setting&gt;
			&lt;!--default for catch all--&gt;
			&lt;address-setting match=&quot;#&quot;&gt;
				&lt;dead-letter-address&gt;DLQ&lt;/dead-letter-address&gt;
				&lt;expiry-address&gt;ExpiryQueue&lt;/expiry-address&gt;
				&lt;redelivery-delay&gt;0&lt;/redelivery-delay&gt;
				&lt;max-size-bytes&gt;-1&lt;/max-size-bytes&gt;
				&lt;max-size-messages&gt;-1&lt;/max-size-messages&gt;
				&lt;page-size-bytes&gt;10M&lt;/page-size-bytes&gt;
				&lt;max-read-page-messages&gt;-1&lt;/max-read-page-messages&gt;
				&lt;max-read-page-bytes&gt;20M&lt;/max-read-page-bytes&gt;
				&lt;message-counter-history-day-limit&gt;10&lt;/message-counter-history-day-limit&gt;
				&lt;address-full-policy&gt;PAGE&lt;/address-full-policy&gt;
				&lt;auto-create-queues&gt;true&lt;/auto-create-queues&gt;
				&lt;auto-create-addresses&gt;true&lt;/auto-create-addresses&gt;
				&lt;auto-delete-queues&gt;false&lt;/auto-delete-queues&gt;
				&lt;auto-delete-addresses&gt;false&lt;/auto-delete-addresses&gt;
			&lt;/address-setting&gt;
		&lt;/address-settings&gt;
		&lt;addresses&gt;
			&lt;address name=&quot;DLQ&quot;&gt;
				&lt;anycast&gt;
					&lt;queue name=&quot;DLQ&quot;/&gt;
				&lt;/anycast&gt;
			&lt;/address&gt;
			&lt;address name=&quot;ExpiryQueue&quot;&gt;
				&lt;anycast&gt;
					&lt;queue name=&quot;ExpiryQueue&quot;/&gt;
				&lt;/anycast&gt;
			&lt;/address&gt;
		&lt;/addresses&gt;
	&lt;/core&gt;
&lt;/configuration&gt;

答案1

得分: 1

在 ActiveMQ Artemis 的配置中,您正在使用 amqps 接受者:

protocols=AMQP

这意味着该接受者接受 AMQP 协议连接。

然而,在您的应用程序中,您正在使用 org.apache.activemq.ActiveMQSslConnectionFactory,该工厂使用的是 OpenWire 协议,而不是 AMQP。

因此,您需要更改接受者配置以支持 OpenWire,例如:

protocols=AMQP,OPENWIRE

或更改您的应用程序正在使用的 JMS 实现为 Qpid JMS,它支持 AMQP。

英文:

In the configuration for ActiveMQ Artemis you're using this on the amqps acceptor:

protocols=AMQP

This means that this acceptor will only accept AMQP protocol connections.

However, in your application you're using a org.apache.activemq.ActiveMQSslConnectionFactory which uses the OpenWire protocol, not AMQP.

Therefore, you either need to change your acceptor configuration to support OpenWire, e.g.:

protocols=AMQP,OPENWIRE

Or change the JMS implementation that your application is using to Qpid JMS which speaks AMQP.

huangapple
  • 本文由 发表于 2023年4月20日 03:35:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76058216.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定