use of com.ing.ifsa.api.ServiceURI 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();
}
}
}
use of com.ing.ifsa.api.ServiceURI in project iaf by ibissource.
the class IfsaProviderListener method populateThreadContext.
public void populateThreadContext(Object rawMessage, Map threadContext, Session session) throws ListenerException {
ServiceRequest request = (ServiceRequest) rawMessage;
// Get variables from the IFSA Service Request, in as good manner
// as possible to emulate the way that the JMS IfsaProviderListener works
String mode = getMessageProtocol().equals("RR") ? "NON_PERSISTENT" : "PERSISTENT";
String id = request.getUniqueId();
String cid = id;
if (log.isDebugEnabled()) {
log.debug("Setting correlation ID to MessageId");
}
Date dTimeStamp = new Date();
String messageText = getStringFromRawMessage(rawMessage, threadContext);
String fullIfsaServiceName = null;
ServiceURI requestedService = request.getServiceURI();
String ifsaServiceName = null, ifsaGroup = null, ifsaOccurrence = null, ifsaVersion = null;
ifsaServiceName = requestedService.getService();
ifsaGroup = requestedService.getGroup();
ifsaOccurrence = requestedService.getOccurrence();
ifsaVersion = requestedService.getVersion();
if (log.isDebugEnabled()) {
log.debug(getLogPrefix() + "got message for [" + fullIfsaServiceName + "] with JMSDeliveryMode=[" + mode + "] \n JMSMessageID=[" + id + "] \n JMSCorrelationID=[" + cid + "] \n ifsaServiceName=[" + ifsaServiceName + "] \n ifsaGroup=[" + ifsaGroup + "] \n ifsaOccurrence=[" + ifsaOccurrence + "] \n ifsaVersion=[" + ifsaVersion + "] \n Timestamp=[" + dTimeStamp.toString() + "] \n ReplyTo=[none" + "] \n MessageHeaders=[<unknown>" + "] \n Message=[" + messageText + "\n]");
}
threadContext.put("id", id);
threadContext.put(IPipeLineSession.technicalCorrelationIdKey, cid);
threadContext.put("timestamp", dTimeStamp);
threadContext.put("replyTo", "none");
threadContext.put("messageText", messageText);
threadContext.put("fullIfsaServiceName", fullIfsaServiceName);
threadContext.put("ifsaServiceName", ifsaServiceName);
threadContext.put("ifsaGroup", ifsaGroup);
threadContext.put("ifsaOccurrence", ifsaOccurrence);
threadContext.put("ifsaVersion", ifsaVersion);
Map udz = request.getAllUserDefinedZones();
if (udz != null) {
String contextDump = "ifsaUDZ:";
for (Iterator it = udz.keySet().iterator(); it.hasNext(); ) {
String key = (String) it.next();
String value = (String) udz.get(key);
contextDump = contextDump + "\n " + key + "=[" + value + "]";
threadContext.put(key, value);
}
if (log.isDebugEnabled()) {
log.debug(getLogPrefix() + contextDump);
}
}
}
Aggregations