Activemq jolokia rest api删除队列?

时间:2014-09-09 19:18:29

标签: rest activemq jolokia

有没有办法在5.9.0上删除ActiveMQ rest api的队列?我知道你可以用

清除队列
"http://" + host + ":" + port + "/api/jolokia/exec/org.apache.activemq:brokerName=localhost,destinationName=" + queueName + ",destinationType=Queue,type=Broker/purge()";

但删除的是什么?

2 个答案:

答案 0 :(得分:4)

您应该使用以下网址格式:

http://hostname:8161/hawtio/jolokia/exec/org.apache.activemq:type=Broker,brokerName=MyBroker/removeQueue(java.lang.String)/MyQueue

您可以阅读有关访问JMX操作的格式,直到jolokia here

答案 1 :(得分:0)

这是一个执行它的java f'n:

public static String removeQueue(String queueName) throws ClientProtocolException, IOException, URISyntaxException {

    String username = "admin";
    String password = "admin";
    URI mqUrl = new URI( YOUR ACTIVE MQ URI HERE );
    HttpHost targetHost = new HttpHost(mqUrl.getHost(), mqUrl.getPort(), "http");

    CredentialsProvider credsProvider = new BasicCredentialsProvider();
    credsProvider.setCredentials(AuthScope.ANY, 
      new UsernamePasswordCredentials(username, password));

    AuthCache authCache = new BasicAuthCache();
    authCache.put(targetHost, new BasicScheme());

    // Add AuthCache to the execution context
    final HttpClientContext context = HttpClientContext.create();
    context.setCredentialsProvider(credsProvider);
    context.setAuthCache(authCache);

    HttpClient client = HttpClientBuilder.create().build();

    String uri = "http://" + mqUrl.getHost() + ":" + mqUrl.getPort() + "/hawtio/jolokia/exec/org.apache.activemq:type=Broker,brokerName=localhost/removeQueue/" + queueName;

    HttpResponse response = client.execute(new HttpGet(uri), context);
    if (response.getStatusLine().getStatusCode() != 200) {
        throw new IOException(response.getStatusLine().toString());
    }
    return IOUtils.toString(response.getEntity().getContent());
}