Search in sources :

Example 1 with JmsCertificateWork

use of org.olat.course.certificate.model.JmsCertificateWork in project OpenOLAT by OpenOLAT.

the class CertificatesManagerImpl method onMessage.

@Override
public void onMessage(Message message) {
    if (message instanceof ObjectMessage) {
        try {
            ObjectMessage objMsg = (ObjectMessage) message;
            JmsCertificateWork workUnit = (JmsCertificateWork) objMsg.getObject();
            doCertificate(workUnit);
            message.acknowledge();
        } catch (JMSException e) {
            log.error("", e);
        } finally {
            dbInstance.commitAndCloseSession();
        }
    }
}
Also used : JmsCertificateWork(org.olat.course.certificate.model.JmsCertificateWork) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException)

Example 2 with JmsCertificateWork

use of org.olat.course.certificate.model.JmsCertificateWork in project OpenOLAT by OpenOLAT.

the class CertificatesManagerImpl method sendJmsCertificateFile.

private void sendJmsCertificateFile(Certificate certificate, CertificateTemplate template, Float score, Boolean passed, boolean sendMail) {
    QueueSender sender;
    QueueSession session = null;
    try {
        JmsCertificateWork workUnit = new JmsCertificateWork();
        workUnit.setCertificateKey(certificate.getKey());
        if (template != null) {
            workUnit.setTemplateKey(template.getKey());
        }
        workUnit.setPassed(passed);
        workUnit.setScore(score);
        workUnit.setSendMail(sendMail);
        session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
        ObjectMessage message = session.createObjectMessage();
        message.setObject(workUnit);
        sender = session.createSender(getJmsQueue());
        sender.send(message);
    } catch (JMSException e) {
        log.error("", e);
    } finally {
        if (session != null) {
            try {
                session.close();
            } catch (JMSException e) {
            // last hope
            }
        }
    }
}
Also used : JmsCertificateWork(org.olat.course.certificate.model.JmsCertificateWork) QueueSender(javax.jms.QueueSender) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) QueueSession(javax.jms.QueueSession)

Example 3 with JmsCertificateWork

use of org.olat.course.certificate.model.JmsCertificateWork in project openolat by klemens.

the class CertificatesManagerImpl method onMessage.

@Override
public void onMessage(Message message) {
    if (message instanceof ObjectMessage) {
        try {
            ObjectMessage objMsg = (ObjectMessage) message;
            JmsCertificateWork workUnit = (JmsCertificateWork) objMsg.getObject();
            doCertificate(workUnit);
            message.acknowledge();
        } catch (JMSException e) {
            log.error("", e);
        } finally {
            dbInstance.commitAndCloseSession();
        }
    }
}
Also used : JmsCertificateWork(org.olat.course.certificate.model.JmsCertificateWork) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException)

Example 4 with JmsCertificateWork

use of org.olat.course.certificate.model.JmsCertificateWork in project openolat by klemens.

the class CertificatesManagerImpl method sendJmsCertificateFile.

private void sendJmsCertificateFile(Certificate certificate, CertificateTemplate template, Float score, Boolean passed, boolean sendMail) {
    QueueSender sender;
    QueueSession session = null;
    try {
        JmsCertificateWork workUnit = new JmsCertificateWork();
        workUnit.setCertificateKey(certificate.getKey());
        if (template != null) {
            workUnit.setTemplateKey(template.getKey());
        }
        workUnit.setPassed(passed);
        workUnit.setScore(score);
        workUnit.setSendMail(sendMail);
        session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
        ObjectMessage message = session.createObjectMessage();
        message.setObject(workUnit);
        sender = session.createSender(getJmsQueue());
        sender.send(message);
    } catch (JMSException e) {
        log.error("", e);
    } finally {
        if (session != null) {
            try {
                session.close();
            } catch (JMSException e) {
            // last hope
            }
        }
    }
}
Also used : JmsCertificateWork(org.olat.course.certificate.model.JmsCertificateWork) QueueSender(javax.jms.QueueSender) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) QueueSession(javax.jms.QueueSession)

Aggregations

JMSException (javax.jms.JMSException)4 ObjectMessage (javax.jms.ObjectMessage)4 JmsCertificateWork (org.olat.course.certificate.model.JmsCertificateWork)4 QueueSender (javax.jms.QueueSender)2 QueueSession (javax.jms.QueueSession)2