use of org.apache.axis2.transport.rabbitmq.RabbitMQMessage in project wso2-axis2-transports by wso2.
the class RabbitMQSender method sendOverAMQP.
/**
* Perform actual sending of the AMQP message
*/
private void sendOverAMQP(RabbitMQConnectionFactory factory, MessageContext msgContext, String targetEPR) throws AxisFault {
try {
RabbitMQMessage message = new RabbitMQMessage(msgContext);
Hashtable<String, String> epProperties = BaseUtils.getEPRProperties(targetEPR);
if (!StringUtils.isEmpty(epProperties.get(RabbitMQConstants.REPLY_TO_NAME))) {
// request-response scenario
RabbitMQRPCMessageSender sender = new RabbitMQRPCMessageSender(factory, targetEPR, epProperties);
RabbitMQMessage responseMessage = sender.send(message, msgContext);
MessageContext responseMsgCtx = createResponseMessageContext(msgContext);
RabbitMQUtils.setSOAPEnvelope(responseMessage, responseMsgCtx, responseMessage.getContentType());
handleIncomingMessage(responseMsgCtx, RabbitMQUtils.getTransportHeaders(responseMessage), responseMessage.getSoapAction(), responseMessage.getContentType());
} else {
// Basic out only publish
RabbitMQMessageSender sender = new RabbitMQMessageSender(factory, targetEPR, epProperties);
sender.send(message, msgContext);
}
} catch (AxisRabbitMQException e) {
handleException("Error occurred while sending message out", e);
} catch (IOException e) {
handleException("Error occurred while sending message out", e);
}
}
use of org.apache.axis2.transport.rabbitmq.RabbitMQMessage in project wso2-axis2-transports by wso2.
the class RabbitMQUtils method setSOAPEnvelope.
public static void setSOAPEnvelope(RabbitMQMessage message, MessageContext msgContext, String contentType) throws AxisFault {
int index = contentType.indexOf(';');
String type = index > 0 ? contentType.substring(0, index) : contentType;
Builder builder = BuilderUtil.getBuilderFromSelector(type, msgContext);
if (builder == null) {
if (log.isDebugEnabled()) {
log.debug("No message builder found for type '" + type + "'. Falling back to SOAP.");
}
builder = new SOAPBuilder();
}
OMElement documentElement;
String charSetEnc = null;
try {
if (contentType != null) {
charSetEnc = new ContentType(contentType).getParameter("charset");
}
} catch (ParseException ex) {
log.debug("Parse error", ex);
}
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
documentElement = builder.processDocument(new ByteArrayInputStream(message.getBody()), contentType, msgContext);
msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement));
}
Aggregations