[rabbitmq-discuss] Dynamic Shovels

Michael Klishin mklishin at gopivotal.com
Fri Apr 18 09:24:59 BST 2014



On 18 April 2014 at 04:17:02, Smithnosky, Jesse (jesse.smithnosky at emc.com) wrote:
> >
> curl -i -u guest:guest -H "content-type:application/json"  
> -XPUT -d'{"value":{"src-uri":"amqp://","src-queue":"my-queue","dest-uri":"amqp://remote-server","dest-queue":"another-queue"}}'  
> http://localhost:15672/api/parameters/shovel/%2f/edShovel

-XPUT means you use HTTP method PUT.
   
>  
>  
> HTTP/1.1 204 No Content
>  
>  
> Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye  
> contact)
>  
>  
> Date: Thu, 17 Apr 2014 23:16:58(http://airmail.calendar/2014-04-17%2023:16:58%20GMT+4)  
> GMT
>  
>  
> Content-Type: application/json
>  
>  
> Content-Length: 0
>  
>  
>  
>  
>  
> It appears that the shovel is getting created correctly, but  
> a 204 is coming back.

204 is a successful response meaning “No Content”.

 This is really just a proof of concept, but  
> it has me a little worried about whether or not I can get it working  
> in Java. I’m trying to do something like this:
>  
>  
>  
>  
>  
> String jsonString = jackson.writeValueAsString(shovel);  
>  
>  
> HttpClient client = HttpClientBuilder.create().build();  
>  
>  
> HttpPost post = new HttpPost(RABBIT_URL_BASE+vhost+"/"+shovelName);  
>  
>  
> post.setEntity(new StringEntity(jsonString));
>  
>  
> post.addHeader("content-type", "application/json");
>  
>  
> String userPassword = "guest:guest";
>  
>  
> String encoding = DatatypeConverter.printBase64Binary(userPassword.getBytes("UTF-8"));  
>  
>  
> post.setHeader( "Authorization", "Basic " + encoding );
>  
>  
> HttpResponse response = client.execute(post);
>  
>  
>  
>  
>  
> No matter what I seem to do, however, I’m getting back a 405 Method  
> not allowed response. Has anyone gotten these working yet? Am  
> I doing something obvious incorrectly? Any help is appreciated.  
>  

You use POST in your Java code but PUT with curl. HTTP API expects a PUT and rejects
POSTs. 
--  
MK  

Software Engineer, Pivotal/RabbitMQ


More information about the rabbitmq-discuss mailing list