← 返回列表
全部 Skill›内容与媒体 Content & Media›quarkus-patterns

quarkus-patterns

作者 @affaan-m · 语言 tur
Quarkus 3.x LTS architecture patterns with Camel for messaging, RESTful API design, CDI services, data access with Panache, and async processing. Use for Java Quarkus backend work with event-driven architectures.
内容与媒体 Content & Media设计通用读写文件待翻译
存储库
最近源活动
2026-11-20 09:13
检测 SKILL.md 语言
tur
星标 ★
307,331
分支 Fork
45,351
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

Quarkus Geliştirme Desenleri

Apache Camel ile bulut-native, event-driven servisler için Quarkus 3.x mimari ve API desenleri.

When to Use

  • JAX-RS veya RESTEasy Reactive ile REST API'leri oluşturma
  • Resource → service → repository katmanlarını yapılandırma
  • Apache Camel ve RabbitMQ ile event-driven desenler uygulama
  • Hibernate Panache, caching veya reaktif akışları yapılandırma
  • Validation, exception mapping veya sayfalama ekleme
  • Dev/staging/production ortamları için profiller kurma (YAML yapılandırma)
  • LogContext ve Logback/Logstash encoder ile özel loglama
  • Async işlemler için CompletableFuture ile çalışma
  • Koşullu akış işleme uygulama
  • GraalVM native derleme ile çalışma

How It Works

Quarkus servislerinde Resource -> service -> repository akışını CDI scope'ları,

@Transactional sınırları, Panache/Hibernate veri erişimi ve Camel/RabbitMQ

entegrasyonlarıyla birlikte uygulayın. Aşağıdaki örnekler event üretimi,

dosya işleme, özel logging context ve async yayınlama için kopyalanabilir

başlangıç noktaları sağlar.

Examples

Birden Fazla Bağımlılıklı Service Katmanı (Lombok)

@Slf4j
@ApplicationScoped
@RequiredArgsConstructor
public class As2ProcessingService {

    private final InvoiceFlowValidator invoiceFlowValidator;
    private final EventService eventService;
    private final DocumentJobService documentJobService;
    private final BusinessRulesPublisher businessRulesPublisher;
    private final FileStorageService fileStorageService;

    public void processFile(Path filePath) throws Exception {
        LogContext logContext = CustomLog.getCurrentContext();
        try (SafeAutoCloseable ignored = CustomLog.startScope(logContext)) {

            String structureIdPartner = logContext.get(As2Constants.STRUCTURE_ID);

            // Koşullu akış mantığı
            boolean isChorusFlow = Boolean.parseBoolean(logContext.get(As2Constants.CHORUS_FLOW));
            log.info("Is CHORUS_FLOW message: {}", isChorusFlow);

            ValidationFlowConfig validationFlowConfig = isChorusFlow
                    ? ValidationFlowConfig.xsdOnly()
                    : ValidationFlowConfig.allValidations();

            InvoiceValidationResult invoiceValidationResult = this.invoiceFlowValidator
                    .validateFlowWithConfig(filePath, validationFlowConfig,
                        EInvoiceSyntaxFormat.UBL, logContext);

            FlowProfile flowProfile = isChorusFlow ?
                    FlowProfile.EXTENDED_CTC_FR :
                    this.invoiceFlowValidator.computeFlowProfile(invoiceValidationResult,
                        invoiceValidationResult.getInvoiceDetails().invoiceFormat().getProfile());

            log.info("Invoice validation completed. Message is valid");

            // CompletableFuture async işlemi
            try(InputStream inputStream = Files.newInputStream(filePath)) {
                CompletableFuture<StoredDocumentInfo> documentInfoCompletableFuture =
                    fileStorageService.uploadOriginalFile(inputStream,
                        invoiceValidationResult.getSize(), logContext,
                        invoiceValidationResult.getInvoiceFormat());

                StoredDocumentInfo documentInfo = documentInfoCompletableFuture.join();
                log.info("File uploaded successfully: {}", documentInfo.getPath());

                if (StringUtils.isBlank(documentInfo.getPath())) {
                    String errorMsg = "File path is empty after upload";
                    log.error(errorMsg);
                    this.eventService.createErrorEvent(documentInfo, "FILE_UPLOAD_FAILED", errorMsg);
                    throw new As2ServerProcessingException(errorMsg);
                }

                this.eventService.createSuccessEvent(documentInfo, "PERSISTENCE_BLOB_EVENT_TYPE");

                String originalFileName = documentInfo.getOriginalFileName();
                BusinessRulesPayload payload = this.documentJobService.createDocumentAndJobEntities(
                    documentInfo, originalFileName, structureIdPartner,
                    flowProfile, invoiceValidationResult.getDocumentHash());

                // Async Camel yayınlama
                businessRulesPublisher.publishAsync(payload);
                this.eventService.createSuccessEvent(payload, "BUSINESS_RULES_MESSAGE_SENT");
            }
        }
    }
}

Temel Desenler:

  • Constructor injection için Lombok üzerinden @RequiredArgsConstructor
  • Logback loglama için @Slf4j
  • try-with-resources ile kapsamlı LogContext
  • Runtime parametrelerine dayalı koşullu akış mantığı
  • Async işlemler için .join() ile CompletableFuture
  • Başarı/hata senaryoları için event takibi
  • Async Camel mesaj yayınlama

Özel Loglama Bağlamı Deseni (Logback)

@ApplicationScoped
public class ProcessingService {

    public void processDocument(Document doc) {
        LogContext logContext = CustomLog.getCurrentContext();
        try (SafeAutoCloseable ignored = CustomLog.startScope(logContext)) {
            // Tüm log ifadelerine bağlam ekle
            logContext.put("documentId", doc.getId().toString());
            logContext.put("documentType", doc.getType());
            logContext.put("userId", SecurityContext.getUserId());

            log.info("Starting document processing");

            // Bu kapsam içindeki tüm loglar bağlamı devralır
            processInternal(doc);

            log.info("Document processing completed");
        } catch (Exception e) {
            log.error("Document processing failed", e);
            throw e;
        }
    }
}

Logback Yapılandırması (logback.xml):

<configuration>
    <appender name="CONSOLE" class="ch.qos.lo
评论
Aaffaan-m
affaan-m
affaan-m/ECC
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@affaan-m
所属大类内容与媒体 Content & Media / 设计
国内可用性通用
最近源活动2026-11-20 09:13
风险提示读写文件
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。