Search in sources :

Example 6 with CoordinatorActionMessage

use of org.apache.oozie.client.event.message.CoordinatorActionMessage in project oozie by apache.

the class TestJMSJobEventListener method testOnCoordinatorJobFailureEvent.

@Test
public void testOnCoordinatorJobFailureEvent() throws ParseException {
    JMSJobEventListener coordEventListener = new JMSJobEventListener();
    coordEventListener.init(conf);
    Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
    Date nominalTime = DateUtils.parseDateUTC("2011-07-11T00:00Z");
    Date endDate = new Date();
    CoordinatorActionEvent cae = new CoordinatorActionEvent("caId1", "caJobId1", CoordinatorAction.Status.FAILED, "user1", "wf-app-name1", nominalTime, startDate, null);
    cae.setEndTime(endDate);
    cae.setErrorCode("E0101");
    cae.setErrorMessage("dummyError");
    ConnectionContext jmsContext = getConnectionContext();
    try {
        Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
        MessageConsumer consumer = jmsContext.createConsumer(session, coordEventListener.getTopic(cae));
        coordEventListener.onCoordinatorActionEvent(cae);
        TextMessage message = (TextMessage) consumer.receive(5000);
        assertFalse(message.getText().contains("missingDependency"));
        CoordinatorActionMessage coordActionFailMessage = JMSMessagingUtils.getEventMessage(message);
        assertEquals(CoordinatorAction.Status.FAILED, coordActionFailMessage.getStatus());
        assertEquals(startDate, coordActionFailMessage.getStartTime());
        assertEquals(endDate, coordActionFailMessage.getEndTime());
        assertEquals("caJobId1", coordActionFailMessage.getParentId());
        assertEquals("caId1", coordActionFailMessage.getId());
        assertEquals(MessageType.JOB, coordActionFailMessage.getMessageType());
        assertEquals(AppType.COORDINATOR_ACTION, coordActionFailMessage.getAppType());
        assertEquals(EventStatus.FAILURE, coordActionFailMessage.getEventStatus());
        assertEquals("user1", coordActionFailMessage.getUser());
        assertEquals("wf-app-name1", coordActionFailMessage.getAppName());
        assertEquals("E0101", coordActionFailMessage.getErrorCode());
        assertEquals("dummyError", coordActionFailMessage.getErrorMessage());
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : CoordinatorActionMessage(org.apache.oozie.client.event.message.CoordinatorActionMessage) MessageConsumer(javax.jms.MessageConsumer) ConnectionContext(org.apache.oozie.jms.ConnectionContext) Date(java.util.Date) TextMessage(javax.jms.TextMessage) ParseException(java.text.ParseException) JMSJobEventListener(org.apache.oozie.jms.JMSJobEventListener) Session(javax.jms.Session) Test(org.junit.Test)

Example 7 with CoordinatorActionMessage

use of org.apache.oozie.client.event.message.CoordinatorActionMessage in project oozie by apache.

the class JMSJobEventListener method onCoordinatorActionEvent.

@Override
public void onCoordinatorActionEvent(CoordinatorActionEvent event) {
    CoordinatorActionMessage coordActionMessage = MessageFactory.createCoordinatorActionMessage(event);
    serializeJMSMessage(coordActionMessage, getTopic(event));
}
Also used : CoordinatorActionMessage(org.apache.oozie.client.event.message.CoordinatorActionMessage)

Aggregations

CoordinatorActionMessage (org.apache.oozie.client.event.message.CoordinatorActionMessage)7 TextMessage (javax.jms.TextMessage)6 ParseException (java.text.ParseException)5 Date (java.util.Date)5 MessageConsumer (javax.jms.MessageConsumer)5 Session (javax.jms.Session)5 ConnectionContext (org.apache.oozie.jms.ConnectionContext)5 JMSJobEventListener (org.apache.oozie.jms.JMSJobEventListener)5 Test (org.junit.Test)5 SLAMessage (org.apache.oozie.client.event.message.SLAMessage)1 WorkflowJobMessage (org.apache.oozie.client.event.message.WorkflowJobMessage)1