use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class JmsListenerBase method configure.
@Override
public void configure() throws ConfigurationException {
super.configure();
if (isSoap()) {
// ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
// String msg = getLogPrefix()+"the use of attribute soap=true has been deprecated. Please change to SoapWrapperPipe";
// configWarnings.add(log, msg);
soapWrapper = SoapWrapper.getInstance();
}
ISender sender = getSender();
if (sender != null) {
sender.configure();
}
configurexPathLogging();
if (paramList != null) {
paramList.configure();
}
}
use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class ShowConfigurationStatus method mapAdapterReceivers.
private ArrayList<Object> mapAdapterReceivers(Adapter adapter, boolean showPendingMsgCount) {
ArrayList<Object> receivers = new ArrayList<Object>();
for (Receiver<?> receiver : adapter.getReceivers()) {
Map<String, Object> receiverInfo = new HashMap<>();
RunState receiverRunState = receiver.getRunState();
receiverInfo.put("name", receiver.getName());
receiverInfo.put("state", receiverRunState.name().toLowerCase());
Map<String, Object> messages = new HashMap<String, Object>(3);
messages.put("received", receiver.getMessagesReceived());
messages.put("retried", receiver.getMessagesRetried());
messages.put("rejected", receiver.getMessagesRejected());
receiverInfo.put("messages", messages);
Set<ProcessState> knownStates = receiver.knownProcessStates();
Map<ProcessState, Object> tsInfo = new LinkedHashMap<ProcessState, Object>();
for (ProcessState state : knownStates) {
IMessageBrowser<?> ts = receiver.getMessageBrowser(state);
if (ts != null) {
Map<String, Object> info = new HashMap<>();
try {
info.put("numberOfMessages", ts.getMessageCount());
} catch (Exception e) {
log.warn("Cannot determine number of messages in process state [" + state + "]", e);
info.put("numberOfMessages", "error");
}
info.put("name", state.getName());
tsInfo.put(state, info);
}
}
receiverInfo.put("transactionalStores", tsInfo);
ISender sender = null;
IListener<?> listener = receiver.getListener();
if (listener != null) {
Map<String, Object> listenerInfo = new HashMap<String, Object>();
listenerInfo.put("name", listener.getName());
listenerInfo.put("class", ClassUtils.nameOf(listener));
if (listener instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) receiver.getListener()).getPhysicalDestinationName();
listenerInfo.put("destination", pd);
}
if (listener instanceof HasSender) {
sender = ((HasSender) listener).getSender();
}
boolean isRestListener = (listener instanceof RestListener);
listenerInfo.put("isRestListener", isRestListener);
if (isRestListener) {
RestListener rl = (RestListener) listener;
listenerInfo.put("restUriPattern", rl.getRestUriPattern());
listenerInfo.put("isView", rl.isView());
}
receiverInfo.put("listener", listenerInfo);
}
if ((listener instanceof JmsListenerBase) && showPendingMsgCount) {
JmsListenerBase jlb = (JmsListenerBase) listener;
JmsBrowser<javax.jms.Message> jmsBrowser;
if (StringUtils.isEmpty(jlb.getMessageSelector())) {
jmsBrowser = new JmsBrowser<>();
} else {
jmsBrowser = new JmsBrowser<>(jlb.getMessageSelector());
}
jmsBrowser.setName("MessageBrowser_" + jlb.getName());
jmsBrowser.setJmsRealm(jlb.getJmsRealmName());
jmsBrowser.setDestinationName(jlb.getDestinationName());
jmsBrowser.setDestinationType(jlb.getDestinationType());
String numMsgs;
try {
int messageCount = jmsBrowser.getMessageCount();
numMsgs = String.valueOf(messageCount);
} catch (Throwable t) {
log.warn("Cannot determine number of messages in errorstore [" + jmsBrowser.getName() + "]", t);
numMsgs = "?";
}
receiverInfo.put("pendingMessagesCount", numMsgs);
}
boolean isEsbJmsFFListener = false;
if (listener instanceof EsbJmsListener) {
EsbJmsListener ejl = (EsbJmsListener) listener;
if (ejl.getMessageProtocol() != null) {
if (ejl.getMessageProtocol().equalsIgnoreCase("FF")) {
isEsbJmsFFListener = true;
}
if (showPendingMsgCount) {
String esbNumMsgs = EsbUtils.getQueueMessageCount(ejl);
if (esbNumMsgs == null) {
esbNumMsgs = "?";
}
receiverInfo.put("esbPendingMessagesCount", esbNumMsgs);
}
}
}
receiverInfo.put("isEsbJmsFFListener", isEsbJmsFFListener);
ISender rsender = receiver.getSender();
if (rsender != null) {
// this sender has preference, but avoid overwriting listeners sender with null
sender = rsender;
}
if (sender != null) {
receiverInfo.put("senderName", sender.getName());
receiverInfo.put("senderClass", ClassUtils.nameOf(sender));
if (sender instanceof HasPhysicalDestination) {
String pd = ((HasPhysicalDestination) sender).getPhysicalDestinationName();
receiverInfo.put("senderDestination", pd);
}
}
if (receiver.isThreadCountReadable()) {
receiverInfo.put("threadCount", receiver.getCurrentThreadCount());
receiverInfo.put("maxThreadCount", receiver.getMaxThreadCount());
}
if (receiver.isThreadCountControllable()) {
receiverInfo.put("threadCountControllable", "true");
}
receivers.add(receiverInfo);
}
return receivers;
}
use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class SenderSeries method doSendMessage.
@Override
public Message doSendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
String correlationID = session == null ? null : session.getMessageId();
long t1 = System.currentTimeMillis();
for (ISender sender : getSenders()) {
if (log.isDebugEnabled())
log.debug(getLogPrefix() + "sending correlationID [" + correlationID + "] message [" + message + "] to sender [" + sender.getName() + "]");
message = sender.sendMessage(message, session);
long t2 = System.currentTimeMillis();
StatisticsKeeper sk = getStatisticsKeeper(sender);
sk.addValue(t2 - t1);
t1 = t2;
}
return message;
}
use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class JavascriptSender method sendMessage.
@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException {
Object jsResult = "";
int numberOfParameters = 0;
JavascriptEngine<?> jsInstance = engine.create();
try {
jsInstance.startRuntime();
} catch (JavascriptException e) {
throw new SenderException("unable to start Javascript engine", e);
}
// Create a Parameter Value List
ParameterValueList pvl = null;
try {
if (getParameterList() != null) {
pvl = getParameterList().getValues(message, session);
}
} catch (ParameterException e) {
throw new SenderException(getLogPrefix() + " exception extracting parameters", e);
}
if (pvl != null) {
numberOfParameters = pvl.size();
}
// This array will contain the parameters given in the configuration
Object[] jsParameters = new Object[numberOfParameters];
for (int i = 0; i < numberOfParameters; i++) {
ParameterValue pv = pvl.getParameterValue(i);
Object value = pv.getValue();
try {
jsParameters[i] = value instanceof Message ? ((Message) value).asString() : value;
} catch (IOException e) {
throw new SenderException(getLogPrefix(), e);
}
}
for (ISender sender : getSenders()) {
jsInstance.registerCallback(sender, session);
}
try {
// Compile the given Javascript and execute the given Javascript function
jsInstance.executeScript(adaptES6Literals(fileInput));
jsResult = jsInstance.executeFunction(jsFunctionName, jsParameters);
} catch (JavascriptException e) {
throw new SenderException("unable to execute script/function", e);
} finally {
jsInstance.closeRuntime();
}
// Pass jsResult, the result of the Javascript function.
// It is recommended to have the result of the Javascript function be of type String, which will be the output of the sender
String result = String.valueOf(jsResult);
if (StringUtils.isEmpty(result) || "null".equals(result) || "undefined".equals(result)) {
return Message.nullMessage();
}
return new Message(result);
}
use of nl.nn.adapterframework.core.ISender in project iaf by ibissource.
the class Receiver method propagateName.
protected void propagateName() {
IListener<M> listener = getListener();
if (listener != null && StringUtils.isEmpty(listener.getName())) {
listener.setName("listener of [" + getName() + "]");
}
ISender errorSender = getErrorSender();
if (errorSender != null) {
errorSender.setName("errorSender of [" + getName() + "]");
}
ITransactionalStorage<Serializable> errorStorage = getErrorStorage();
if (errorStorage != null) {
errorStorage.setName("errorStorage of [" + getName() + "]");
}
ISender answerSender = getSender();
if (answerSender != null) {
answerSender.setName("answerSender of [" + getName() + "]");
}
}
Aggregations