Search in sources :

Example 61 with TransactionAttribute

use of javax.ejb.TransactionAttribute in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityMessageServiceBean method sendModuleErrorResponseMessage.

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void sendModuleErrorResponseMessage(@Observes @ActivityMessageErrorEvent EventMessage message) {
    Connection connection = null;
    try {
        connection = getConnectionFactory().createConnection();
        final Session session = JMSUtils.connectToQueue(connection);
        log.info("Sending message back to recipient from Activity Module with correlationId {} on queue: {}", message.getJmsMessage().getJMSMessageID());
        String data = JAXBMarshaller.marshallJaxBObjectToString(message.getFault());
        TextMessage response = session.createTextMessage(data);
        response.setJMSCorrelationID(message.getJmsMessage().getJMSMessageID());
        session.createProducer(message.getJmsMessage().getJMSReplyTo()).send(response);
    } catch (ActivityModelMarshallException | JMSException e) {
        log.error("Error when returning module activity request", e);
        log.error("[ Error when returning module activity request. ] {} {}", e.getMessage(), e.getStackTrace());
    } finally {
        JMSUtils.disconnectQueue(connection);
    }
}
Also used : ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) Connection(javax.jms.Connection) JMSException(javax.jms.JMSException) TextMessage(javax.jms.TextMessage) Session(javax.jms.Session) TransactionAttribute(javax.ejb.TransactionAttribute)

Aggregations

TransactionAttribute (javax.ejb.TransactionAttribute)61 JMSException (javax.jms.JMSException)8 IOException (java.io.IOException)7 Connection (javax.jms.Connection)6 Session (javax.jms.Session)6 TextMessage (javax.jms.TextMessage)6 Query (javax.persistence.Query)5 Configuration (org.hibernate.cfg.Configuration)5 Dataset (edu.harvard.iq.dataverse.Dataset)4 ConfigMessageException (eu.europa.ec.fisheries.uvms.config.exception.ConfigMessageException)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 EJBException (javax.ejb.EJBException)4 Message (javax.jms.Message)4 MessageProducer (javax.jms.MessageProducer)4 DataFile (edu.harvard.iq.dataverse.DataFile)3 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)3 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)3 Properties (java.util.Properties)3 EntityManager (javax.persistence.EntityManager)3