Created
July 6, 2017 14:17
-
-
Save pjmuley/c1d15342ad7993758cde1ec555190174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
// Message acknowledgement, effectively deleting message from the queue | |
JSONArray jsonArrayAck= (JSONArray) jsonParser.parse(outputGet); // Parse json output from retrieve message earlier to get lock id | |
JSONObject structureAck =(JSONObject) ((JSONObject)jsonArrayAck.get(0)).get("headers"); | |
String lockId= (String)structureAck.get("lockId"); | |
WebResource webResourceAck = client.resource(postURI); | |
String inputAck="{ \"lockId\": \""+lockId+"\" }"; | |
ClientResponse responseAck=webResourceAck.header("Authorization"," bearer" + access_token) | |
.type("application/json") | |
.accept("application/json") | |
.delete(ClientResponse.class, inputAck); | |
String outputAck = responseAck.getEntity(String.class); | |
System.out.println("Ack Message: \n" + outputAck); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment