Search in sources :

Example 1 with RabbitMQRPCMessageSender

use of org.apache.axis2.transport.rabbitmq.rpc.RabbitMQRPCMessageSender 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);
    }
}
Also used : RabbitMQRPCMessageSender(org.apache.axis2.transport.rabbitmq.rpc.RabbitMQRPCMessageSender) AxisRabbitMQException(org.apache.axis2.transport.rabbitmq.utils.AxisRabbitMQException) MessageContext(org.apache.axis2.context.MessageContext) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 MessageContext (org.apache.axis2.context.MessageContext)1 RabbitMQRPCMessageSender (org.apache.axis2.transport.rabbitmq.rpc.RabbitMQRPCMessageSender)1 AxisRabbitMQException (org.apache.axis2.transport.rabbitmq.utils.AxisRabbitMQException)1