[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ACNN8QPGPM8T00KW2FQABS":3,"skill-same:01M6ACNN8QPGPM8T00KW2FQABS":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":17,"categories":18,"keywords":29,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":33,"frontMatter":34,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":40,"ownerHtmlUrl":41,"ownerBlogUrl":42,"ownerDescription":7,"updatedAt":43,"install":44,"resources":57},"01M6ACNN8QPGPM8T00KW2FQABS","manage-eca","ECA 管理",null,"","apache\u002Fofbiz-plugins","apache","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F47359?v=4","01M6AC83E6K4FDKK7HZ8WNMQKE","The Apache Software Foundation","01M6ACMJJ1Q4WYATY4GXZ2FAVD",178,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-eca\u002FSKILL.md",[19,24],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8C36CP2J9CRK1B6PYRXVHPN","应用配置管理","SCENARIO","使用场景",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8C6RQ852C9AEJFCBGG1YA7S","IT 管理员","PROFESSION","适用职业",[30],"manage eca","2026-11-10 10:12:30",false,"\u003C!--\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied.  See the License for the\nspecific language governing permissions and limitations\nunder the License.\n-->\n\n---\nname: manage-eca\ndescription: Manage Service Event Condition Actions (SECA) and Entity Event Condition Actions (EECA) to implement event-driven logic in OFBiz.\n---\n\n# Skill: Manage Service and Entity ECAs (SECA \u002F EECA) in Apache OFBiz\n\n## Goal\nTo implement event-driven logic in OFBiz by triggering services automatically when another service reaches a lifecycle event (SECA) or a database entity is modified (EECA).\n\nECAs are powerful — but misused ECAs are one of the fastest ways to destabilize a production OFBiz system.\n\n> **Core Principle**: If removing the ECA breaks the main business flow, it should **NOT** be an ECA.\n\n## Triggers\n- Implementing cross-cutting concerns (e.g., clearing caches, indexing).\n- Triggering side effects (e.g., sending emails after order completion).\n- Enforcing business rules that depend on data changes.\n- Syncing data between different systems or components.\n\n## Rules & Procedures\n\n### Decision Tree: SECA vs EECA vs Explicit Chaining\n\n**Step 1: Is this logic part of the main business flow?**\nExamples: \"Order approval must reserve inventory\", \"Shipment creation must validate allocation\", \"Invoice must be generated or order is invalid\".\n- **YES** → **Explicit chaining \u002F orchestrator service**\n  - (Call the next service directly, or create a wrapper service like `processOrderApproval` that orchestrates steps using **Groovy** (**Cross-Reference**: `manage-groovy`) or **Service Groups** (**Cross-Reference**: `manage-service-groups`).)\n- **NO** → Go to Step 2\n*Rule: If removing it breaks the flow, it’s not an ECA.*\n\n**Step 2: What is the trigger source you truly want?**\nAsk: \"What event should cause this to happen?\"\n- **2A) Trigger is a service lifecycle event**\n  - Example: \"After `storeOrder` completes, send an email\", \"After `createShipment` commits, push to ERP\".\n  - **Choose SECA**\n  - Then go to Step 3 (event + mode)\n- **2B) Trigger is a database row change**\n  - Example: \"Whenever Product changes, reindex\", \"When OrderHeader.statusId becomes COMPLETED, notify\".\n  - **Choose EECA** (only on physical entities)\n  - Then go to Step 3 (event + mode)\n- *If neither is clear → prefer explicit chaining (more traceable).*\n\n**Step 3: Does the triggered work need committed DB state?**\nAsk: \"Will the triggered service read data written by the triggering work?\"\n- **YES** → Use post-commit trigger\n  - **SECA**: `event=\"commit\"`\n  - **EECA**: prefer `event=\"return\"` but ensure the consuming logic doesn’t require uncommitted visibility; if it must read committed state reliably, prefer SECA on commit of the creating\u002Fupdating service (or pass required data directly).\n- **NO** → `return` is usually fine\n  - (SECA: `event=\"return\"`, EECA: `event=\"return\"`)\n*Key: async is concurrent; commit matters when reads must see written data.*\n\n**Step 4: Is the action heavy \u002F slow \u002F failure-tolerant?**\nExamples: external API call, email, indexing, analytics.\n- **YES** → `mode=\"async\"`\n  - Use `persist=\"true\"` only when job volume is controlled and reliability is required.\n  - *(See the [manage-async](..\u002Fmanage-async\u002FSKILL.md) skill before choosing `mode=\"async\"`!)*\n- **NO** → `mode=\"sync\"` (keep it lightweight and deterministic)\n\n### Quick Rules of Thumb\n\n**Use Explicit Chaining when:**\n- It’s core workflow logic\n- Ordering matters strongly across multiple steps\n- You need clear traceability and testing\n- You want retries\u002Fcompensation explicitly\n\n**Use SECA when:**\n- Trigger is \"after service X\"\n- You want to extend behavior without changing service code\n- You can pick `return` vs `commit` intentionally\n\n**Use EECA when:**\n- Trigger is \"when entity row changes\"\n- You need cross-cutting reaction to DB writes from multiple entry points\n- You can write precise conditions\n- You are not targeting view entities and not using `find`\n\n### Implementation Procedures\n\n#### 1. Service ECAs (SECAs)\nSECAs trigger a service when another service reaches a specific life-cycle event.\n\n- **Location**: Typically defined in `secas.xml` files within a component's `servicedef` directory.\n- **Registration**: Register the SECA file in `ofbiz-component.xml`:\n  ```xml\n  \u003Cservice-resource type=\"eca\" loader=\"main\" location=\"servicedef\u002Fsecas.xml\"\u002F>\n  ```\n\n#### SECA Pattern\n```xml\n\u003Ceca service=\"serviceName\" event=\"event-name\">\n    \u003C!-- Optional Conditions -->\n    \u003Ccondition field-name=\"statusId\" operator=\"equals\" value=\"ORDER_COMPLETED\"\u002F>\n    \u003C!-- Actions -->\n    \u003Caction service=\"triggerService\" mode=\"sync|async\" persist=\"true|false\"\u002F>\n\u003C\u002Feca>\n```\n\n#### Event Selection Rules\n- **return**: Business logic completed, transaction not yet committed (most common).\n- **commit**: Use ONLY when the triggered service must see committed data.\n- **invoke**: Avoid \"invoke\" unless modifying input context is required.\n- `auth`: Before authentication.\n- `in-validate`: Before input validation.\n- `out-validate`: Before output validation.\n\n---\n\n#### 2. Entity ECAs (EECAs)\nEECAs trigger a service when a database operation occurs on a specific entity.\n\n- **Location**: Typically defined in `eecas.xml` files within a component's `entitydef` directory.\n- **Registration**: Register the EECA file in `ofbiz-component.xml`:\n  ```xml\n  \u003Centity-resource type=\"eca\" loader=\"main\" location=\"entitydef\u002Feecas.xml\"\u002F>\n  ```\n\n#### EECA Pattern\n```xml\n\u003Ceca entity=\"EntityName\" operation=\"create|store|remove|find\" event=\"validate|run|return|status-change\">\n    \u003Ccondition field-name=\"fieldName\" operator=\"not-equals\" value=\"N\"\u002F>\n    \u003Caction service=\"triggerService\" mode=\"sync\" value-attr=\"currentValue\"\u002F>\n\u003C\u002Feca>\n```\n\n#### Critical Constraints\n- NEVER attach EECA to view entities.\n- Avoid `operation=\"find\"` (high performance risk).\n- ✔ Prefer `store` + condition over `status-change` when possible.\n\n#### Event Rules\n- **run**: Before DB operation (rare).\n- **return**: After DB operation (most common).\n- **status-change**: Use ONLY for explicit status-driven logic.\n\n**Common Operations**: `create`, `store` (update), `remove`.\n\n---\n\n## Guardrails\n- **Avoid Recursion**: Be extremely careful not to trigger a SECA\u002FEECA that eventually calls the original service\u002Fentity operation, leading to an infinite loop (see Examples).\n- **Transactional Impact**: Synchronous (`mode=\"sync\"`) actions run in the same transaction. If the action fails, the main operation fails.\n- **Condition Precision**: Always use conditions to ensure the action only triggers when strictly necessary.\n- **Async Execution Warning**: Before configuring `mode=\"async\"`, you **MUST** review the explicit rules in the `manage-async` skill to prevent JobSandbox explosions and system instability.\n\n## Examples: Good Patterns vs Anti-Patterns\n\n### 1. Order Completion SECA (Good Pattern for Live Traffic)\nTriggering an email and resetting totals after an order is stored.\n```xml\n\u003Ceca service=\"storeOrder\" event=\"return\">\n    \u003Ccondition field-name=\"orderTypeId\" operator=\"equals\" value=\"SALES_ORDER\"\u002F>\n    \u003Caction service=\"resetOrderGrandTotal\" mode=\"sync\"\u002F>\n    \u003Caction service=\"sendOrderConfirmationEmail\" mode=\"async\" persist=\"true\"\u002F>\n\u003C\u002Feca>\n```\n**Why this is good (for live traffic)**: It decouples the heavy network call (email) from the transaction, avoiding blocking the user during checkout.\n\n**ANTI-PATTERN: Leaving this enabled for bulk historical imports.**\nThis async + persist strategy is **WRONG** if:\n- You are **bulk-importing historical orders** (JobSandbox explosion).\n- The email must be sent **before** order completion is considered successful.\n- The service modifies `OrderHeader` again (leading to transaction timing collisions).\n- You are firing this for **every minor order update** (missing `\u003Ccondition>` guard).\n\n### 2. Infinite Loop Recursion (EECA ANTI-PATTERN)\n**NEVER** trigger an action that updates the exact same entity that triggered it, unless guarded by iron-clad status conditions.\n```xml\n\u003Ceca entity=\"OrderHeader\" operation=\"store\" event=\"return\">\n    \u003Caction service=\"recomputeOrderHeader\" mode=\"sync\"\u002F>\n\u003C\u002Feca>\n```\n**Why this is dangerous**: When `recomputeOrderHeader` executes, it internally stores `\u003COrderHeader>`. Because the operation is `store`, the EECA immediately fires a *second* time. This creates an infinite loop that instantly crashes the transaction thread.\n\n### 3. View Entity trigger (EECA ANTI-PATTERN)\n**NEVER** attach an EECA to a View Entity.\n```xml\n\u003C!-- WRONG: OrderHeaderAndItems is a View Entity -->\n\u003Ceca entity=\"OrderHeaderAndItems\" operation=\"store\" event=\"return\">\n    \u003Caction service=\"triggerCustomLogic\" mode=\"sync\"\u002F>\n\u003C\u002Feca>\n```\n**Why this is wrong**: View Entities are virtual joins. The OFBiz Entity Engine does not fire database events (`create`, `store`, `remove`) on views—it fires them on the underlying physical tables. An EECA on a View Entity will either never trigger, or will trigger inconsistently and cause deep system confusion.\n\n### 4. Find Operation (EECA ANTI-PATTERN)\n**NEVER** attach an EECA to a `find` operation unless absolutely unavoidable and closely monitored.\n```xml\n\u003C!-- WRONG: High performance risk -->\n\u003Ceca entity=\"Product\" operation=\"find\" event=\"return\">\n    \u003Caction service=\"triggerExpensiveCheck\" mode=\"sync\"\u002F>\n\u003C\u002Feca>\n```\n**Why this is dangerous**: Find operations are executed continuously by the system (UI lookups, internal service logic, batch processing). Intercepting every `find` operation on a core entity like `Product` adds massive latency to the system and will destroy database throughput.\n\n### 5. Product Keyword Indexing EECA\nAutomatically indexing keywords whenever a Product is created or updated.\n```xml\n\u003Ceca entity=\"Product\" operation=\"create\" event=\"return\">\n    \u003Caction service=\"indexProductKeywords\" mode=\"sync\" value-attr=\"productInstance\"\u002F>\n\u003C\u002Feca>\n\u003Ceca entity=\"Product\" operation=\"store\" event=\"return\">\n    \u003Caction service=\"indexProductKeywords\" mode=\"sync\" value-attr=\"productInstance\"\u002F>\n\u003C\u002Feca>\n```\n",{},"trunk","6c6c27710443de03e9247605d33a2e2f5bc3d1e2","ai-agent-skills\u002Fmanage-eca",222,"https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins","https:\u002F\u002Fofbiz.apache.org\u002F","https:\u002F\u002Fgithub.com\u002Fapache","https:\u002F\u002Fwww.apache.org\u002F","2026-11-12 22:04:06",{"source":9,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add apache\u002Fofbiz-plugins --skill manage-eca",{"tool":50,"command":51},"bunx","bunx skills add apache\u002Fofbiz-plugins --skill manage-eca",{"tool":53,"command":54},"pnpm","pnpm dlx skills add apache\u002Fofbiz-plugins --skill manage-eca","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-eca\u002FSKILL.md",true,[58,64],{"path":59,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":62,"sourceHtmlUrl":63},"config.json","REFERENCE","参考文档",391,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdevelopment\u002Fcc-skill-continuous-learning\u002Fconfig.json",{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"evaluate-session.sh","SCRIPT","脚本",2015,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdevelopment\u002Fcc-skill-continuous-learning\u002Fevaluate-session.sh",[71,85,97,111,125,139],{"skillNo":72,"name":73,"nameZh":74,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":75,"categories":76,"keywords":83,"publishedAt":31},"01M6ACQSN90YKJZ92MQ52D9R8H","prepush-readiness","推送前就绪检查","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fprepush-readiness\u002FSKILL.md",[77,80],{"categoryNo":78,"categoryName":79,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师",{"categoryNo":81,"categoryName":82,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BR5V701HCN066VEP7H4812","代码仓库协作管理",[84],"prepush readiness",{"skillNo":86,"name":87,"nameZh":88,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":89,"categories":90,"keywords":95,"publishedAt":31},"01M6ACQPR1WRA751V4DXVC3AHF","manage-webapps","Web 应用管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-webapps\u002FSKILL.md",[91,92],{"categoryNo":78,"categoryName":79,"taxonomyType":27,"taxonomyTypeDesc":28},{"categoryNo":93,"categoryName":94,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BWKS60NTYJHFE9FQSXGDKS","低代码应用开发",[96],"manage webapps",{"skillNo":98,"name":99,"nameZh":100,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":101,"categories":102,"keywords":109,"publishedAt":31},"01M6ACQMCX8Z7NY2CE08NCV6ND","manage-themes","主题管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-themes\u002FSKILL.md",[103,106],{"categoryNo":104,"categoryName":105,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQ6TQMKHSMFVQHR2KYAEVN","界面设计师",{"categoryNo":107,"categoryName":108,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BRASNPVNJVQQJ4KZX8XM5D","前端开发与界面实现",[110],"manage themes",{"skillNo":112,"name":113,"nameZh":114,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":115,"categories":116,"keywords":123,"publishedAt":31},"01M6ACQHYN20AFWF6TKK4RGQ8A","manage-tests","测试管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-tests\u002FSKILL.md",[117,120],{"categoryNo":118,"categoryName":119,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":121,"categoryName":122,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[124],"manage tests",{"skillNo":126,"name":127,"nameZh":128,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":129,"categories":130,"keywords":137,"publishedAt":31},"01M6ACQFRMW7R45YD3HRAXPGWF","manage-templates","模板管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-templates\u002FSKILL.md",[131,134],{"categoryNo":132,"categoryName":133,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TK1MPB82068236GSXDE","文档处理",{"categoryNo":135,"categoryName":136,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQ6TPH3VQWKQZXV7EPF8VZ","办公行政人员",[138],"manage templates",{"skillNo":140,"name":141,"nameZh":142,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":7,"sourceHtmlUrl":143,"categories":144,"keywords":149,"publishedAt":31},"01M6ACQCSSDZQMD8VX2K3WRR93","manage-strategies","策略管理","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-strategies\u002FSKILL.md",[145,148],{"categoryNo":146,"categoryName":147,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BTXF8K9DFQC4T4TXVH0NMZ","策略与托管设置管理",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},[150],"manage strategies"]