• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmrs / openmrs-core / 27147200794

08 Jun 2026 03:09PM UTC coverage: 63.494% (-10.1%) from 73.596%
27147200794

push

github

web-flow
TRUNK-6516: Provide CDC mechanism with Debezium (#6151)

16 of 78 new or added lines in 8 files covered. (20.51%)

39 existing lines in 3 files now uncovered.

23804 of 37490 relevant lines covered (63.49%)

0.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/api/src/main/java/org/openmrs/event/EventPublisher.java
1
/**
2
 * This Source Code Form is subject to the terms of the Mozilla Public License,
3
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
 * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5
 * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6
 *
7
 * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8
 * graphic logo is a trademark of OpenMRS Inc.
9
 */
10
package org.openmrs.event;
11

12
import org.hibernate.HibernateException;
13
import org.hibernate.SessionFactory;
14
import org.hibernate.engine.spi.SessionImplementor;
15
import org.jspecify.annotations.NonNull;
16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
18
import org.springframework.context.ApplicationEventPublisher;
19
import org.springframework.context.annotation.Primary;
20
import org.springframework.stereotype.Component;
21

22
/**
23
 * OpenMRS custom {@link ApplicationEventPublisher}, which populates
24
 * sessionId in order to be able to group events happening in the same session.
25
 * <p>
26
 * It can be autowired as {@link EventPublisher} or Spring's {@link ApplicationEventPublisher}.
27
 * 
28
 * @since 2.9.0
29
 */
30
@Primary
31
@Component
32
public class EventPublisher implements ApplicationEventPublisher {
33
        private static final Logger log = LoggerFactory.getLogger(EventPublisher.class);
1✔
34
        
35
        private final ApplicationEventPublisher delegate;
36
        private final SessionFactory sessionFactory;
37
        
38
        public EventPublisher(ApplicationEventPublisher delegate, SessionFactory sessionFactory) {
1✔
39
                this.delegate = delegate;
1✔
40
                this.sessionFactory = sessionFactory;
1✔
41
        }
1✔
42

43
        @Override
44
        public void publishEvent(@NonNull Object event) {
45
                if (event instanceof BaseSessionEvent) {
1✔
46
                        try {
47
                                String sessionId = ((SessionImplementor) sessionFactory.getCurrentSession()).getSessionIdentifier().toString();
1✔
48
                                BaseSessionEvent sessionEvent = (BaseSessionEvent) event;
1✔
49
                                sessionEvent.setSessionId(sessionId);
1✔
NEW
50
                        } catch (HibernateException e) {
×
NEW
51
                                log.debug("No session bound to the current thread: {}", e.getMessage());
×
52
                        }
1✔
53
                }
54
                delegate.publishEvent(event);
1✔
55
        }
1✔
56

57
        
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc