Skip to content

Commit e1e51fa

Browse files
update README.md with some gibbity after proofreading
1 parent 4c7cc38 commit e1e51fa

File tree

2 files changed

+202
-125
lines changed

2 files changed

+202
-125
lines changed

src/shop-dc-shim/README.md

Lines changed: 200 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,127 @@
11
# Shop Datacenter Shim Service
22

3-
The Shop Datacenter Shim Service is an N-Tier Java Spring Boot application that simulates a traditional on-premises retail system deployed in a datacenter environment. This service demonstrates hybrid cloud-on-premises integration by acting as a shim that bridges local shop purchases to cloud checkout services.
3+
The Shop Datacenter Shim Service is an N-Tier Java Spring Boot application that simulates a traditional on-premises retail system deployed in a datacenter environment. This service demonstrates hybrid cloud-on-premises integration by acting as a shim that bridges local shop purchases to cloud checkout services.
44

5-
## Architecture
5+
**NOTE:** This demo is an addition to an existing Astronomy Shop Demo and expects a deployment of such in the same k8s cluster
66

7-
This service follows traditional enterprise N-Tier architecture:
7+
## Demo Use Case
88

9-
- **Presentation Layer**: REST controllers for shop transaction APIs
10-
- **Business Layer**: Service classes handling local validation and cloud integration
11-
- **Data Layer**: JPA repositories with PostgreSQL for local transaction storage
12-
- **Integration Layer**: gRPC client for calling cloud checkout services
9+
This service demonstrates a real-world hybrid architecture scenario:
10+
11+
- **On-Premises Reality**: Traditional retail POS systems deployed in datacenters
12+
- **Cloud Integration**: Modern checkout and payment processing in the cloud
13+
- **Monitoring Bridge**: Shows how enterprises monitor hybrid architectures
14+
- **Technology Evolution**: Traditional Java/DB architecture calling modern microservices
15+
16+
## Demo Features & Intentional Errors
1317

14-
## Key Features
18+
### Intentional Jackson Serialization Errors
19+
The service includes **intentional Jackson serialization errors** on the transaction status endpoint (`GET /api/shop/transaction/{transactionId}`) to demonstrate real-world error scenarios:
1520

16-
- **On-Premises Retail Simulation**: Mimics traditional datacenter-deployed point-of-sale systems
17-
- **Cloud Integration**: Makes gRPC calls to cloud-hosted checkout service
18-
- **Dual Instrumentation**: Supports both AppDynamics (traditional) and Splunk Observability (modern)
19-
- **Enterprise Patterns**: Follows traditional enterprise Java patterns with database persistence
20-
- **Async Processing**: Background processing with transaction state management
21-
- **Load Generation**: Dedicated load generator simulating realistic shop transactions
21+
**What Works As Intended:**
22+
- ✅ Purchase submissions (`POST /api/shop/purchase`) - returns 202 successfully
23+
- ✅ Background transaction processing and database persistence
24+
- ✅ gRPC calls to cloud checkout service
25+
26+
### Business Context
27+
- Local shop systems handle inventory, pricing, customer data
28+
- Cloud services provide scalable checkout, payment, and fulfillment
29+
- Dual monitoring shows both AppDynamics and Splunk Observability
30+
- Demonstrates enterprise modernization patterns
2231

2332
## Environment Configuration
2433

2534
### Deployment Environment
35+
**NOTE:** These new services will be in a separate environment from your Astronomy Shop Demo. Filter to both environments to see the entire service map.
2636
- `deployment.environment.name`: `datacenter-b01`
2737
- `service.namespace`: `datacenter`
2838
- Network: Separate datacenter network (172.20.0.0/16) with bridge to cloud services
2939

3040
### Service Configuration
3141
- **Service Port**: 8070
32-
- **Database**: PostgreSQL (shop-dc-shim-db)
42+
- **Database**: SQL Server (shop-dc-shim-db)
3343
- **Cloud Integration**: gRPC to checkout service
3444
- **Monitoring**: Dual AppDynamics + Splunk Observability
3545

46+
## Development / Contribution
47+
48+
### Using Demo In A Box instance (from Splunk Show Observability4Ninjas / Portfolio Demo)
49+
**Note:** This requires the instance to have a k3s/k3d deployment with Astronomy Shop Demo
50+
- Update and use `build-image-quay-dev.sh` to build a new image with your local changes
51+
- Reference that new image in `k8s-addition.yaml` and copy to your instance
52+
- `kubectl apply -f k8s-addition.yaml` will add the `shop-dc-shim-db`, `shop-dc-shim`, and `shop-dc-load-generator` pods to your cluster
53+
- Once `shop-dc-shim` finishes spinning up (5-7min) the load generator will start sending traffic
54+
- To delete `kubectl delete -f k8s-addition.yaml` will remove all shop-dc related resources
55+
56+
### Bare Metal (thar may be dragons)
57+
**NOTE:** REQUIRES A DEPLOYMENT OF ASTRONOMY SHOP DEMO IN A LOCAL K3S CLUSTER
58+
```bash
59+
# Build the service
60+
./gradlew build
61+
62+
# Run with local profile
63+
java -jar build/libs/shop-dc-shim-*.jar
64+
65+
# Run load generator
66+
cd load-generator
67+
pip install -r requirements.txt
68+
python shop_load_generator.py --url http://localhost:8070
69+
70+
# Docker build
71+
docker build -t shop-dc-shim:latest .
72+
```
73+
74+
## Architecture
75+
76+
This service follows traditional enterprise N-Tier architecture:
77+
78+
- **Presentation Layer**: REST controllers for shop transaction APIs
79+
- **Business Layer**: Service classes handling local validation and cloud integration
80+
- **Data Layer**: JPA repositories with SQL Server for local transaction storage
81+
- **Integration Layer**: gRPC client for calling cloud checkout services
82+
83+
## Configuration
84+
85+
### Environment Variables
86+
87+
**Service Configuration:**
88+
- `SHOP_DC_SHIM_PORT`: Service port (default: 8070)
89+
- `DB_CONNECTION_STRING`: SQL Server connection string (jdbc:sqlserver://...)
90+
- `DB_USERNAME`: Database username (default: sa)
91+
- `DB_PASSWORD`: Database password (default: ShopPass123!)
92+
- `CHECKOUT_SERVICE_ADDR`: Cloud checkout service address (default: checkout:8080)
93+
- `CHECKOUT_SERVICE_HOST`: Cloud checkout service host (default: checkout)
94+
- `CHECKOUT_SERVICE_PORT`: Cloud checkout service port (default: 8080)
95+
96+
**AppDynamics Configuration:**
97+
- `APPDYNAMICS_JAVAAGENT_ENABLED`: Enable AppD agent
98+
- `APPDYNAMICS_CONTROLLER_HOST_NAME`: AppD controller
99+
- `APPDYNAMICS_AGENT_APPLICATION_NAME`: App name in AppD
100+
- `APPDYNAMICS_AGENT_TIER_NAME`: Tier name in AppD
101+
102+
**Splunk Observability:**
103+
- `OTEL_EXPORTER_OTLP_ENDPOINT`: OTLP collector endpoint
104+
- `OTEL_RESOURCE_ATTRIBUTES`: Resource attributes
105+
- `SPLUNK_PROFILER_ENABLED`: Enable profiler
106+
107+
### Startup Script
108+
The service uses `start-app-dual.sh` which matches enterprise Ansible deployment patterns:
109+
110+
```bash
111+
# AppDynamics + Splunk dual instrumentation
112+
export AGENT_DEPLOYMENT_MODE=dual
113+
java -javaagent:/opt/appdynamics/javaagent.jar \
114+
-Dagent.deployment.mode=dual \
115+
-Dotel.instrumentation.jdbc.enabled=true \
116+
-Dsplunk.profiler.enabled=true \
117+
-Dsplunk.profiler.memory.enabled=true \
118+
-Dsplunk.snapshot.profiler.enabled=true \
119+
-Dsplunk.snapshot.selection.probability=0.2 \
120+
-Dotel.exporter.otlp.endpoint=http://splunk-otel-collector-agent:4318 \
121+
-Dappdynamics.sim.enabled=true \
122+
-jar /app/*.jar
123+
```
124+
36125
## API Endpoints
37126

38127
### POST /api/shop/purchase
@@ -106,6 +195,29 @@ Check the status of a shop transaction.
106195
}
107196
```
108197

198+
### GET /api/shop/store/{storeLocation}/transactions
199+
Get recent transactions for a specific store location.
200+
201+
**Query Parameters:**
202+
- `hours` (optional): Number of hours to look back (default: 24)
203+
204+
**Response:**
205+
```json
206+
{
207+
"storeLocation": "DC-NYC-01",
208+
"hoursBack": 24,
209+
"transactionCount": 15,
210+
"transactions": [
211+
{
212+
"transactionId": "uuid-string",
213+
"status": "COMPLETED",
214+
"totalAmount": 299.99,
215+
"createdAt": "2024-01-01T10:00:00"
216+
}
217+
]
218+
}
219+
```
220+
109221
### GET /api/shop/health
110222
Health check endpoint with transaction statistics.
111223

@@ -128,6 +240,60 @@ Health check endpoint with transaction statistics.
128240
}
129241
```
130242

243+
244+
245+
## Request Flow Through Java Components
246+
247+
### End-to-End Transaction Processing Flow
248+
249+
When a purchase request is submitted to the shop-dc-shim service, it flows through these Java components:
250+
251+
1. **ShopController.processPurchase()** (`/api/shop/purchase`)
252+
- Receives HTTP POST request with purchase details
253+
- Creates OpenTelemetry span for tracing
254+
- Validates request using `@Valid` annotation
255+
- Calls `ShopTransactionService.initiateShopPurchase()`
256+
- Returns HTTP 202 (Accepted) with transaction ID
257+
258+
2. **ShopTransactionService.initiateShopPurchase()**
259+
- Generates unique transaction ID and local order ID
260+
- Creates `ShopTransaction` entity with INITIATED status
261+
- Serializes shipping address and items to JSON
262+
- Saves transaction to SQL Server database
263+
- Calls `processTransactionAsync()` for background processing
264+
- Returns transaction ID to controller
265+
266+
3. **ShopTransactionService.processTransactionAsync()** (Async)
267+
- Runs in background thread pool
268+
- Updates transaction status to VALIDATING
269+
- Calls `performLocalValidation()` for on-premises validation
270+
- Updates status to SUBMITTING_CLOUD
271+
- Calls `CloudCheckoutService.submitToCloudCheckout()`
272+
- Processes cloud response and updates transaction status
273+
- Saves final transaction state to database
274+
275+
4. **ShopTransactionService.performLocalValidation()**
276+
- Simulates on-premises validation logic:
277+
- Local inventory checks
278+
- Customer information validation
279+
- Fraud detection
280+
- Payment limits verification
281+
- Adds processing delay to simulate real validation
282+
283+
5. **CloudCheckoutService.submitToCloudCheckout()**
284+
- Creates gRPC channel to checkout service
285+
- Generates unique user ID for cloud transaction
286+
- Calls `buildGrpcRequest()` to create protobuf request
287+
- Makes blocking gRPC call to checkout service
288+
- Returns `CloudCheckoutResult` with success/failure status
289+
290+
6. **CloudCheckoutService.buildGrpcRequest()**
291+
- Converts shop purchase request to protobuf format
292+
- Builds `Address`, `CreditCardInfo`, and `PlaceOrderRequest` messages
293+
- Returns properly formatted gRPC request
294+
295+
The entire flow is instrumented with OpenTelemetry spans for distributed tracing, and each step updates the transaction status in the SQL Server database for monitoring and reconciliation.
296+
131297
## Transaction Processing Flow
132298

133299
1. **Local Purchase Initiation**: Customer makes purchase at store terminal
@@ -138,55 +304,12 @@ Health check endpoint with transaction statistics.
138304
6. **Confirmation**: Local transaction updated with cloud response
139305
7. **Completion**: Final status stored locally for reconciliation
140306

141-
## Transaction States
142-
143-
- `INITIATED`: Local transaction started
144-
- `VALIDATING`: Performing local validation checks
145-
- `SUBMITTING_CLOUD`: Sending request to cloud checkout
146-
- `CLOUD_PROCESSING`: Cloud is processing the request
147-
- `COMPLETED`: Successfully completed end-to-end
148-
- `FAILED`: Failed at any stage
149-
- `RETRY_PENDING`: Queued for retry
150-
151-
## Database Schema
152-
153-
The service uses PostgreSQL with the following main tables:
154-
155-
```sql
156-
-- Main transaction table
157-
CREATE TABLE shop_transactions (
158-
id BIGSERIAL PRIMARY KEY,
159-
transaction_id VARCHAR(255) UNIQUE NOT NULL,
160-
local_order_id VARCHAR(255) NOT NULL,
161-
cloud_order_id VARCHAR(255),
162-
customer_email VARCHAR(255) NOT NULL,
163-
customer_name VARCHAR(255),
164-
total_amount DECIMAL(10,2),
165-
currency_code CHAR(3),
166-
status VARCHAR(20) NOT NULL DEFAULT 'INITIATED',
167-
store_location VARCHAR(100),
168-
terminal_id VARCHAR(50),
169-
-- ... additional fields for timestamps, addresses, etc.
170-
);
171-
172-
-- Store location lookup
173-
CREATE TABLE store_locations (
174-
id SERIAL PRIMARY KEY,
175-
store_code VARCHAR(10) UNIQUE NOT NULL,
176-
store_name VARCHAR(100) NOT NULL,
177-
address TEXT,
178-
city VARCHAR(50),
179-
state VARCHAR(50),
180-
country VARCHAR(50),
181-
timezone VARCHAR(50) DEFAULT 'America/New_York',
182-
is_active BOOLEAN DEFAULT true
183-
);
184-
```
307+
308+
309+
185310

186311
## Monitoring & Observability
187312

188-
### Dual Instrumentation
189-
The service supports both traditional and modern observability:
190313

191314
**AppDynamics (Traditional APM)**
192315
- Application: `shop-dc-shim-service`
@@ -243,73 +366,9 @@ python shop_load_generator.py --mode burst --concurrent 20 --total 50
243366
python shop_load_generator.py --mode single
244367
```
245368

246-
## Demo Use Case
247-
248-
This service demonstrates a real-world hybrid architecture scenario:
249-
250-
- **On-Premises Reality**: Traditional retail POS systems deployed in datacenters
251-
- **Cloud Integration**: Modern checkout and payment processing in the cloud
252-
- **Monitoring Bridge**: Shows how enterprises monitor hybrid architectures
253-
- **Technology Evolution**: Traditional Java/DB architecture calling modern microservices
254-
255-
### Business Context
256-
- Local shop systems handle inventory, pricing, customer data
257-
- Cloud services provide scalable checkout, payment, and fulfillment
258-
- Dual monitoring shows both traditional APM and modern observability
259-
- Demonstrates enterprise modernization patterns
260369

261-
## Configuration
262370

263-
### Environment Variables
264371

265-
**Service Configuration:**
266-
- `SHOP_DC_SHIM_PORT`: Service port (default: 8070)
267-
- `DB_CONNECTION_STRING`: PostgreSQL connection
268-
- `CHECKOUT_SERVICE_HOST`: Cloud checkout service host
269-
- `CHECKOUT_SERVICE_PORT`: Cloud checkout service port
270-
271-
**AppDynamics Configuration:**
272-
- `APPDYNAMICS_JAVAAGENT_ENABLED`: Enable AppD agent
273-
- `APPDYNAMICS_CONTROLLER_HOST_NAME`: AppD controller
274-
- `APPDYNAMICS_AGENT_APPLICATION_NAME`: App name in AppD
275-
- `APPDYNAMICS_AGENT_TIER_NAME`: Tier name in AppD
276-
277-
**Splunk Observability:**
278-
- `OTEL_EXPORTER_OTLP_ENDPOINT`: OTLP collector endpoint
279-
- `OTEL_RESOURCE_ATTRIBUTES`: Resource attributes
280-
- `SPLUNK_PROFILER_ENABLED`: Enable profiler
281-
282-
### Startup Script
283-
The service uses `start-app-dual.sh` which matches enterprise Ansible deployment patterns:
284-
285-
```bash
286-
# AppDynamics + Splunk dual instrumentation
287-
export AGENT_DEPLOYMENT_MODE=dual
288-
java -javaagent:appdynamics/javaagent.jar \
289-
-javaagent:opentelemetry-javaagent.jar \
290-
-Dagent.deployment.mode=dual \
291-
-Dotel.instrumentation.jdbc.enabled=true \
292-
-Dsplunk.profiler.enabled=true \
293-
-jar app.jar
294-
```
295-
296-
## Local Development
297-
298-
```bash
299-
# Build the service
300-
./gradlew build
301-
302-
# Run with local profile
303-
java -jar build/libs/shop-dc-shim-*.jar
304-
305-
# Run load generator
306-
cd load-generator
307-
pip install -r requirements.txt
308-
python shop_load_generator.py --url http://localhost:8070
309-
310-
# Docker build
311-
docker build -t shop-dc-shim:latest .
312-
```
313372

314373
## Docker Compose Setup
315374

@@ -325,7 +384,23 @@ networks:
325384
- subnet: 172.20.0.0/16
326385

327386
services:
387+
shop-dc-shim-db:
388+
image: mcr.microsoft.com/mssql/server:2022-latest
389+
environment:
390+
- ACCEPT_EULA=Y
391+
- MSSQL_SA_PASSWORD=ShopPass123!
392+
ports:
393+
- "1433:1433"
394+
networks:
395+
- datacenter-network
396+
328397
shop-dc-shim:
398+
depends_on:
399+
- shop-dc-shim-db
400+
environment:
401+
- DB_CONNECTION_STRING=jdbc:sqlserver://shop-dc-shim-db:1433;databaseName=master;encrypt=false;trustServerCertificate=true
402+
- DB_USERNAME=sa
403+
- DB_PASSWORD=ShopPass123!
329404
networks:
330405
- datacenter-network # On-prem network
331406
- default # Cloud service connectivity

src/shop-dc-shim/k8s-addition.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
### Expects a deployment of Astronomy Shop Demo in the same cluster
2+
### Uses checkout service from that demo
13
---
24
apiVersion: v1
35
kind: Service

0 commit comments

Comments
 (0)