use of org.apache.axis2.transport.msmq.util.IMSMQClient in project wso2-axis2-transports by wso2.
the class MSMQSender method sendOverMSMQ.
private void sendOverMSMQ(MessageContext msgCtx, String queuName, String contentType) throws AxisFault {
IMSMQClient mqClient = new MSMQCamelClient();
Message message = null;
try {
message = createMSMQMessage(msgCtx, contentType, queuName);
message.setLabel(contentType);
} catch (AxisFault axisFault) {
handleException("Error creaging the MSMQ message from the message context", axisFault);
}
// TODO: should we wait for a response, ok we need to support MSMQ
// request/response scenario
// get the reply queue name and start to receive from here. See
// JMSSender.java:166 for more
// information
boolean waitForResponse = waitForSynchronousResponse(msgCtx);
if (waitForResponse) {
try {
String correlationId = "";
if (msgCtx.getRelatesTo() != null) {
correlationId = msgCtx.getRelatesTo().getValue();
} else {
// TODO: if we are having a one way message we don't have this
correlationId = MSMQConstants.DEFAULT_MSG_CORRELATION_ID;
}
message.setCorrelationIdAsString(correlationId);
} catch (UnsupportedEncodingException e) {
handleException("Error while setting up message Correlation", e);
}
} else {
message.setCorrelationId(MSMQConstants.DEFAULT_MSG_CORRELATION_ID.getBytes());
}
try {
try {
// By default we are handling queues without transactional
mqClient.create(queuName, "MSMQ-WSO2", false);
} catch (MessageQueueException e) {
log.warn("Queue " + queuName + " already there.");
}
// TODO: how to handle transactional messages
mqClient.open(queuName, org.apache.axis2.transport.msmq.util.IMSMQClient.Access.SEND);
} catch (AxisFault axisFault) {
log.error("Queue " + queuName + " already there.");
handleException("Could not open the queu: " + queuName + " for lisinting", axisFault);
}
try {
if (message != null) {
mqClient.send(message);
}
} catch (AxisFault axisFault) {
handleException("Cloud not send the message: " + axisFault);
} finally {
try {
mqClient.close();
} catch (AxisFault axisFault) {
handleException("Cloud not close the queue: ", axisFault);
}
}
if (waitForResponse) {
// TODO: logic to be finalized on handling synchronous request/reply
// for the given MSMQ message
// MSMQClient replyClient = new MSMQClient();
}
}
Aggregations