[rabbitmq-discuss] RABBIT MANAGEMENT HTTP API CANNOT SUPPORT "Create Queue and Exchange"?

johnson johnson at edocom.cn
Tue Oct 23 19:13:19 BST 2012


Hi all,

I wrote a sample code to use Rabbitmq management HTTP API. For "Create a new vhost", it works fine.

    HttpPut httpput httpput = new HttpPut();
httpput.setHeader("content-type", "application/json");
    httpput.setURI(new URI("http://192.168.2.129:55672/api/vhosts/my-vhost"));
    DefaultHttpClient httpclient = new DefaultHttpClient();  
    httpclient.getCredentialsProvider().setCredentials(new AuthScope("192.168.2.129", 55672),
                                            new UsernamePasswordCredentials("guest", "guest"));
    HttpResponse response = httpclient.execute(httpput);


But if I want to create a new Exchange or Queue using the same code, it always returns NoHTTPResponseException. It seems that once I setEntity for httpput, the exception occurs.

    HttpPut httpput = new HttpPut();
    httpput.setHeader("content-type", "application/json");

    JSONObject param = new JSONObject();
    param.put("type", "direct");
    StringEntity  entity = new StringEntity(param.toString());
    httpput.setEntity(entity);

    httpput.setURI(new URI("http://192.168.2.129:55672/api/exchanges/%2f/my-new-exchange"));
    DefaultHttpClient httpclient = new DefaultHttpClient();  
    httpclient.getCredentialsProvider().setCredentials(new AuthScope("192.168.2.129", 55672),
                                            new UsernamePasswordCredentials("guest", "guest"));
    
    HttpResponse response = httpclient.execute(httpput);


Could anyone give me some example how to use HTTP API? Thanks.

Johnson



Best regards,
Johnson 刘峰
MOBILE:13776621689                                                                 
TEL: 025-83191712
FAX: 025-58783331
地址: 南京市雨花区软件大道48号苏豪国际广场A幢一楼A区
邮编: 210012
 Information System Co. Ltd.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121024/169d91c6/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 14489 bytes
Desc: not available
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121024/169d91c6/attachment.jpeg>


More information about the rabbitmq-discuss mailing list