Skip to content

Commit af4e489

Browse files
author
Maksim Kostromin
committed
update activemq-spring-stomp
1 parent ca418b3 commit af4e489

File tree

95 files changed

+180
-12861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+180
-12861
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ script:
4444

4545
# spring-jms-docker-activemq
4646
- cd $root/spring-jms-docker-activemq
47-
- bash gradlew clean integrationTests
4847
- bash gradlew clean build
4948

5049
# activemq-spring-stomp
5150
- cd $root/activemq-spring-stomp
52-
- bash gradlew clean integrationTests build
51+
- bash gradlew clean build
52+
- bash gradlew dockerUp
53+
- http :8080/api/messages
54+
- bash gradlew dockerDown
5355

5456
before_cache:
5557
- rm -rf $HOME/.gradle/caches/modules-2/modules-2.lock

activemq-spring-stomp/build.gradle

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,24 @@
1-
plugins {
2-
id "com.avast.gradle.docker-compose" version "0.3.21"
3-
}
4-
5-
dockerCompose {
6-
useComposeFiles = ["$projectDir/docker-compose.yml"]
7-
captureContainersOutput = true
8-
stopContainers = true
9-
removeContainers = true
10-
removeImages = "Local"
11-
removeVolumes = true
12-
projectName = "$rootProject.name"
13-
}
14-
151
["clean", "assemble", "test", "build"].each { taskName ->
162
tasks.create(taskName) { task ->
173
gradle.includedBuilds.each { build ->
4+
if (build.name == "docker") return
185
dependsOn gradle.includedBuild(build.name).task(":$taskName")
196
}
207
}
218
}
229

23-
["test", "build"].each {
24-
def task = tasks.findByName it
25-
task.shouldRunAfter clean, assemble, composeUp
26-
task.dependsOn assemble, composeUp
27-
task.finalizedBy composeDown
28-
}
29-
30-
task integrationTests(dependsOn: "test")
31-
32-
// bootRun -> run-$projectName
33-
gradle.includedBuilds.each { build ->
34-
tasks.create("run-$build.name") { task ->
35-
dependsOn assemble, composeUp, gradle.includedBuild(build.name).task(":bootRun")
36-
shouldRunAfter clean, assemble, composeUp
37-
finalizedBy composeDown
38-
}
39-
}
40-
4110
["dockerUp", "dockerDown"].each { taskName ->
4211
gradle.includedBuilds.findAll({ it.name == "docker" }).each { build ->
4312
tasks.create(taskName) { task ->
4413
dependsOn gradle.includedBuild(build.name).task(":$taskName")
4514
}
4615
}
4716
}
17+
18+
// bootRun -> run-$projectName
19+
gradle.includedBuilds.each { build ->
20+
tasks.create("run-$build.name") { task ->
21+
dependsOn assemble, gradle.includedBuild(build.name).task(":bootRun")
22+
shouldRunAfter clean, assemble
23+
}
24+
}

