<commit_before>package com.ddd.poc.domain.core.service;

import com.ddd.poc.domain.core.event.DomainEvent;
import com.ddd.poc.domain.core.dao.EventDomainDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class EventBus {

    private final static Logger LOGGER = LoggerFactory.getLogger(EventBus.class);

    private final ApplicationEventPublisher publisher;

    private final EventDomainDao eventDomainDao;

    @Autowired
    public EventBus(ApplicationEventPublisher publisher, EventDomainDao eventDomainDao) {
        this.publisher = publisher;
        this.eventDomainDao = eventDomainDao;
    }


    @Transactional
    public void publishEvent(DomainEvent event) {
        try {
            eventDomainDao.create(event).save();
            publisher.publishEvent(event);
        } catch (Exception ex) {
            LOGGER.error("An error occured during event publishing, event: {}, exception: {}", event, ex.getMessage(), ex);
        }
    }
}<commit_msg>always publish event in a new transaction<commit_after>package com.ddd.poc.domain.core.service;

import com.ddd.poc.domain.core.event.DomainEvent;
import com.ddd.poc.domain.core.dao.EventDomainDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class EventBus {

    private final static Logger LOGGER = LoggerFactory.getLogger(EventBus.class);

    private final ApplicationEventPublisher publisher;

    private final EventDomainDao eventDomainDao;

    @Autowired
    public EventBus(ApplicationEventPublisher publisher, EventDomainDao eventDomainDao) {
        this.publisher = publisher;
        this.eventDomainDao = eventDomainDao;
    }


    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void publishEvent(DomainEvent event) {
        try {
            eventDomainDao.create(event).save();
            publisher.publishEvent(event);
        } catch (Exception ex) {
            LOGGER.error("An error occured during event publishing, event: {}, exception: {}", event, ex.getMessage(), ex);
        }
    }
}
{'fraction_non_alphanumeric': 0.0905587668593449, 'fraction_numerical': 0.0015414258188824663, 'mean_word_length': 4.090196078431372, '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': '3956362', 'n_tokens_mistral': 700, 'n_tokens_neox': 714, 'n_words': 145}