بنقرة واحدة
java-microservices
Build microservices - Spring Cloud, service mesh, event-driven, resilience patterns
القائمة
Build microservices - Spring Cloud, service mesh, event-driven, resilience patterns
Master Java concurrency - threads, executors, locks, CompletableFuture, virtual threads
Containerize Java applications - Dockerfile optimization, JVM settings, security
Master core Java programming - syntax, OOP, collections, streams, and exception handling
Master Gradle - Kotlin DSL, task configuration, build optimization, caching
Master JPA/Hibernate - entity design, queries, transactions, performance optimization
Master Maven and Gradle - build configuration, dependencies, plugins, CI/CD
| name | java-microservices |
| description | Build microservices - Spring Cloud, service mesh, event-driven, resilience patterns |
| sasmp_version | 1.3.0 |
| version | 3.0.0 |
| bonded_agent | 07-java-microservices |
| bond_type | PRIMARY_BOND |
| allowed-tools | Read, Write, Bash, Glob, Grep |
| parameters | {"pattern":{"type":"string","enum":["saga","cqrs","event_sourcing","api_gateway"],"description":"Architecture pattern"},"messaging":{"type":"string","enum":["kafka","rabbitmq","redis"],"description":"Messaging platform"}} |
Build production microservices with Spring Cloud and distributed system patterns.
This skill covers microservices architecture with Spring Cloud including service discovery, API gateway, circuit breakers, event-driven communication, and distributed tracing.
Use when you need to:
// Saga with Choreography
@Component
public class OrderSagaListener {
@KafkaListener(topics = "order.created")
public void handleOrderCreated(OrderCreatedEvent event) {
inventoryService.reserve(event.getItems());
}
@KafkaListener(topics = "payment.failed")
public void handlePaymentFailed(PaymentFailedEvent event) {
// Compensating transaction
inventoryService.release(event.getOrderId());
orderService.cancel(event.getOrderId());
}
}
// Circuit Breaker Configuration
@Configuration
public class ResilienceConfig {
@Bean
public Customizer<Resilience4JCircuitBreakerFactory> cbCustomizer() {
return factory -> factory.configureDefault(id ->
new Resilience4JConfigBuilder(id)
.circuitBreakerConfig(CircuitBreakerConfig.custom()
.failureRateThreshold(50)
.waitDurationInOpenState(Duration.ofSeconds(30))
.slidingWindowSize(10)
.build())
.build());
}
}
// API Gateway Routes
@Configuration
public class GatewayConfig {
@Bean
public RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("orders", r -> r
.path("/api/orders/**")
.filters(f -> f
.stripPrefix(1)
.circuitBreaker(c -> c.setName("order-cb"))
.retry(retry -> retry.setRetries(3)))
.uri("lb://order-service"))
.build();
}
}
management:
tracing:
sampling:
probability: 1.0
endpoints:
web:
exposure:
include: health,info,metrics,prometheus
logging:
pattern:
level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
Order → Inventory → Payment → (Success | Compensate)
CLOSED → (failures exceed threshold) → OPEN
OPEN → (wait duration) → HALF_OPEN
HALF_OPEN → (success) → CLOSED
HALF_OPEN → (failure) → OPEN
| Problem | Cause | Solution |
|---|---|---|
| Cascade failure | No circuit breaker | Add Resilience4j |
| Message lost | No ack | Enable manual ack |
| Inconsistent data | No compensation | Implement saga |
| Service not found | Discovery delay | Tune heartbeat |
□ Trace request (traceId)
□ Check circuit breaker state
□ Verify Kafka consumer lag
□ Review gateway routes
□ Monitor retry counts
Skill("java-microservices")
java-spring-boot - Spring Cloudjava-docker - Containerization