Skip to content

Commit 6d3a5d4

Browse files
committed
fix: remove dependency between api and jms modules
1 parent b0e1501 commit 6d3a5d4

File tree

6 files changed

+108
-15
lines changed

6 files changed

+108
-15
lines changed

listener-jms/pom.xml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
</properties>
1818

1919
<dependencies>
20-
<dependency>
21-
<groupId>fr.insee.pearljam</groupId>
22-
<artifactId>api</artifactId>
23-
<version>${project.version}</version>
24-
</dependency>
25-
2620
<dependency>
2721
<groupId>org.springframework.boot</groupId>
2822
<artifactId>spring-boot-starter-actuator</artifactId>
@@ -103,6 +97,22 @@
10397
<optional>true</optional>
10498
</dependency>
10599

100+
<dependency>
101+
<groupId>org.springframework.boot</groupId>
102+
<artifactId>spring-boot-starter-data-jpa</artifactId>
103+
</dependency>
104+
105+
<dependency>
106+
<groupId>org.postgresql</groupId>
107+
<artifactId>postgresql</artifactId>
108+
</dependency>
109+
110+
<dependency>
111+
<groupId>org.liquibase</groupId>
112+
<artifactId>liquibase-core</artifactId>
113+
<scope>test</scope>
114+
</dependency>
115+
106116
<dependency>
107117
<groupId>org.springframework.boot</groupId>
108118
<artifactId>spring-boot-docker-compose</artifactId>
@@ -119,6 +129,33 @@
119129
<artifactId>maven-install-plugin</artifactId>
120130
<version>3.1.1</version>
121131
</plugin>
132+
<!-- Copy Liquibase files from API module for tests -->
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-resources-plugin</artifactId>
136+
<version>3.3.1</version>
137+
<executions>
138+
<execution>
139+
<id>copy-liquibase-resources</id>
140+
<phase>process-test-resources</phase>
141+
<goals>
142+
<goal>copy-resources</goal>
143+
</goals>
144+
<configuration>
145+
<outputDirectory>${project.build.testOutputDirectory}/db</outputDirectory>
146+
<resources>
147+
<resource>
148+
<directory>${project.basedir}/../api/src/main/resources/db</directory>
149+
<includes>
150+
<include>**/*.xml</include>
151+
<include>**/*.sql</include>
152+
</includes>
153+
</resource>
154+
</resources>
155+
</configuration>
156+
</execution>
157+
</executions>
158+
</plugin>
122159
<plugin>
123160
<groupId>org.springframework.boot</groupId>
124161
<artifactId>spring-boot-maven-plugin</artifactId>

listener-jms/src/main/java/fr/insee/pearljam/JMSApplication.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22

33
import lombok.extern.slf4j.Slf4j;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.autoconfigure.domain.EntityScan;
56
import org.springframework.boot.builder.SpringApplicationBuilder;
67
import org.springframework.boot.context.event.ApplicationReadyEvent;
78
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
89
import org.springframework.cache.annotation.EnableCaching;
910
import org.springframework.context.event.EventListener;
11+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
1012
import org.springframework.jms.annotation.EnableJms;
1113
import org.springframework.transaction.annotation.EnableTransactionManagement;
1214

13-
@SpringBootApplication(scanBasePackages = {
14-
"fr.insee.pearljam.jms",
15-
"fr.insee.pearljam.infrastructure.db.events"
16-
})
15+
@SpringBootApplication()
1716
@EnableTransactionManagement
1817
@ConfigurationPropertiesScan
1918
@EnableCaching
2019
@EnableJms
20+
@EntityScan(basePackages = "fr.insee.pearljam.jms.infrastructure.db")
21+
@EnableJpaRepositories(basePackages = "fr.insee.pearljam.jms.infrastructure.db")
2122
@Slf4j
2223
public class JMSApplication {
2324

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package fr.insee.pearljam.jms.infrastructure.db.events;
2+
3+
import com.fasterxml.jackson.databind.node.ObjectNode;
4+
import jakarta.persistence.Column;
5+
import jakarta.persistence.Entity;
6+
import jakarta.persistence.Id;
7+
import jakarta.persistence.Table;
8+
import lombok.Getter;
9+
import lombok.NoArgsConstructor;
10+
import lombok.Setter;
11+
import org.hibernate.annotations.CreationTimestamp;
12+
import org.hibernate.annotations.JdbcTypeCode;
13+
import org.hibernate.type.SqlTypes;
14+
15+
import java.time.LocalDateTime;
16+
import java.util.UUID;
17+
18+
@Entity
19+
@Table(name = "inbox")
20+
@Getter
21+
@Setter
22+
@NoArgsConstructor
23+
public class InboxDB {
24+
@Id
25+
@Column(length = 50)
26+
private UUID id;
27+
28+
@JdbcTypeCode(SqlTypes.JSON)
29+
@Column(columnDefinition = "jsonb")
30+
private ObjectNode payload;
31+
32+
@CreationTimestamp
33+
@Column(name = "created_date", nullable = false, updatable = false)
34+
private LocalDateTime createdDate;
35+
36+
public InboxDB(UUID id, ObjectNode payload) {
37+
super();
38+
this.id = id;
39+
this.payload = payload;
40+
}
41+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package fr.insee.pearljam.jms.infrastructure.db.events;
2+
3+
import org.springframework.data.jpa.repository.JpaRepository;
4+
import org.springframework.data.jpa.repository.Query;
5+
import org.springframework.stereotype.Repository;
6+
7+
import java.util.List;
8+
import java.util.UUID;
9+
10+
@Repository
11+
public interface InboxJpaRepository extends JpaRepository<InboxDB, UUID> {
12+
13+
@Query("SELECT i FROM InboxDB i ORDER BY i.createdDate ASC")
14+
List<InboxDB> findAllOrderByCreatedDate();
15+
}

listener-jms/src/main/java/fr/insee/pearljam/jms/service/MultimodeSubscriber.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package fr.insee.pearljam.jms.service;
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
4-
import com.fasterxml.jackson.databind.node.ObjectNode;
54
import fr.insee.modelefiliere.EventDto;
6-
import fr.insee.pearljam.infrastructure.db.events.InboxDB;
7-
import fr.insee.pearljam.infrastructure.db.events.InboxJpaRepository;
85
import fr.insee.pearljam.jms.configuration.MultimodeProperties;
6+
import fr.insee.pearljam.jms.infrastructure.db.events.InboxDB;
7+
import fr.insee.pearljam.jms.infrastructure.db.events.InboxJpaRepository;
98
import jakarta.jms.JMSException;
109
import jakarta.jms.Message;
1110
import lombok.RequiredArgsConstructor;

listener-jms/src/test/java/fr/insee/pearljam/jms/integration/MultimodeSubscriberIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.fasterxml.jackson.databind.ObjectMapper;
44
import fr.insee.modelefiliere.EventDto;
55
import fr.insee.pearljam.JMSApplication;
6-
import fr.insee.pearljam.infrastructure.db.events.InboxDB;
7-
import fr.insee.pearljam.infrastructure.db.events.InboxJpaRepository;
6+
import fr.insee.pearljam.jms.infrastructure.db.events.InboxDB;
7+
import fr.insee.pearljam.jms.infrastructure.db.events.InboxJpaRepository;
88
import jakarta.jms.ConnectionFactory;
99
import org.junit.jupiter.api.BeforeEach;
1010
import org.junit.jupiter.api.Test;

0 commit comments

Comments
 (0)