Java 在Wildfly 17中启用发送到JMS主题或从JMS主题接收

Java 在Wildfly 17中启用发送到JMS主题或从JMS主题接收,java,jboss,jms-topic,wildfly-17,Java,Jboss,Jms Topic,Wildfly 17,为了能够向Wildfly 17中的给定主题发送JMS消息并通过JMS接收消息,应配置哪些设置 在浏览互联网后,我发现了以下来源: 但是,上述链接都没有完全解决我的问题。1。)应使用命令在Wildfly 17中创建一个特殊的应用程序用户 add-user.sh/add-user.cmd 属于组“来宾”,JMS消息生成器将代表其创建JMS消息。有关如何创建此用户的详细信息,请参见: 2.)Wilffly 17必须使用 standalone-full.xml 不只是 standalo

为了能够向Wildfly 17中的给定主题发送JMS消息并通过JMS接收消息,应配置哪些设置

在浏览互联网后,我发现了以下来源:

但是,上述链接都没有完全解决我的问题。

1。)应使用命令在Wildfly 17中创建一个特殊的应用程序用户

add-user.sh/add-user.cmd
属于组“来宾”,JMS消息生成器将代表其创建JMS消息。有关如何创建此用户的详细信息,请参见:

2.)Wilffly 17必须使用

standalone-full.xml
不只是

   standalone.xml
3.)应在Wildfly17中创建消息主题,消息应发送至该主题。这可以通过使用以下参数运行脚本
jboss-cli.bat/jboss cli.bat
实现:

jms-topic add --topic-address=AuctionTopic --entries=[#topic/auction", "java:jboss/exported/jms/topic/auction"]
或者直接在standalone-full.xml的第537行插入以下条目:

<jms-topic name="topic/testTopic" entries="java:/jms/topic/auction java:jboss/exported/jms/topic/auction" />
在哪里

  <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
Properties props = new Properties();
// Wildfly 17.00:
// this user and password shall be created before the application is deployed
// with the help of add-user.sh. The jmsuser shall be an application user that // belongs to the group guest
        props.put(Context.SECURITY_PRINCIPAL, "jmsuser");
        props.put(Context.SECURITY_CREDENTIALS, "Password1!");
        javax.naming.InitialContext ctx = new InitialContext(props);

        Object obj = ctx.lookup(Constants.JMS_CONNECTION_FACTORY);
        ConnectionFactory factory = (ConnectionFactory) obj;
        this.jmsConnection = factory.createConnection();
        obj = ctx.lookup(Constants.JMS_TOPIC_NAME);
        this.topic = (Topic) obj;
Constants.JMS_CONNECTION_FACTORY = "ConnectionFactory";
Constants.JMS_TOPIC_NAME = "java:/jms/topic/auction";