Package org.apache.oozie.jms

Examples of org.apache.oozie.jms.ConnectionContext


            return null;
        }
    }

    public ConnectionContext createConnectionContext(JMSConnectionInfo connInfo) {
        ConnectionContext connCtxt = connectionMap.get(connInfo);
        if (connCtxt == null) {
            try {
                connCtxt = getConnectionContextImpl();
                connCtxt.createConnection(connInfo.getJNDIProperties());
                connCtxt.setExceptionListener(new JMSExceptionListener(connInfo, connCtxt, true));
                connectionMap.put(connInfo, connCtxt);
                LOG.info("Connection established to JMS Server for [{0}]", connInfo);
            }
            catch (Exception e) {
                LOG.warn("Exception while establishing connection to JMS Server for [{0}]", connInfo, e);
View Full Code Here


        return jmsProducerConnContext;
    }

    private ConnectionContext getConnectionContextImpl() {
        Class<?> defaultClazz = ConfigurationService.getClass(conf, JMS_CONNECTION_CONTEXT_IMPL);
        ConnectionContext connCtx = null;
        if (defaultClazz == DefaultConnectionContext.class) {
            connCtx = new DefaultConnectionContext();
        }
        else {
            connCtx = (ConnectionContext) ReflectionUtils.newInstance(defaultClazz, null);
View Full Code Here

            return false;
        }
        LOG.info("Attempting retry of connection [{0}]", connInfo);
        connRetryInfo.setNumAttempt(connRetryInfo.getNumAttempt() + 1);
        connRetryInfo.setNextDelay(connRetryInfo.getNextDelay() * retryMultiplier);
        ConnectionContext connCtxt = createConnectionContext(connInfo);
        boolean shouldRetry = false;
        if (connCtxt == null) {
            shouldRetry = true;
        }
        else {
View Full Code Here

        wfEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.RUNNING, "user1",
                "wf-app-name1", startDate, null);

        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertFalse(message.getText().contains("endTime"));
            WorkflowJobMessage wfStartMessage = JMSMessagingUtils.getEventMessage(message);
            assertEquals(WorkflowJob.Status.RUNNING, wfStartMessage.getStatus());
View Full Code Here

        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        Date endDate = new Date();
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.SUCCEEDED, "user1",
                "wf-app-name1", startDate, endDate);

        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            WorkflowJobMessage wfSuccMessage = JMSMessagingUtils.getEventMessage(message);
            assertEquals(WorkflowJob.Status.SUCCEEDED, wfSuccMessage.getStatus());
            assertEquals(startDate, wfSuccMessage.getStartTime());
View Full Code Here

        Date endDate = new Date();
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.FAILED, "user1",
                "wf-app-name1", startDate, endDate);
        wfe.setErrorCode("dummyErrorCode");
        wfe.setErrorMessage("dummyErrorMessage");
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            WorkflowJobMessage wfFailMessage = JMSMessagingUtils.getEventMessage(message);
            assertEquals(WorkflowJob.Status.FAILED, wfFailMessage.getStatus());
            assertEquals(startDate, wfFailMessage.getStartTime());
View Full Code Here

        JMSJobEventListener wfEventListener = new JMSJobEventListener();
        wfEventListener.init(conf);
        Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.SUSPENDED, "user1",
                "wf-app-name1", startDate, null);
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertFalse(message.getText().contains("endTime"));
            WorkflowJobMessage wfFailMessage = JMSMessagingUtils.getEventMessage(message);
            assertEquals(WorkflowJob.Status.SUSPENDED, wfFailMessage.getStatus());
View Full Code Here

    public void testWorkflowJobSelectors() throws ParseException {
        JMSJobEventListener wfEventListener = new JMSJobEventListener();
        wfEventListener.init(conf);
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.FAILED, "user_1",
                "wf-app-name1", new Date(), new Date());
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            String selector = JMSHeaderConstants.USER + "='user_1'";
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe), selector);
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            WorkflowJobMessage wfFailMessage = JMSMessagingUtils.getEventMessage(message);
            Assert.assertEquals(WorkflowJob.Status.FAILED, wfFailMessage.getStatus());
            assertEquals("user_1", wfFailMessage.getUser());
View Full Code Here

    public void testWorkflowJobSelectorsNegative() {
        JMSJobEventListener wfEventListener = new JMSJobEventListener();
        wfEventListener.init(conf);
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.FAILED, "user1",
                "wf-app-name1", new Date(), new Date());
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            // Pass a selector which wont match and assert for null message
            String selector = JMSHeaderConstants.USER + "='Non_matching_user'";
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe), selector);
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            assertNull(message);
            wfEventListener.destroy();
        }
View Full Code Here

    public void testWorkflowJobSelectorsOr() {
        JMSJobEventListener wfEventListener = new JMSJobEventListener();
        wfEventListener.init(conf);
        WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.FAILED, "user1",
                "wf-app-name1", new Date(), new Date());
        ConnectionContext jmsContext = getConnectionContext();
        try {
            Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
            // Pass a selector using OR condition
            String selector = JMSHeaderConstants.USER + "='Non_matching_user' OR " + JMSHeaderConstants.APP_NAME
                    + "='wf-app-name1'";
            MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe), selector);
            wfEventListener.onWorkflowJobEvent(wfe);
            TextMessage message = (TextMessage) consumer.receive(5000);
            WorkflowJobMessage wfFailMessage = JMSMessagingUtils.getEventMessage(message);
            Assert.assertEquals(WorkflowJob.Status.FAILED, wfFailMessage.getStatus());
            assertEquals("user1", wfFailMessage.getUser());
View Full Code Here

TOP

Related Classes of org.apache.oozie.jms.ConnectionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.