use of com.ing.ifsa.IFSAPoisonMessage in project iaf by ibissource.
the class PullingIfsaProviderListener method getRawMessage.
/**
* Retrieves messages to be processed by the server, implementing an IFSA-service, but does no processing on it.
*/
public Object getRawMessage(Map threadContext) throws ListenerException {
Object result = null;
QueueSession session = null;
QueueReceiver receiver = null;
threadContext.remove(THREAD_CONTEXT_ORIGINAL_RAW_MESSAGE_KEY);
try {
session = getSession(threadContext);
try {
receiver = getReceiver(threadContext, session);
result = receiver.receive(getTimeOut());
while (result == null && canGoOn() && !JtaUtil.inTransaction()) {
result = receiver.receive(getTimeOut());
}
} catch (Exception e) {
throw new ListenerException(getLogPrefix(), e);
} finally {
releaseReceiver(receiver);
}
} finally {
if (sessionNeedsToBeSavedForAfterProcessMessage(result)) {
threadContext.put(THREAD_CONTEXT_SESSION_KEY, session);
} else {
releaseSession(session);
}
}
if (result instanceof IFSAPoisonMessage) {
IFSAHeader header = ((IFSAPoisonMessage) result).getIFSAHeader();
String source;
try {
source = header.getIFSA_Source();
} catch (Exception e) {
source = "unknown due to exeption:" + e.getMessage();
}
String msg = getLogPrefix() + "received IFSAPoisonMessage " + "source [" + source + "]" + "content [" + ToStringBuilder.reflectionToString((IFSAPoisonMessage) result) + "]";
log.warn(msg);
}
try {
if ((result instanceof IFSATextMessage || result instanceof IFSAPoisonMessage) && JtaUtil.inTransaction()) {
threadContext.put(THREAD_CONTEXT_ORIGINAL_RAW_MESSAGE_KEY, result);
result = new MessageWrapper(result, this);
}
} catch (Exception e) {
throw new ListenerException("cannot wrap non serialzable message in wrapper", e);
}
return result;
}
use of com.ing.ifsa.IFSAPoisonMessage in project iaf by ibissource.
the class PullingIfsaProviderListener method getStringFromRawMessage.
/**
* Extracts string from message obtained from {@link #getRawMessage(Map)}. May also extract
* other parameters from the message and put those in the threadContext.
* @return input message for adapter.
*/
public String getStringFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException {
if (rawMessage instanceof IMessageWrapper) {
return getStringFromWrapper((IMessageWrapper) rawMessage, threadContext);
}
if (rawMessage instanceof IFSAPoisonMessage) {
IFSAPoisonMessage pm = (IFSAPoisonMessage) rawMessage;
IFSAHeader header = pm.getIFSAHeader();
String source;
try {
source = header.getIFSA_Source();
} catch (Exception e) {
source = "unknown due to exeption:" + e.getMessage();
}
return "<poisonmessage>" + " <source>" + source + "</source>" + " <contents>" + XmlUtils.encodeChars(ToStringBuilder.reflectionToString(pm)) + "</contents>" + "</poisonmessage>";
}
TextMessage message = null;
try {
message = (TextMessage) rawMessage;
} catch (ClassCastException e) {
log.warn(getLogPrefix() + "message received was not of type TextMessage, but [" + rawMessage.getClass().getName() + "]", e);
return null;
}
try {
return message.getText();
} catch (JMSException e) {
throw new ListenerException(getLogPrefix(), e);
}
}
use of com.ing.ifsa.IFSAPoisonMessage in project iaf by ibissource.
the class PushingIfsaProviderListener method getStringFromRawMessage.
/**
* Extracts string from message obtained from {@link #getRawMessage(Map)}. May also extract
* other parameters from the message and put those in the threadContext.
* @return input message for adapter.
*/
public String getStringFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException {
if (rawMessage instanceof IMessageWrapper) {
return getStringFromWrapper((IMessageWrapper) rawMessage, threadContext);
}
if (rawMessage instanceof IFSAPoisonMessage) {
IFSAPoisonMessage pm = (IFSAPoisonMessage) rawMessage;
IFSAHeader header = pm.getIFSAHeader();
String source;
try {
source = header.getIFSA_Source();
} catch (Exception e) {
source = "unknown due to exeption:" + e.getMessage();
}
return "<poisonmessage>" + " <source>" + source + "</source>" + " <contents>" + XmlUtils.encodeChars(ToStringBuilder.reflectionToString(pm)) + "</contents>" + "</poisonmessage>";
}
TextMessage message = null;
try {
message = (TextMessage) rawMessage;
} catch (ClassCastException e) {
log.warn(getLogPrefix() + "message received was not of type TextMessage, but [" + rawMessage.getClass().getName() + "]", e);
return null;
}
try {
String result = message.getText();
threadContext.put(THREAD_CONTEXT_ORIGINAL_RAW_MESSAGE_KEY, message);
return result;
} catch (JMSException e) {
throw new ListenerException(getLogPrefix(), e);
}
}
Aggregations