Skip to content

Commit be8f0ea

Browse files
Adding H2 on The test profile. Settings On normal profile to Connect with Mariadb
1 parent e39dff1 commit be8f0ea

File tree

5 files changed

+116
-5
lines changed

5 files changed

+116
-5
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,33 @@
33
![Java CI](https://github.com/ricardo-ribeiro/SpringBootWebRabbitMQAndKafka/workflows/Java%20CI/badge.svg)
44

55

6+
7+
8+
69
# Running Docker Services
710

811
```bash
912
cd docker
1013
docker-compose up
1114
```
1215

16+
# Docker Services
17+
18+
19+
## [ADMINER](localhost:9999)
20+
21+
Web Application MYSQL/MariaDB database explorer.
22+
Allows you to run queries and manage your database.
23+
24+
![Adminer Image](../master/docs/adminer/Adminer.png)
25+
26+
27+
## [RabbitMQ Management Console](localhost:15672)
28+
29+
RabbitMQ Management Console
30+
31+
32+
1333
# Running the Application
1434
```bash
1535
./gradlew build bootRun

build.gradle

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ dependencies {
3939
*/
4040
// Enable Spring Data with H2 in mem db
4141
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
42-
/**
43-
* Adding H2 In Memory Database For Development
44-
*/
45-
runtime 'com.h2database:h2'
42+
43+
compile 'org.mariadb.jdbc:mariadb-java-client:2.3.0'
44+
45+
4646

4747

4848
/**
@@ -58,9 +58,15 @@ dependencies {
5858
* Adding Kafka Cloud Stream Support
5959
*/
6060
implementation 'org.springframework.cloud:spring-cloud-starter-stream-kafka'
61-
61+
62+
/**
63+
* Adding H2 In Memory Database For Development
64+
*/
65+
testRuntime 'com.h2database:h2'
66+
6267

6368
testImplementation('org.springframework.boot:spring-boot-starter-test')
69+
testImplementation('org.springframework.kafka:spring-kafka-test')
6470

6571
// Spring Cloud Streams Test
6672
testCompile 'org.springframework.cloud:spring-cloud-stream-test-support'

docs/adminer/Adminer.png

99.8 KB
Loading

src/main/resources/application.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ server:
44
logging.level.root: INFO
55

66
spring:
7+
datasource:
8+
url: jdbc:mariadb://localhost:3306/ExampleDatabase
9+
username: root
10+
password: root
11+
driver-class-name: org.mariadb.jdbc.Driver
12+
validationQuery: SELECT 1
713
application:
814
name: ExampleApp
915
h2:

src/test/resources/application.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
server:
2+
port: 5757
3+
4+
logging.level.root: INFO
5+
6+
spring:
7+
datasource:
8+
url: jdbc:h2:mem:testdb
9+
username: root
10+
password: root
11+
driverClassName: org.h2.Driver
12+
validationQuery: SELECT 1
13+
application:
14+
name: ExampleApp
15+
h2:
16+
console:
17+
enabled: true
18+
cloud:
19+
stream:
20+
defaultBinder: rabbit
21+
bindings:
22+
globalEventsInput:
23+
binder: kafka
24+
destination: global_events
25+
content-type: application/json
26+
group: input-group-1
27+
globalEventsOutput:
28+
binder: kafka
29+
destination: global_events
30+
group: output-group-1
31+
content-type: application/json
32+
paymentsReceived:
33+
binder: rabbit
34+
destination: queue.payment.received
35+
group: payments
36+
paymentValidated:
37+
binder: rabbit
38+
destination: queue.payment.validated
39+
group: payments
40+
41+
binders:
42+
kafka:
43+
type: kafka
44+
environment:
45+
spring.cloud.stream.kafka:
46+
binder:
47+
brokers: localhost
48+
defaultBrokerPort: 9092
49+
bindings:
50+
globalEventsOutput:
51+
producer:
52+
configuration:
53+
key.serializer: org.apache.kafka.common.serialization.StringSerializer
54+
globalEventsInput:
55+
consumer:
56+
configuration:
57+
isolation.level: read_committed # In case of Transactional Produced, Otherwise read_uncommitted
58+
rabbit:
59+
type: rabbit
60+
environment:
61+
spring:
62+
cloud:
63+
stream:
64+
rabbit:
65+
bindings:
66+
paymentsReceived:
67+
consumer:
68+
autoBindDlq: true
69+
requeueRejected: true
70+
republishToDlq: true
71+
paymentValidated:
72+
producer:
73+
autoBindDlq: true
74+
republishToDlq: true
75+
rabbitmq:
76+
host: localhost
77+
port: 5672
78+
username: guest
79+
password: guest

0 commit comments

Comments
 (0)