WildFly JMS 错误:没有队列 jms.queue.exampleQueue 的权限='CONSUME'

问题描述 投票:0回答:1

我正在使用 WildFly 19 和 JMS 应用程序。运行该程序后,出现以下错误:

AMQ229213: User: murad does not have permission='CONSUME' for queue jms.queue.exampleQueue on address jms.queue.exampleQueue.jms.queue.exampleQueue

这是我的 JMS 代码:

  try {

            // Set up the namingContext for the JNDI lookup
            final Properties env = new Properties();
            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
            env.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080");
            env.put(Context.SECURITY_PRINCIPAL, "murad");
            env.put(Context.SECURITY_CREDENTIALS, "Murad@1234");
            env.put("jboss.naming.client.ejb.context", true);
            namingContext = new InitialContext(env);

            ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup("jms/RemoteConnectionFactory");
            System.out.println("Got ConnectionFactory " + connectionFactory);

            Destination destination = (Destination) namingContext.lookup("jms/queue/exampleQueue");
            System.out.println("Got JMS Endpoint " + destination);

            // Create the JMS context
            context = connectionFactory.createContext("murad", "Murad@1234"); 
            
            JMSConsumer consumer = context.createConsumer(destination);
            // Then receive the same number of messages that were sent

            String text = consumer.receiveBody(String.class, 5000);
            if (text == null)
                System.out.println("No message Received! Maybe another Consumer listening on the Queue ??");
            System.out.println("Received message with content " + text);


        } catch (Exception e) {

Wildfly 配置 xml 是:

java jakarta-ee jms activemq-artemis
1个回答
0
投票

我在applicaton-oles.properties中修改murad=guest后解决了这个问题。

但是我面临另一个错误。下面的行给出了 null 值作为结果。

String text = Consumer.receiveBody(String.class, 5000);

错误是: “收到内容为空的消息”

© www.soinside.com 2019 - 2024. All rights reserved.