Skip to content

Commit 2d6db11

Browse files
committed
Updated documentation
1 parent b624c2d commit 2d6db11

1 file changed

Lines changed: 36 additions & 24 deletions

File tree

examples/demo-service/README.md

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,69 @@
11
# ClickHouse-Java Demo Service
22

33
## About
4-
This is an example of a Spring Boot application using different ClickHouse-Java clients and features.
4+
This is and example of a Spring Boot service using ClickHouse client directly and via JPA.
5+
Example is an application that requires ClickHouse DB running externally. It can be a Docker or
6+
ClickHouse Cloud instance.
57

8+
## How to Run
69

7-
## Usage
10+
### Initialize DB
11+
Set up a ClickHouse instance.
812

9-
This example requires an instance of ClickHouse running locally on in remote server.
10-
Application uses `system.numbers` table to generate dataset of any size. It is very convenient because:
11-
- data is already there
12-
- server generates data as if it was a real table
13-
- no need to change schema or create tables
13+
Example of running with Docker:
14+
```shell
15+
docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret\
16+
-p 8123:8123 clickhouse/clickhouse-server
1417

15-
Run clickhouse instance in docker:
18+
docker ps
19+
# output should be like:
20+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
21+
2abfefc40a84 clickhouse/clickhouse-server "/entrypoint.sh" 4 seconds ago Up 2 seconds 9000/tcp, 0.0.0.0:8123->8123/tcp, :::8123->8123/tcp, 9009/tcp demo-service-db
1622
```
17-
docker run --rm -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret\
18-
-p 8123:8123 clickhouse/clickhouse-server
1923

24+
Example how to run client:
25+
```shell
26+
docker exec -it demo-service-db clickhouse-client
2027
```
2128

22-
Create table:
29+
Create table (needed for JPA example):
2330
```
2431
CREATE TABLE ui_events
2532
(
26-
`id` UUID,
33+
`id` String,
2734
`timestamp` DateTime64,
28-
`eventName` String
35+
`event_name` String,
36+
`tags` Array(String)
2937
)
3038
ENGINE = MergeTree
3139
ORDER BY timestamp
3240
```
3341

34-
To run
42+
### Run Demo-Service
3543

3644
```shell
3745
./gradlew bootRun
3846
```
3947

40-
To test
48+
### Interact with API
49+
50+
#### Direct Client
4151

52+
To read `limit` number of rows from `system.numbers`:
4253
```shell
4354
curl http://localhost:8080/direct/dataset/0?limit=100000
4455
```
4556

46-
JPA Insert
57+
#### JPA
58+
59+
To insert some data:
4760
```shell
48-
curl -v -X POST -H "Content-Type: application/json" -d '{"id": "123", "timestamp": "2025-04-07T14:30:00.000Z", "eventName": "Login", "tags": ["security", "activity"]}' http://localhost:8080/events/ui_events
49-
```
50-
JPA Select
51-
```shell
52-
curl -v -X GET http://localhost:8080/events/ui_events
61+
curl -v -X POST -H "Content-Type: application/json" \
62+
-d '{"id": "4NAD7B8HH1", "timestamp": "2025-04-07T14:30:00.000Z", "eventName": "Login", "tags": ["security", "activity"]}'\
63+
http://localhost:8080/events/ui_events
5364
```
5465

55-
## Features
56-
57-
- [x] Client V2 New Implementation
66+
To fetch inserted data:
67+
```shell
68+
curl -v -X GET http://localhost:8080/events/ui_events
69+
```

0 commit comments

Comments
 (0)