Skip to content

Commit 36c6794

Browse files
authored
Merge pull request #1292 from ozangunalp/pulsar_quickstarts
Reactive Messaging Pulsar quickstart
2 parents adefb34 + c8b8460 commit 36c6794

40 files changed

+2483
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) for how to build these examples.
7676
* [MongoDB with Panache](./mongodb-panache-quickstart): Simplify your MongoDB applications with Panache
7777
* [MicroProfile Messaging MQTT](./mqtt-quickstart): How to interact with MQTT using MicroProfile reactive messaging
7878
* [Neo4j](./neo4j-quickstart): How to connect to a Neo4j graph datastore
79+
* [Pulsar](./pulsar-quickstart): How to interact with Apache Pulsar using MicroProfile reactive messaging
7980
* [OpenAPI and Swagger UI](./openapi-swaggerui-quickstart): Use OpenAPI and Swagger UI to expose your REST API and test your REST services
8081
* [OpenTelemetry](./opentelemetry-quickstart): How to use OpenTelemetry to monitor application performance
8182
* [OpenTracing and Jaeger](./opentracing-quickstart): How to use MicroProfile OpenTracing and Jaeger to monitor application performances

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<module>openapi-swaggerui-quickstart</module>
6868
<module>opentracing-quickstart</module>
6969
<module>opentelemetry-quickstart</module>
70+
<module>pulsar-quickstart</module>
7071
<module>quartz-quickstart</module>
7172
<module>qute-quickstart</module>
7273
<module>rabbitmq-quickstart</module>
58.5 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

pulsar-quickstart/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Quarkus Pulsar Quickstart
2+
============================
3+
4+
This project illustrates how you can interact with Apache Pulsar using MicroProfile Reactive Messaging.
5+
The complete instructions are available on https://quarkus.io/guides/pulsar-quickstart.
6+
7+
## Start the application in dev mode
8+
9+
In a first terminal, run:
10+
11+
```bash
12+
> mvn -f pulsar-quickstart-producer quarkus:dev
13+
```
14+
15+
In a second terminal, run:
16+
17+
```bash
18+
> mvn -f pulsar-quickstart-processor quarkus:dev
19+
```
20+
21+
Then, open your browser to `http://localhost:8080/quotes.html`, and click on the "Request Quote" button.
22+
23+
## Build the application in JVM mode
24+
25+
To build the applications, run:
26+
27+
```bash
28+
> mvn -f pulsar-quickstart-producer package
29+
> mvn -f pulsar-quickstart-processor package
30+
```
31+
32+
Because we are running in _prod_ mode, we need to provide an pulsar broker.
33+
The [docker-compose.yml](docker-compose.yml) file starts the broker and your application.
34+
35+
Start the broker and the applications using:
36+
37+
```bash
38+
> docker compose up --build
39+
```
40+
41+
Then, open your browser to `http://localhost:8080/quotes.html`, and click on the "Request Quote" button.
42+
43+
44+
## Build the application in native mode
45+
46+
To build the applications into native executables, run:
47+
48+
```bash
49+
> mvn -f pulsar-quickstart-producer package -Pnative -Dquarkus.native.container-build=true
50+
> mvn -f pulsar-quickstart-processor package -Pnative -Dquarkus.native.container-build=true
51+
```
52+
53+
The `-Dquarkus.native.container-build=true` instructs Quarkus to build Linux 64bits native executables, who can run inside containers.
54+
55+
Then, start the system using:
56+
57+
```bash
58+
> export QUARKUS_MODE=native
59+
> docker compose up
60+
```
61+
Then, open your browser to `http://localhost:8080/quotes.html`, and click on the "Request Quote" button.

pulsar-quickstart/docker-compose.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
version: '3.8'
2+
3+
services:
4+
5+
pulsar:
6+
image: apachepulsar/pulsar:3.0.0
7+
command: [
8+
"sh", "-c",
9+
"bin/apply-config-from-env.py conf/standalone.conf && bin/pulsar standalone -nfw -nss"
10+
]
11+
12+
ports:
13+
- "6650:6650"
14+
- "8080:8080"
15+
tmpfs:
16+
- /pulsar/data
17+
healthcheck:
18+
test: curl --fail http://localhost:8080/admin/v2/clusters || exit 1
19+
interval: 10s
20+
timeout: 10s
21+
retries: 5
22+
start_period: 5s
23+
environment:
24+
PULSAR_PREFIX_advertisedListeners: internal:pulsar://localhost:6650,external:pulsar://pulsar:6650
25+
PULSAR_PREFIX_transactionCoordinatorEnabled: true
26+
PULSAR_PREFIX_systemTopicEnabled: true
27+
networks:
28+
- pulsar-quickstart-network
29+
30+
producer:
31+
image: quarkus-quickstarts/pulsar-quickstart-producer:1.0-${QUARKUS_MODE:-jvm}
32+
depends_on:
33+
pulsar:
34+
condition: service_healthy
35+
build:
36+
context: pulsar-quickstart-producer
37+
dockerfile: src/main/docker/Dockerfile.${QUARKUS_MODE:-jvm}
38+
deploy:
39+
restart_policy:
40+
condition: on-failure
41+
environment:
42+
PULSAR_CLIENT_SERVICE_URL: pulsar://pulsar:6650
43+
ports:
44+
- "8082:8080"
45+
networks:
46+
- pulsar-quickstart-network
47+
48+
processor:
49+
image: quarkus-quickstarts/pulsar-quickstart-processor:1.0-${QUARKUS_MODE:-jvm}
50+
depends_on:
51+
pulsar:
52+
condition: service_healthy
53+
build:
54+
context: pulsar-quickstart-processor
55+
dockerfile: src/main/docker/Dockerfile.${QUARKUS_MODE:-jvm}
56+
deploy:
57+
restart_policy:
58+
condition: on-failure
59+
environment:
60+
PULSAR_CLIENT_SERVICE_URL: pulsar://pulsar:6650
61+
networks:
62+
- pulsar-quickstart-network
63+
64+
networks:
65+
pulsar-quickstart-network:
66+
name: pulsar-quickstart

0 commit comments

Comments
 (0)