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

c0vxltue  于 2023-11-15  发布在  Java
关注(0)|答案(1)|浏览(116)

我使用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是:


的数据

gkl3eglg

gkl3eglg1#

我已经解决了这个问题后,更新applicaton-roles.properties使用murad=guest(即分配guest角色给用户murad)。

相关问题