<commit_before>package org.jboss.hal.testsuite.test.runtime.messaging.deployment;

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.transaction.UserTransaction;

@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class MessagingStatisticsBean {

    @Resource(mappedName = "java:/JmsXA")
    private ConnectionFactory connectionFactory;

    @Resource(mappedName = "java:/jms/queue/test")
    private Queue queue;

    @Resource
    private UserTransaction tx;

    public void commit() {
        try {
            tx.begin();
            sendMessage();
            tx.commit();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public void rollback() {
        try {
            tx.begin();
            sendMessage();
            tx.rollback();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private void sendMessage() throws JMSException {
        Connection connection = null;
        try {
            connection = connectionFactory.createConnection();
            Session session = connection.createSession();
            MessageProducer producer = session.createProducer(queue);
            connection.start();
            producer.send(session.createTextMessage("Sample message."));
        } finally {
            if (connection != null) {
                connection.close();
            }
        }<commit_msg>Making runtime messaging test issues investigation easier.<commit_after>package org.jboss.hal.testsuite.test.runtime.messaging.deployment;

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;

@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class MessagingStatisticsBean {

    @Resource(mappedName = "java:/JmsXA")
    private ConnectionFactory connectionFactory;

    @Resource(mappedName = "java:/jms/queue/test")
    private Queue queue;

    @Resource
    private UserTransaction tx;

    public void commit() {
        try {
            tx.begin();
            sendMessage();
            tx.commit();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public void rollback() {
        try {
            tx.begin();
            sendMessage();
            tx.rollback();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    private void sendMessage() throws JMSException, IllegalStateException, SecurityException, SystemException {
        Connection connection = null;
        try {
            connection = connectionFactory.createConnection();
            Session session = connection.createSession();
            MessageProducer producer = session.createProducer(queue);
            connection.start();
            producer.send(session.createTextMessage("Sample message."));
        } catch (Throwable t) {
            tx.rollback();
            throw t;
        } finally {
            if (connection != null) {
                connection.close();
            }
        }
{'fraction_non_alphanumeric': 0.0957041870581838, 'fraction_numerical': 0.0, 'mean_word_length': 2.5239463601532566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5665601', 'n_tokens_mistral': 944, 'n_tokens_neox': 918, 'n_words': 205}