Skip to content

Instantly share code, notes, and snippets.

pjmuley

Block or report user

Report or block pjmuley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TestAPI.java
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.util.UUID;
View RemoveMQMessage.java
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);
View ListenMQMessage.java
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";
// Get message from existing queue using API
WebResource webResourceGet = client.resource(brokerURI);
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("poolingTime","10000");
View SendMQMessage.java
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);
View GetAccessToken.java
String client_id="85b56xxxxxxxxxxxxxxxxxxxxxxxxxb968fd";
String client_secret="2B792xxxxxxxxxxxxxxxxxxxxxx3B3b1";
String authURI="https://mq-us-west-2.anypoint.mulesoft.com/api/v1/authorize";
// Get access token required for publish/subscribe API's
Client client = Client.create();
WebResource webResource = client.resource(authURI);
String input = "client_id="+client_id+"&client_secret="+client_secret+"&grant_type=client_credentials";
ClientResponse response = webResource.header("Content-Type", "application/x-www-form-urlencoded")
.accept("application/json")
.post(ClientResponse.class, input);
View ExpectedSOAPResponse.xml
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns0:getLoanResponse xmlns:ns0="http://www.mulesoft.com/schemas/Mule/Schema.xsd">
<ns0:loanList>
<ns0:loan>
<ns0:loanId>102</ns0:loanId>
<ns0:customerId>2</ns0:customerId>
<ns0:loanType>auto</ns0:loanType>
<ns0:loanAmount>33436.49</ns0:loanAmount>
<ns0:monthlyPayment>676.48</ns0:monthlyPayment>
<ns0:interestRate>12.56</ns0:interestRate>
</ns0:loan>
View SetMessage.xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.mulesoft.com/schemas/Mule/Schema.xsd"><soapenv:Header/><soapenv:Body><sch:getLoanRequest xmlns:sch="http://www.mulesoft.com/schemas/Mule/Schema.xsd"><sch:loanId>102</sch:loanId></sch:getLoanRequest></soapenv:Body></soapenv:Envelope>
View dependencies.xml
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-cxf</artifactId>
<version>${mule.version}</version>
</dependency>
<dependency>
<groupId>com.mulesoft.weave</groupId>
<artifactId>mule-plugin-weave</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
@pjmuley
pjmuley / mysql.xml
Created Jul 25, 2016
MySQL Dependency
View mysql.xml
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<type>jar</type>
</dependency>
You can’t perform that action at this time.