我使用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是:
的数据
1条答案
按热度按时间gkl3eglg1#
我已经解决了这个问题后,更新
applicaton-roles.properties
使用murad=guest
(即分配guest
角色给用户murad
)。