use of nl.nn.adapterframework.receivers.Receiver in project iaf by ibissource.
the class ShowConfigurationStatus method mapAdapter.
private Map<String, Object> mapAdapter(Adapter adapter) {
Map<String, Object> adapterInfo = new HashMap<String, Object>();
Configuration config = adapter.getConfiguration();
String adapterName = adapter.getName();
adapterInfo.put("name", adapterName);
adapterInfo.put("description", adapter.getDescription());
adapterInfo.put("configuration", config.getName());
// replace low line (x'5f') by asterisk (x'2a) so it's sorted before any digit and letter
String nameUC = StringUtils.upperCase(StringUtils.replace(adapterName, "_", "*"));
adapterInfo.put("nameUC", nameUC);
RunState adapterRunState = adapter.getRunState();
adapterInfo.put("started", adapterRunState == RunState.STARTED);
String state = adapterRunState.toString().toLowerCase().replace("*", "");
adapterInfo.put("state", state);
adapterInfo.put("configured", adapter.configurationSucceeded());
adapterInfo.put("upSince", adapter.getStatsUpSinceDate().getTime());
Date lastMessage = adapter.getLastMessageDateDate();
if (lastMessage != null) {
adapterInfo.put("lastMessage", lastMessage.getTime());
adapterInfo.put("messagesInProcess", adapter.getNumOfMessagesInProcess());
adapterInfo.put("messagesProcessed", adapter.getNumOfMessagesProcessed());
adapterInfo.put("messagesInError", adapter.getNumOfMessagesInError());
}
Iterator<Receiver<?>> it = adapter.getReceivers().iterator();
int errorStoreMessageCount = 0;
int messageLogMessageCount = 0;
while (it.hasNext()) {
Receiver rcv = it.next();
if (rcv.isNumberOfExceptionsCaughtWithoutMessageBeingReceivedThresholdReached()) {
adapterInfo.put("receiverReachedMaxExceptions", "true");
}
IMessageBrowser esmb = rcv.getMessageBrowser(ProcessState.ERROR);
if (esmb != null) {
try {
errorStoreMessageCount += esmb.getMessageCount();
} catch (ListenerException e) {
log.warn("Cannot determine number of messages in errorstore of [" + rcv.getName() + "]", e);
}
}
IMessageBrowser mlmb = rcv.getMessageBrowser(ProcessState.DONE);
if (mlmb != null) {
try {
messageLogMessageCount += mlmb.getMessageCount();
} catch (ListenerException e) {
log.warn("Cannot determine number of messages in messagelog of [" + rcv.getName() + "]", e);
}
}
}
if (errorStoreMessageCount != 0) {
adapterInfo.put("errorStoreMessageCount", errorStoreMessageCount);
}
if (messageLogMessageCount != 0) {
adapterInfo.put("messageLogMessageCount", messageLogMessageCount);
}
return adapterInfo;
}
use of nl.nn.adapterframework.receivers.Receiver in project iaf by ibissource.
the class WsdlTest method mockPipeLine.
protected PipeLine mockPipeLine(IValidator inputValidator, IValidator outputValidator, String targetNamespace, String adapterName) {
PipeLine simple = mock(PipeLine.class);
when(simple.getInputValidator()).thenReturn(inputValidator);
when(simple.getOutputValidator()).thenReturn(outputValidator);
Adapter adp = mock(Adapter.class);
when(simple.getAdapter()).thenReturn(adp);
Configuration cfg = mock(Configuration.class);
when(simple.getAdapter().getConfiguration()).thenReturn(cfg);
final Receiver receiverBase = mock(Receiver.class);
WebServiceListener listener = new WebServiceListener();
listener.setServiceNamespaceURI(targetNamespace);
when(receiverBase.getListener()).thenReturn(listener);
when(adp.getReceivers()).thenAnswer(new Answer<Iterable<Receiver>>() {
public Iterable<Receiver> answer(InvocationOnMock invocation) throws Throwable {
return Arrays.asList(receiverBase);
}
});
when(adp.getName()).thenReturn(adapterName);
when(cfg.getClassLoader()).thenReturn(this.getClass().getClassLoader());
when(adp.getConfigurationClassLoader()).thenReturn(this.getClass().getClassLoader());
when(simple.getConfigurationClassLoader()).thenReturn(this.getClass().getClassLoader());
return simple;
}
Aggregations