use of com.ing.ifsa.exceptions.IFSAException in project iaf by ibissource.
the class IfsaRequesterSender method sendMessage.
/**
* Execute a request to the IFSA service.
* @return in Request/Reply, the retrieved message or TIMEOUT, otherwise null
*/
public String sendMessage(String dummyCorrelationId, String message, Map params) throws SenderException, TimeOutException {
Connection conn = null;
Map udzMap = null;
try {
String realServiceId;
// Extract parameters
if (params != null && params.size() > 0) {
// Use first param as serviceId
realServiceId = (String) params.get("serviceId");
if (realServiceId == null) {
realServiceId = getServiceId();
}
String occurrence = (String) params.get("occurrence");
if (occurrence != null) {
int i = realServiceId.indexOf('/', realServiceId.indexOf('/', realServiceId.indexOf('/', realServiceId.indexOf('/') + 1) + 1) + 1);
int j = realServiceId.indexOf('/', i + 1);
realServiceId = realServiceId.substring(0, i + 1) + occurrence + realServiceId.substring(j);
}
// Use remaining params as outgoing UDZs
udzMap = new HashMap(params);
udzMap.remove("serviceId");
udzMap.remove("occurrence");
} else {
realServiceId = getServiceId();
}
// Open connection to the Application ID
conn = ConnectionManager.getConnection(getApplicationId());
// Create the request, and set the Service URI to the Service ID
ServiceRequest request = new ServiceRequest(new BusinessMessage(message));
request.setServiceURI(new ServiceURI(realServiceId));
addUdzMapToRequest(udzMap, request);
if (isSynchronous()) {
// RR handling
if (timeOut > 0) {
request.setTimeout(timeOut);
}
RequestReplyAccessBean rrBean = RequestReplyAccessBean.getInstance();
ServiceReply reply = rrBean.sendReceive(conn, request);
return reply.getBusinessMessage().getText();
} else {
// FF handling
FireForgetAccessBean ffBean = FireForgetAccessBean.getInstance();
ffBean.send(conn, request);
return null;
}
} catch (com.ing.ifsa.exceptions.TimeoutException toe) {
throw new TimeOutException(toe);
} catch (IFSAException e) {
throw new SenderException(e);
} finally {
if (conn != null) {
conn.close();
}
}
}
Aggregations