Skip to content

Instantly share code, notes, and snippets.

@pjmuley
Last active July 6, 2017 05:25
Show Gist options
  • Select an option

  • Save pjmuley/0bed483854a636f7e12fac11e9aa3bb8 to your computer and use it in GitHub Desktop.

Select an option

Save pjmuley/0bed483854a636f7e12fac11e9aa3bb8 to your computer and use it in GitHub Desktop.
String queueName="myQueue";
String queueMessage="This is my test message";
String brokerURI="https://mq-us-west-2.anypoint.mulesoft.com/api/v1/organizations/";
brokerURI = brokerURI + orgId +"/environments/"+ envId +"/destinations/"+ queueName+"/messages";
// Post message to existing queue using API
String messageId=UUID.randomUUID().toString();
String postURI=brokerURI+"/"+messageId;
System.out.println(postURI);
WebResource webResourcePost = client.resource(postURI);
String inputPost="{ \"body\": \""+queueMessage+"\" }";
ClientResponse responsePost=webResourcePost.header("Authorization"," bearer" + access_token)
.type("application/json")
.accept("application/json")
.put(ClientResponse.class, inputPost);
String outputPost = responsePost.getEntity(String.class);
System.out.println("Post Successful: \n"+outputPost);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment