Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Web Security TippsIntroducing the new Confluence integration with Google Chat(22.09.2026 um 19:40 Uhr)
Web Security TippsQuick notes in Take notes for me(22.09.2026 um 21:31 Uhr)
Sichere ProgrammierungSecurity improvements for SSH(22.09.2026 um 16:11 Uhr)
Sichere ProgrammierungKI-Akzeptanz: Wie Rewe digital einfach nur den Chatbot umbenannte(22.09.2026 um 18:00 Uhr)
Sichere ProgrammierungClaude Opus 5.5: Keeping safety ahead of capabilities(22.09.2026 um 20:59 Uhr)
Sichere ProgrammierungYour Terraform Monolith Isn't Too Big. It's Tightly Coupled.(22.09.2026 um 21:00 Uhr)
Sichere ProgrammierungMy PR got merged into Mike — OSS Legal AI Platform 🎉(22.09.2026 um 21:34 Uhr)
Sichere ProgrammierungStop Writing JavaScript To Fix `100vh` On Mobile(22.09.2026 um 21:35 Uhr)
Sichere ProgrammierungNext.js proxy.ts Explained (with Cheat Sheet)(22.09.2026 um 21:36 Uhr)
Web Security TippsIntroducing the new Confluence integration with Google Chat(22.09.2026 um 19:40 Uhr)
Web Security TippsQuick notes in Take notes for me(22.09.2026 um 21:31 Uhr)
Sichere ProgrammierungSecurity improvements for SSH(22.09.2026 um 16:11 Uhr)
Sichere ProgrammierungKI-Akzeptanz: Wie Rewe digital einfach nur den Chatbot umbenannte(22.09.2026 um 18:00 Uhr)
Sichere ProgrammierungClaude Opus 5.5: Keeping safety ahead of capabilities(22.09.2026 um 20:59 Uhr)
Sichere ProgrammierungYour Terraform Monolith Isn't Too Big. It's Tightly Coupled.(22.09.2026 um 21:00 Uhr)
Sichere ProgrammierungMy PR got merged into Mike — OSS Legal AI Platform 🎉(22.09.2026 um 21:34 Uhr)
Sichere ProgrammierungStop Writing JavaScript To Fix `100vh` On Mobile(22.09.2026 um 21:35 Uhr)
Sichere ProgrammierungNext.js proxy.ts Explained (with Cheat Sheet)(22.09.2026 um 21:36 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

LangChain4J-CDI best practices

LangChain4J-CDI is the pivotal component that enables developers to integrate their AI services into their enterprise Java applications with ease, thanks to CDI. Whether you're a seasoned developer or getting started with integrating AI…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

LangChain4J-CDI is the pivotal component that enables developers to integrate their AI services into their enterprise Java applications with ease, thanks to CDI.



Whether you're a seasoned developer or getting started with integrating AI in your existing Java application, here are the best practices that will ensure you get building your AI solutions with ease.






1. Applying CDI scopes to your AI service or AI agent



Whether you're creating an AI Service or an AI agent, you would feel compelled to apply the CDI scopes in this manner:




@RegisterAIService
@ApplicationScoped //<-- Do not do this. It doesn't work, and there's no side effect.
public interface ChatAiService {

String chat(String message);
};






This won't work as the interface is not CDI managed. For those who want to be too technical, the CD scopes cannot propagate down to its proxy.



Instead, each of the LangChain4J-CDI stereotype annotations contains a scope() parameter where you can assign your CDI scope.



Example:




@RegisterAIService(scope = ApplicationScoped.class) //Better approach, it works.
public interface ChatAiService {

String chat(String message);
};






This applies to all of these annotations:




//For AI Service
@RegisterAIService,

//For AI Agent
@RegisterSimpleAgent,
@RegisterSequenceAgent,
@RegisterLoopAgent,
@RegisterParallelAgent,
@RegisterParallelMapperAgent,
@RegisterConditionalAgent,
@RegisterSupervisorAgent,
@RegisterPlannerAgent,
@RegisterA2AAgent,
@RegisterMcpClientAgent,
@RegisterHumanInTheLoopAgent






## 2. Using MicroProfile Fault Tolerance Retry



If you want to apply a retry policy to your AI service or AI agent using MicroProfile @Retry annotation, you first have to disable LangChain4J's internal retry policy (which is set to 3 retries by default).



There are various ways to do this. Using MicroProfile config, set the maxRetries = 0.



For example:




dev.langchain4j.cdi.plugin.<bean-model-name>.config.max-retries=0






Or, if you're using LangChain4J's provider's ChatModelBuilder, then you can simply apply the same value by setting builder.maxRetries(0);.



Without disabling LangChain4J's internal retry policy, your application server will invoke the retry with the total complexity of O(n*m), where n is the max retries by MicroProfile and m is the max retries by LangChain4J.



Please note that not all LangChain4J AI providers provide a maxRetries on their ChatModel. If you're declaratively configuring maxRetries using MicroProfile Config on a bean without such property, the config property will be ignored.






3. Finally



These are the few caveats that we identified and thought were worth sharing so that you don't have to suffer in your AI discovery.

Happy coding! ☕👩🏾‍💻

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten LangChain4J-CDI best practices

Thematisch verwandte Begriffe: LangChain4JCDI, best, practices · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-77259 | MCP Atlassian is a Model Context Protocol (MCP) server for Atlassian pro…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick