Welcome to the Order Management API, a Jakarta EE and MicroProfile demo.
+ +| Method | +URL | +Description | +
|---|---|---|
| GET | +/api/orders | +Get all orders | +
| GET | +/api/orders/{id} | +Get order by ID | +
| GET | +/api/orders/user/{userId} | +Get orders by user ID | +
| GET | +/api/orders/status/{status} | +Get orders by status | +
| POST | +/api/orders | +Create new order | +
| PUT | +/api/orders/{id} | +Update order | +
| DELETE | +/api/orders/{id} | +Delete order | +
| PATCH | +/api/orders/{id}/status/{status} | +Update order status | +
| Method | +URL | +Description | +
|---|---|---|
| GET | +/api/orderItems/order/{orderId} | +Get items for an order | +
| GET | +/api/orderItems/{orderItemId} | +Get specific order item | +
| POST | +/api/orderItems/order/{orderId} | +Add item to order | +
| PUT | +/api/orderItems/{orderItemId} | +Update order item | +
| DELETE | +/api/orderItems/{orderItemId} | +Delete order item | +
curl -X GET http://localhost:8050/order/api/orders
+
+
diff --git a/code/chapter13/order/src/main/webapp/order-status-codes.html b/code/chapter13/order/src/main/webapp/order-status-codes.html
new file mode 100644
index 00000000..faed8a09
--- /dev/null
+++ b/code/chapter13/order/src/main/webapp/order-status-codes.html
@@ -0,0 +1,75 @@
+
+
+
+
+
+ This page describes the possible status codes for orders in the system.
+ +| Status Code | +Description | +
|---|---|
| CREATED | +Order has been created but not yet processed | +
| PAID | +Payment has been received for the order | +
| PROCESSING | +Order is being processed (items are being picked, packed, etc.) | +
| SHIPPED | +Order has been shipped to the customer | +
| DELIVERED | +Order has been delivered to the customer | +
| CANCELLED | +Order has been cancelled | +
MicroProfile Config Demo with Custom ConfigSource
+The Payment Service demonstrates MicroProfile Config integration with custom ConfigSource implementation.
+It provides endpoints for managing payment configuration and processing payments using dynamic configuration.
+Key Features:
+This service implements a custom MicroProfile ConfigSource that allows dynamic configuration updates:
+Redirecting to the Payment Service homepage...
+ + diff --git a/code/chapter13/reactive-messaging-hello/README.md b/code/chapter13/reactive-messaging-hello/README.md new file mode 100644 index 00000000..e6a7048f --- /dev/null +++ b/code/chapter13/reactive-messaging-hello/README.md @@ -0,0 +1,336 @@ +# Open Liberty Reactive Messaging Hello World + +A comprehensive demonstration of MicroProfile Reactive Messaging 3.0 on Open Liberty, showcasing message publishing, consuming, and processing patterns. + +## Features + +- ✅ **Message Publishing** - Send messages via REST API or programmatically +- ✅ **Message Consumption** - Receive and process messages asynchronously +- ✅ **Stream Processing** - Transform messages using @Incoming/@Outgoing +- ✅ **Multiple Patterns** - Emitter-based and Publisher-based messaging +- ✅ **REST API** - Interact with the messaging system via HTTP endpoints +- ✅ **Kafka Ready** - Pre-configured for Apache Kafka (with in-memory fallback) + +## Architecture + +``` +┌─────────────┐ ┌──────────────────┐ ┌─────────────┐ +│ REST API │─────▶│ HelloPublisher │─────▶│ Message │ +│ │ │ (Emitter/Stream) │ │ Channel │ +└─────────────┘ └──────────────────┘ └──────┬──────┘ + │ + ┌──────────────────┐ ┌──────▼──────┐ + │ HelloConsumer │◀─────│ Message │ + │ (@Incoming) │ │ Channel │ + └──────────────────┘ └─────────────┘ +``` + +## Prerequisites + +- Java 17 or later +- Maven 3.8+ +- Open Liberty 23.0.0.3+ (will be downloaded automatically) +- Optional: Apache Kafka (for production use) + +## Project Structure + +``` +reactive-messaging-hello/ +├── pom.xml +├── src/ +│ ├── main/ +│ │ ├── java/com/example/reactive/ +│ │ │ ├── ReactiveMessagingApplication.java +│ │ │ ├── model/ +│ │ │ │ └── HelloMessage.java +│ │ │ ├── publisher/ +│ │ │ │ └── HelloPublisher.java +│ │ │ ├── consumer/ +│ │ │ │ └── HelloConsumer.java +│ │ │ └── resource/ +│ │ │ └── HelloResource.java +│ │ ├── resources/ +│ │ │ └── META-INF/ +│ │ │ └── microprofile-config.properties +│ │ ├── liberty/config/ +│ │ │ └── server.xml +│ │ └── webapp/ +│ │ └── WEB-INF/ +│ │ └── beans.xml +└── README.md +``` + +## Quick Start + +### 1. Build the Application + +```bash +mvn clean package +``` + +### 2. Start Open Liberty + +```bash +mvn liberty:run +``` + +The server will start on http://localhost:9080 + +### 3. Test the Application + +**Welcome Endpoint:** +```bash +curl http://localhost:9080/api/hello +``` + +**Publish a Message:** +```bash +curl -X POST http://localhost:9080/api/hello/publish \ + -H "Content-Type: application/json" \ + -d '{"message": "Hello Reactive Messaging!"}' +``` + +**View Received Messages:** +```bash +curl http://localhost:9080/api/hello/messages +``` + +**Health Check:** +```bash +curl http://localhost:9080/api/hello/health +``` + +**Clear Messages:** +```bash +curl -X DELETE http://localhost:9080/api/hello/messages +``` + +## Configuration + +### Message Channels + +The application uses two main channels configured in `microprofile-config.properties`: + +- **`hello-out`** - Outgoing channel for publishing messages +- **`hello-in`** - Incoming channel for consuming messages + +### Connector Options + +#### Option 1: In-Memory Connector (Default for Testing) + +Uncomment in `microprofile-config.properties`: +```properties +mp.messaging.outgoing.hello-out.connector=smallrye-in-memory +mp.messaging.incoming.hello-in.connector=smallrye-in-memory +``` + +#### Option 2: Apache Kafka (Production) + +Use the default Kafka configuration: +```properties +mp.messaging.outgoing.hello-out.connector=liberty-kafka +mp.messaging.outgoing.hello-out.topic=hello-topic + +mp.messaging.incoming.hello-in.connector=liberty-kafka +mp.messaging.incoming.hello-in.topic=hello-topic +mp.messaging.incoming.hello-in.group.id=hello-consumer-group +``` + +**Start Kafka locally:** +```bash +# Using Docker +docker run -d --name kafka \ + -p 9092:9092 \ + apache/kafka:latest +``` + +## Key Concepts Demonstrated + +### 1. Emitter Pattern + +```java +@Inject +@Channel("hello-out") +EmitterMicroProfile Reactive Messaging 3.0 Demo
+