use of org.apache.axis2.transport.rabbitmq.utils.AxisRabbitMQException in project wso2-axis2-transports by wso2.
the class RabbitMQSender method init.
/**
* Initialize the transport sender by reading pre-defined connection factories for
* outgoing messages.
*
* @param cfgCtx the configuration context
* @param transportOut the transport sender definition from axis2.xml
* @throws AxisFault on error
*/
@Override
public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut) throws AxisFault {
try {
super.init(cfgCtx, transportOut);
SecretResolver secretResolver = cfgCtx.getAxisConfiguration().getSecretResolver();
// initialize connection factory and pool
rabbitMQConnectionFactory = new RabbitMQConnectionFactory();
int poolSize = RabbitMQUtils.resolveTransportDescription(transportOut, secretResolver, rabbitMQConnectionFactory);
RabbitMQConnectionPool rabbitMQConnectionPool = new RabbitMQConnectionPool(rabbitMQConnectionFactory, poolSize);
// initialize channel factory and pool
RabbitMQChannelFactory rabbitMQChannelFactory = new RabbitMQChannelFactory(rabbitMQConnectionPool);
rabbitMQChannelPool = new RabbitMQChannelPool(rabbitMQChannelFactory, poolSize);
// initialize confirm channel factory and pool
RabbitMQConfirmChannelFactory rabbitMQConfirmChannelFactory = new RabbitMQConfirmChannelFactory(rabbitMQConnectionPool);
rabbitMQConfirmChannelPool = new RabbitMQChannelPool(rabbitMQConfirmChannelFactory, poolSize);
log.info("RabbitMQ AMQP Transport Sender initialized...");
} catch (AxisRabbitMQException e) {
throw new AxisFault("Error occurred while initializing the RabbitMQ AMQP Transport Sender.", e);
}
}
use of org.apache.axis2.transport.rabbitmq.utils.AxisRabbitMQException in project wso2-axis2-transports by wso2.
the class RabbitMQRPCMessageSender method send.
public RabbitMQMessage send(RabbitMQMessage message, MessageContext msgContext) throws AxisRabbitMQException, IOException {
publish(message, msgContext);
RabbitMQMessage responseMessage = processResponse(message.getCorrelationId());
// release the dual channel to the pool
try {
connectionFactory.pushRPCChannel(dualChannel);
} catch (InterruptedException e) {
handleException(e.getMessage());
}
return responseMessage;
}
use of org.apache.axis2.transport.rabbitmq.utils.AxisRabbitMQException 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);
}
}
Aggregations