Search in sources :

Example 1 with MessageKeeperMessage

use of nl.nn.adapterframework.util.MessageKeeperMessage in project iaf by ibissource.

the class ShowScheduler method getJobMessages.

private List<Map<String, Object>> getJobMessages(JobDetail jobDetail) throws ApiException {
    List<Map<String, Object>> messages = new ArrayList<Map<String, Object>>();
    IJob jobdef = (IJob) jobDetail.getJobDataMap().get(ConfiguredJob.JOBDEF_KEY);
    for (int t = 0; t < jobdef.getMessageKeeper().size(); t++) {
        Map<String, Object> message = new HashMap<String, Object>(3);
        MessageKeeperMessage job = jobdef.getMessageKeeper().getMessage(t);
        message.put("text", job.getMessageText());
        message.put("date", job.getMessageDate());
        message.put("level", job.getMessageLevel());
        messages.add(message);
    }
    return messages;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IJob(nl.nn.adapterframework.scheduler.job.IJob) MessageKeeperMessage(nl.nn.adapterframework.util.MessageKeeperMessage) ArrayList(java.util.ArrayList) Map(java.util.Map) JobDataMap(org.quartz.JobDataMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with MessageKeeperMessage

use of nl.nn.adapterframework.util.MessageKeeperMessage in project iaf by ibissource.

the class ShowConfigurationStatus method mapAdapterMessages.

private ArrayList<Object> mapAdapterMessages(Adapter adapter) {
    int totalMessages = adapter.getMessageKeeper().size();
    // adapter.getMessageKeeper().get
    ArrayList<Object> messages = new ArrayList<Object>(totalMessages);
    for (int t = 0; t < totalMessages; t++) {
        Map<String, Object> message = new HashMap<String, Object>();
        MessageKeeperMessage msg = adapter.getMessageKeeper().getMessage(t);
        message.put("message", msg.getMessageText());
        message.put("date", msg.getMessageDate());
        message.put("level", msg.getMessageLevel());
        message.put("capacity", adapter.getMessageKeeper().capacity());
        messages.add(message);
    }
    return messages;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MessageKeeperMessage(nl.nn.adapterframework.util.MessageKeeperMessage) ArrayList(java.util.ArrayList)

Example 3 with MessageKeeperMessage

use of nl.nn.adapterframework.util.MessageKeeperMessage in project iaf by ibissource.

the class IbisContextTest method nullClassLoader.

@Test
public void nullClassLoader() {
    String configurationName = "ConfigWithNullClassLoader";
    try (IbisContext context = new IbisTestContext(configurationName, TestClassLoader.class)) {
        context.init(false);
        assertEquals("TestConfiguration", context.getApplicationName());
        assertEquals(0, context.getIbisManager().getConfigurations().size());
        MessageEventListener events = context.getBean("MessageEventListener", MessageEventListener.class);
        MessageKeeperMessage message = events.getMessageKeeper().getMessage(events.getMessageKeeper().size() - 2);
        assertNotNull("unable to find MessageKeeperMessage", message);
        assertThat(message.getMessageText(), Matchers.endsWith("error configuring ClassLoader for configuration [ConfigWithNullClassLoader]: (ClassLoaderException) test-exception"));
    }
}
Also used : MessageEventListener(nl.nn.adapterframework.lifecycle.MessageEventListener) MessageKeeperMessage(nl.nn.adapterframework.util.MessageKeeperMessage) Test(org.junit.Test)

Example 4 with MessageKeeperMessage

use of nl.nn.adapterframework.util.MessageKeeperMessage in project iaf by ibissource.

the class ShowScheduler method getJobMessages.

private List<Map<String, Object>> getJobMessages(JobDef jobdef) throws ApiException {
    List<Map<String, Object>> messages = new ArrayList<Map<String, Object>>();
    for (int t = 0; t < jobdef.getMessageKeeper().size(); t++) {
        Map<String, Object> message = new HashMap<String, Object>(3);
        MessageKeeperMessage job = jobdef.getMessageKeeper().getMessage(t);
        message.put("text", job.getMessageText());
        message.put("date", job.getMessageDate());
        message.put("level", job.getMessageLevel());
        messages.add(message);
    }
    return messages;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MessageKeeperMessage(nl.nn.adapterframework.util.MessageKeeperMessage) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) JobDataMap(org.quartz.JobDataMap)

Example 5 with MessageKeeperMessage

use of nl.nn.adapterframework.util.MessageKeeperMessage in project iaf by ibissource.

the class DatabaseSchedulerTest method executeJob.

@Test
public void executeJob() throws Exception {
    ResultSetBuilder builder = FixedQuerySenderMock.ResultSetBuilder.create();
    builder.setValue("JOBNAME", "dummy name");
    builder.setValue("JOBGROUP", "dummy group");
    builder.setValue("ADAPTER", "testAdapter");
    builder.setValue("RECEIVER", "testReceiver");
    builder.setValue("CRON", "");
    builder.setValue("EXECUTIONINTERVAL", "10");
    builder.setValue("MESSAGE", "dummy message");
    Adapter adapter = configuration.createBean(Adapter.class);
    adapter.setName("testAdapter");
    configuration.registerAdapter(adapter);
    configuration.mockQuery("SELECT COUNT(*) FROM IBISSCHEDULES", builder.build());
    job.execute(configuration.getIbisManager());
    MessageKeeper messageKeeper = job.getMessageKeeper();
    for (int i = 0; i < messageKeeper.size(); i++) {
        MessageKeeperMessage message = messageKeeper.getMessage(i);
        if ("ERROR".equals(message.getMessageLevel())) {
            assertThat(message.getMessageText(), CoreMatchers.containsString("adapter [testAdapter] receiver [testReceiver] not registered"));
        }
    }
}
Also used : ResultSetBuilder(nl.nn.adapterframework.testutil.FixedQuerySenderMock.ResultSetBuilder) MessageKeeperMessage(nl.nn.adapterframework.util.MessageKeeperMessage) MessageKeeper(nl.nn.adapterframework.util.MessageKeeper) Adapter(nl.nn.adapterframework.core.Adapter) Test(org.junit.Test)

Aggregations

MessageKeeperMessage (nl.nn.adapterframework.util.MessageKeeperMessage)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)2 Test (org.junit.Test)2 JobDataMap (org.quartz.JobDataMap)2 Adapter (nl.nn.adapterframework.core.Adapter)1 MessageEventListener (nl.nn.adapterframework.lifecycle.MessageEventListener)1 IJob (nl.nn.adapterframework.scheduler.job.IJob)1 ResultSetBuilder (nl.nn.adapterframework.testutil.FixedQuerySenderMock.ResultSetBuilder)1 MessageKeeper (nl.nn.adapterframework.util.MessageKeeper)1