Apex callout to RabbitMQ Queue

Create AMQP HTTPRequest calling POST /api/exchanges/{username}/{exchangeName}/publish

WebCustomSettings are custom settings in Salesforce the values are the following:
AMQP_Url__c: https://jellyfish.rmq.cloudamqp.com
AMQP_Credentials__c: xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxx (username:password)
	public void callAmqpEndpoint(String exchangeName, String method, String aPayload) {
  	HttpRequest req = new HttpRequest();
    try {
      if (exchangeName != null) {
        req.setTimeout(120000);
        req.setMethod(method);
				setAmqpAuthHeader(req);
				System.debug(String.valueOf(aPayload));
        req.setEndpoint(WebCustomSettings.AMQP_Url__c + '/api/exchanges/' + WebCustomSettings.AMQP_Credentials__c.split(':')[0] + '/' + exchangeName + '/publish');
				if (aPayload!=null)
        	req.setBody(aPayload);
        System.debug('Sending api request to endpoint' + req.getEndpoint());
        Http http = new Http();
        http.send(req);
      } else {
        throw new Rest_Exception(ResponseCodes_Mgr.getCode('AMQP_REQUEST_FAILED'));
      }
    } catch (Exception ex) {
      System.debug('Error sending amqp request ' + ex);
      List<String> theArgs = new List<String>();
      theArgs.add('AMQP');
      theArgs.add(req.getEndpoint());
      throw new Rest_Exception(ResponseCodes_Mgr.getCode('AMQP_REQUEST_FAILED', ex, theArgs));
    }
  }

Setup AMQP headers

private void setAmqpAuthHeader(HttpRequest aReq) {
    Blob headerValue = Blob.valueOf(WebCustomSettings.AMQP_Credentials__c);
    String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
    aReq.setHeader('Authorization', authorizationHeader);
		aReq.setHeader('Content-Type', 'application/json');
		aReq.setHeader('X-AMQP-Tracer', requestJson!=null && requestJson.getTraceId()!=null ? requestJson.getTraceId() : '');
  }

Serialize AMQP Request JSON

	private String serializeAmqpRequests(String payload) {
		JSONGenerator generator = JSON.createGenerator(false);
		generator.writeStartObject();
		generator.writeStringField('routing_key','amqp-events');
		generator.writeFieldName('properties');
		generator.writeStartObject();
		generator.writeEndObject();
		generator.writeStringField('payload', payload);
		generator.writeStringField('payload_encoding', 'string');
		generator.writeEndObject();
		return generator.getAsString();
	}

Callout RabbitMQ

public void sendAmqpRequest(String payload){
		 String amqpPayload = serializeAmqpRequests(payload);
		 callAmqpEndpoint('event-exchange', 'POST', amqpPayload);
	}

Invoke an Web Service from Websphere Message Broker

Step 1: Create your Java Bean that runs on Websphere Application Server.

Step 2: Create a Web Service for the Bean using the bottom-up or top-down approach in Rational Application Developer.

Step 3: Create the business flow in Websphere Message Broker.

Step 4: Testing your Web Service Flow Putting a Test Message on your Input Queue (QInput)

Input SOAP Message:

<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:cloc=”http://clock.ejb3.ibm.com”><soapenv:Header/><soapenv:Body><cloc:getClockInfo><format>short</format></cloc:getClockInfo></soapenv:Body></soapenv:Envelope&gt;

Step 5: Check output Queue (Q.Output) for the Web Service Result

HTTP/1.1 200 OKContent-Type: text/xml; charset=utf-8Content-Language: en-ZAContent-Length: 457Date: Mon, 17 May 2010 19:03:02 GMTServer: WebSphere Application Server/7.0

<SOAP_Domain_Msg xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:soapenc=”http://schemas.xmlsoap.org/soap/encoding/&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”><Context operation=”getClockInfo” operationType=”REQUEST_RESPONSE” portType=”Clock” portTypeNamespace=”http://clock.ejb3.ibm.com&#8221; port=”Clock” service=”ClockService” fileName=”C:\Documents and Settings\All Users\Application Data\IBM\MQSI\components\WMBB\1eaf83a7-2801-0000-0080-c0b40e353b3a\config\XSD\Clock/com/ibm/ejb3/clock/Clock.wsdl”><SOAP_Version>1.1</SOAP_Version><Namespace xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:soapenc=”http://schemas.xmlsoap.org/soap/encoding/&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchem