首页 > 解决方案 > Artemis 的生产者问题

问题描述

您好,我正在尝试将消息生成到我的服务器中上传的队列中,并且我正在使用 spring-boot-starter-artemis。当我从服务器端发送消息时,我的消费者没有任何问题,我的应用程序可以使用它。但是在尝试生成时,我得到了这个异常:javax.jms.JMSException: There is no queue with name myqueueName

@Component
public class ArtemisProducer {
    @Autowired
    JmsTemplate jmsTemplate;
    
    @Value("${jms.queue.destination}")
    String destinationQueue;
    
    public void send(String msg){
        jmsTemplate.convertAndSend(destinationQueue, msg);
    }
}

配置文件:

spring.artemis.mode=native
spring.artemis.host=host
spring.artemis.port=port
spring.artemis.user=username
spring.artemis.password=password
jms.queue.destination=myqueue

例外 :

  "exception": "org.springframework.jms.UncategorizedJmsException",
  "message": "Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: There is no queue with name myqueue",

标签: spring-bootactivemq-artemis

解决方案


默认情况下,地址和队列都是自动创建的。听起来您的经纪人已禁用此功能。您应该使用以下地址设置启用自动地址和队列创建:

<auto-create-queues>true</auto-create-queues>
<auto-create-addresses>true</auto-create-addresses>

或者手动创建地址和队列,例如:

<addresses>
   <address name="myqueue">
      <anycast>
         <queue name="myqueue"/>
      </anycast>
   </address>
</addresses>

推荐阅读