Search in sources :

Example 6 with Receiver

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;
}
Also used : RunState(nl.nn.adapterframework.util.RunState) ListenerException(nl.nn.adapterframework.core.ListenerException) Configuration(nl.nn.adapterframework.configuration.Configuration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IMessageBrowser(nl.nn.adapterframework.core.IMessageBrowser) Receiver(nl.nn.adapterframework.receivers.Receiver) Date(java.util.Date)

Example 7 with Receiver

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;
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Receiver(nl.nn.adapterframework.receivers.Receiver) Adapter(nl.nn.adapterframework.core.Adapter) PipeLine(nl.nn.adapterframework.core.PipeLine) WebServiceListener(nl.nn.adapterframework.http.WebServiceListener)

Aggregations

Receiver (nl.nn.adapterframework.receivers.Receiver)7 Adapter (nl.nn.adapterframework.core.Adapter)4 HashMap (java.util.HashMap)3 Configuration (nl.nn.adapterframework.configuration.Configuration)3 PipeLine (nl.nn.adapterframework.core.PipeLine)3 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)2 IAdapter (nl.nn.adapterframework.core.IAdapter)2 IListener (nl.nn.adapterframework.core.IListener)2 WebServiceListener (nl.nn.adapterframework.http.WebServiceListener)2 WsdlGenerator (nl.nn.adapterframework.soap.WsdlGenerator)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1