activemq-spring-stomp/docker/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
dockerCompose {
7-
useComposeFiles = ["$projectDir/docker-compose.yml"]
7+
useComposeFiles = ["$projectDir/src/docker-compose.yml"]
88
captureContainersOutput = true
99
stopContainers = true
1010
removeContainers = true

activemq-spring-stomp/docker/docker-compose.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
version: "2.1"
2+
3+
services:
4+
5+
activemq:
6+
image: webcenter/activemq:5.14.3
7+
ports:
8+
- "1883:1883" # mqtt
9+
- "5672:5672" # amqp
10+
- "8161:8161" # ui
11+
- "61613:61613" # stomp
12+
- "61614:61614" # ws
13+
- "61616:61616" # jms
14+
networks: [backing-services]
15+
volumes:
16+
- "activemq-data:/opt/activemq/conf"
17+
- "activemq-data:/data/activemq"
18+
- "activemq-data:/var/log/activemq"
19+
environment:
20+
ACTIVEMQ_MIN_MEMORY: 512
21+
ACTIVEMQ_MAX_MEMORY: 2048
22+
ACTIVEMQ_ENABLED_SCHEDULER: "true"
23+
ACTIVEMQ_REMOVE_DEFAULT_ACCOUNT: "true"
24+
ACTIVEMQ_ADMIN_LOGIN: admin
25+
ACTIVEMQ_ADMIN_PASSWORD: password
26+
27+
postgres:
28+
depends_on: [activemq]
29+
image: healthcheck/postgres:alpine
30+
ports: ["5432:5432"]
31+
networks: [backing-services]
32+
volumes: ["postgres-data:/var/lib/postgresql/data"]
33+
environment:
34+
POSTGRES_DB: db
35+
POSTGRES_USER: user
36+
POSTGRES_PASSWORD: password
37+
38+
messaging-backend:
39+
build:
40+
context: ../..
41+
dockerfile: ./docker/src/messaging-backend/Dockerfile
42+
depends_on:
43+
postgres:
44+
condition: service_healthy
45+
environment:
46+
MQ_HOST: activemq
47+
DB_HOST: postgres
48+
image: 127.0.0.1:5000/messaging-backend
49+
ports: ["8080:8080"]
50+
volumes: ["messaging-backend-data:/home/app"]
51+
networks: [backing-services]
52+
53+
messaging-frontend-admin:
54+
build:
55+
context: ../..
56+
dockerfile: ./docker/src/messaging-frontend-admin/Dockerfile
57+
depends_on:
58+
messaging-backend:
59+
condition: service_healthy
60+
environment:
61+
MESSAGING_SERVICE_HOST: 127.0.0.1
62+
# MESSAGING_SERVICE_HOST: messaging-backend
63+
image: 127.0.0.1:5000/messaging-frontend-admin
64+
ports: ["8002:8002"]
65+
volumes: ["messaging-frontend-admin-data:/home/app"]
66+
networks: [backing-services]
67+
68+
# messaging-frontend-client:
69+
# build:
70+
# context: ../..
71+
# dockerfile: ./docker/src/messaging-frontend-client/Dockerfile
72+
# depends_on:
73+
# messaging-backend:
74+
# condition: service_healthy
75+
# environment:
76+
# MESSAGING_SERVICE_HOST: 127.0.0.1
77+
# image: 127.0.0.1:5000/messaging-frontend-client
78+
# ports: ["8001:8001"]
79+
# volumes: ["messaging-frontend-client-data:/home/app"]
80+
# networks: [backing-services]
81+
82+
volumes:
83+
activemq-data: {}
84+
postgres-data: {}
85+
messaging-backend-data: {}
86+
messaging-frontend-admin-data: {}
87+
messaging-frontend-client-data: {}
88+
89+
networks:
90+
backing-services:
91+
driver: bridge
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM openjdk:8u131-jre-alpine
2+
MAINTAINER Maksim Kostromin <[email protected]>
3+
RUN apk --no-cache add busybox-suid bash curl \
4+
&& addgroup app-group \
5+
&& adduser -h /home/app -s /bin/bash -D -u 1025 app app-group
6+
USER app
7+
WORKDIR /home/app
8+
ENTRYPOINT ["java", "-jar", "./app.jar"]
9+
EXPOSE 8080
10+
HEALTHCHECK --interval=30s --timeout=30s --retries=10 CMD curl -f http://127.0.0.1:8080/health || exit 1
11+
COPY ./messaging-backend/build/libs/*.jar ./app.jar
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM openjdk:8u131-jre-alpine
2+
MAINTAINER Maksim Kostromin <[email protected]>
3+
RUN apk --no-cache add busybox-suid bash curl \
4+
&& addgroup app-group \
5+
&& adduser -h /home/app -s /bin/bash -D -u 1025 app app-group
6+
USER app
7+
WORKDIR /home/app
8+
ENTRYPOINT ["java", "-jar", "./app.jar"]
9+
EXPOSE 8002
10+
HEALTHCHECK --interval=30s --timeout=30s --retries=10 CMD curl -f http://127.0.0.1:8002/health || exit 1
11+
COPY ./messaging-frontend-admin/build/libs/*.jar ./app.jar
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM openjdk:8u131-jre-alpine
2+
MAINTAINER Maksim Kostromin <[email protected]>
3+
RUN apk --no-cache add busybox-suid bash curl \
4+
&& addgroup app-group \
5+
&& adduser -h /home/app -s /bin/bash -D -u 1025 app app-group
6+
USER app
7+
WORKDIR /home/app
8+
ENTRYPOINT ["java", "-jar", "./app.jar"]
9+
EXPOSE 8001
10+
HEALTHCHECK --interval=30s --timeout=30s --retries=10 CMD curl -f http://127.0.0.1:8001/health || exit 1
11+
COPY ./messaging-frontend-client/build/libs/*.jar ./app.jar

activemq-spring-stomp/messaging-backend/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ plugins {
1414
id "cn.bestwu.propdeps-eclipse" version "0.0.10"
1515
id "com.github.ben-manes.versions" version "0.14.0"
1616
id "org.springframework.boot" version "1.5.7.RELEASE"
17+
id "com.avast.gradle.docker-compose" version "0.3.21"
1718
id "com.ewerk.gradle.plugins.querydsl" version "1.0.8"
1819
id "io.spring.dependency-management" version "1.0.3.RELEASE"
1920
}
@@ -33,6 +34,7 @@ dependencies {
3334
"io.projectreactor:reactor-net"
3435

3536
compile("org.springframework.boot:spring-boot-starter-mustache")
37+
compile("org.springframework.boot:spring-boot-starter-actuator")
3638

3739
compile("org.springframework.boot:spring-boot-starter-activemq")
3840

@@ -79,3 +81,19 @@ sourceSets {
7981
clean {
8082
delete "$projectDir/out"
8183
}
84+
85+
dockerCompose {
86+
useComposeFiles = ["$projectDir/docker-compose.yml"]
87+
captureContainersOutput = true
88+
stopContainers = true
89+
removeContainers = true
90+
removeImages = "Local"
91+
removeVolumes = true
92+
projectName = "$rootProject.name"
93+
}
94+
95+
[test, build, bootRun].each {
96+
it.shouldRunAfter clean, assemble, composeUp
97+
it.dependsOn assemble, composeUp
98+
it.finalizedBy composeDown
99+
}

activemq-spring-stomp/messaging-backend/src/main/java/daggerok/domain/audit/AbstractAuditEntity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import com.fasterxml.jackson.annotation.JsonFormat;
44
import lombok.Data;
5+
import org.springframework.data.annotation.CreatedBy;
56
import org.springframework.data.annotation.CreatedDate;
7+
import org.springframework.data.annotation.LastModifiedBy;
68
import org.springframework.data.annotation.LastModifiedDate;
79
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
810
import org.springframework.format.annotation.DateTimeFormat;
@@ -37,11 +39,10 @@ public abstract class AbstractAuditEntity implements Serializable {
3739
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS")
3840
@DateTimeFormat(iso = DATE_TIME)
3941
LocalDateTime modifiedDate;
40-
/*
42+
4143
@CreatedBy
4244
String createdBy;
4345

4446
@LastModifiedBy
4547
String lastModifiedBy;
46-
*/
4748
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
package daggerok.web;
22

3-
import org.springframework.stereotype.Controller;
43
import org.springframework.web.bind.annotation.GetMapping;
4+
import org.springframework.web.bind.annotation.RestController;
55

6-
@Controller
6+
import java.util.Collections;
7+
import java.util.List;
8+
import java.util.Map;
9+
10+
import static java.util.Arrays.asList;
11+
12+
@RestController
713
public class IndexPage {
814

915
@GetMapping("/")
10-
public String index() {
11-
return "/index.html";
12-
}
13-
14-
@GetMapping({ "", "/404" })
15-
public String redirect() {
16-
return "redirect:/";
16+
public List<Map<String, String>> index() {
17+
return asList(
18+
Collections.singletonMap("GET", "/api/messages"),
19+
Collections.singletonMap("POST", "/api/v1/messages")
20+
);
1721
}
1822
}

0 commit comments

Comments
 (0)