Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何限制activemq中的用户?_Java_Activemq - Fatal编程技术网

Java 如何限制activemq中的用户?

Java 如何限制activemq中的用户?,java,activemq,Java,Activemq,我是activemq的新手。我已下载最新的activemq 5.8并运行服务器。我已使用以下代码创建队列并发送示例消息: // URL of the JMS server. DEFAULT_BROKER_URL will just mean // that JMS server is on localhost private static String url = ActiveMQConnection.DEFAULT_BROKER_URL; // Name of the

我是activemq的新手。我已下载最新的activemq 5.8并运行服务器。我已使用以下代码创建队列并发送示例消息:

// URL of the JMS server. DEFAULT_BROKER_URL will just mean
    // that JMS server is on localhost
    private static String url = ActiveMQConnection.DEFAULT_BROKER_URL;

    // Name of the queue we will be sending messages to
    private static String subject = "TESTQUEUE";

    public static void main(String[] args) throws JMSException {
        // Getting JMS connection from the server and starting it
        ConnectionFactory connectionFactory =
            new ActiveMQConnectionFactory(url);
        Connection connection = connectionFactory.createConnection();
        connection.start();

        // JMS messages are sent and received using a Session. We will
        // create here a non-transactional session object. If you want
        // to use transactions you should set the first parameter to 'true'
        Session session = connection.createSession(false,
            Session.AUTO_ACKNOWLEDGE);

        // Destination represents here our queue 'TESTQUEUE' on the
        // JMS server. You don't have to do anything special on the
        // server to create it, it will be created automatically.
        Destination destination = session.createQueue(subject);

        // MessageProducer is used for sending messages (as opposed
        // to MessageConsumer which is used for receiving them)
        MessageProducer producer = session.createProducer(destination);

        // We will send a small text message saying 'Hello' in Japanese
        TextMessage message = session.createTextMessage("こんにちは");

        // Here we are sending the message!
        producer.send(message);
        System.out.println("Sent message '" + message.getText() + "'");

        connection.close();
    }
我已成功运行上述代码并创建了队列。现在我想限制activemq服务器中的用户访问。我更改了CreateConnection方法,如下所示

Connection connection = connectionFactory.createConnection("test","test");
现在,如果我成功运行已更改的代码消息发送到队列。但测试用户在activemq中不存在,即使已建立连接。如何限制此用户

<authorizationPlugin>
    <map>
      <authorizationMap>
        <authorizationEntries>
          <authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
          <authorizationEntry queue="USERS.>" read="users" write="users" admin="users" />
          <authorizationEntry queue="GUEST.>" read="guests" write="guests,users" admin="guests,users" />

          <authorizationEntry queue="TEST.Q" read="guests" write="guests" />

          <authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
          <authorizationEntry topic="USERS.>" read="users" write="users" admin="users" />
          <authorizationEntry topic="GUEST.>" read="guests" write="guests,users" admin="guests,users" />

          <authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>
        </authorizationEntries>
      </authorizationMap>
    </map>
  </authorizationPlugin>
</plugins>

在上面的文件中是activemq.xml.Now,我只想访问队列中的某些用户

如何限制actviemq中的用户?在activemq.xml文件上方我需要更改什么?

请参阅activemq文档:

在activemq.xml中:

在“目的地”部分定义要创建的队列。 您可以通过在“用户”部分定义组来控制权限。 在“authorizationEntries”部分,您可以定义允许哪些组读取、写入和管理队列

activemq.xml的框架:
Hi。什么队伍?什么语言?什么问题?