Files
2nd/10_Wiki/Topic_Programming/Architecture/Simple event processing.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

4.8 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-simple-event-processing Simple Event Processing 10_Wiki/Topics verified self
SEP
Direct Event Handling
1:1 Event Processing
none A 0.9 applied
event-driven
architecture
eda
messaging
2026-05-10 pending
language framework
typescript kafka

Simple Event Processing

매 한 줄

"매 1 event → 1 reaction. No correlation, no aggregation, no temporal pattern.". 매 EDA 의 simplest tier — notable event 의 detect 후 매 single downstream action 의 trigger. 매 CEP (Complex Event Processing) / ESP (Event Stream Processing) 와 대비되는 매 baseline pattern.

매 핵심

매 SEP vs ESP vs CEP

  • SEP: 1 event → 1 action. No state, no correlation.
  • ESP: stream 의 windowing, aggregation (Flink, Kafka Streams).
  • CEP: pattern matching across events (Drools Fusion, Esper).

매 properties

  • Stateless (매 event 의 self-contained).
  • Low latency (no buffering / windowing).
  • High throughput (parallelize trivially).
  • Idempotent handlers preferred (at-least-once delivery).

매 응용

  1. Order placed → email confirmation.
  2. User signup → welcome workflow.
  3. Sensor reading → threshold alert.
  4. Payment captured → inventory reserve.
  5. Log line → metric increment.

💻 패턴

Kafka consumer (TypeScript)

import { Kafka } from 'kafkajs';

const kafka = new Kafka({ brokers: ['localhost:9092'] });
const consumer = kafka.consumer({ groupId: 'order-emails' });

await consumer.subscribe({ topic: 'orders.placed' });
await consumer.run({
  eachMessage: async ({ message }) => {
    const order = JSON.parse(message.value!.toString());
    await sendOrderEmail(order.userId, order.id);
  },
});

AWS EventBridge rule

import { EventBridgeClient, PutRuleCommand } from '@aws-sdk/client-eventbridge';

await client.send(new PutRuleCommand({
  Name: 'order-placed-email',
  EventPattern: JSON.stringify({
    source: ['app.orders'],
    'detail-type': ['OrderPlaced'],
  }),
  Targets: [{ Arn: lambdaArn, Id: 'send-email' }],
}));

NATS subject handler

import { connect, StringCodec } from 'nats';

const nc = await connect({ servers: 'nats://localhost:4222' });
const sc = StringCodec();
const sub = nc.subscribe('orders.placed');

for await (const msg of sub) {
  const order = JSON.parse(sc.decode(msg.data));
  await reserveInventory(order);
}

Idempotent handler

async function handleOrderPlaced(event: OrderEvent) {
  const seen = await redis.set(`processed:${event.id}`, '1', 'NX', 'EX', 86400);
  if (!seen) return;  // already handled
  await sendEmail(event);
}

Dead-letter handling

await consumer.run({
  eachMessage: async ({ message }) => {
    try {
      await handle(message);
    } catch (err) {
      await producer.send({
        topic: 'orders.placed.dlq',
        messages: [{ value: message.value, headers: { error: err.message } }],
      });
    }
  },
});

CloudEvents envelope

const cloudEvent = {
  specversion: '1.0',
  type: 'com.example.order.placed',
  source: '/orders',
  id: crypto.randomUUID(),
  time: new Date().toISOString(),
  data: { orderId, userId, amount },
};
await producer.send({ topic: 'orders.placed', messages: [{ value: JSON.stringify(cloudEvent) }] });

Webhook fan-out

app.post('/webhooks/payment', async (req, res) => {
  await eventBus.publish('payment.captured', req.body);
  res.status(202).end();
});

매 결정 기준

상황 Approach
1:1 event → action, stateless SEP
Stream aggregation (window sums) ESP (Flink)
Pattern detect (A then B within 5s) CEP (Esper)
Cross-system fan-out SEP via EventBridge/Kafka

기본값: Kafka or EventBridge + idempotent stateless handlers.

🔗 Graph

🤖 LLM 활용

언제: stateless 1:1 event handling — webhook, notification, simple workflow trigger. 언제 X: pattern correlation 필요 — CEP / ESP 사용.

안티패턴

  • Stateful SEP: 매 cross-event state 가지면 ESP 로 reframe.
  • No idempotency: at-least-once delivery 에서 매 duplicate side-effect.
  • Synchronous webhook chain: 매 cascading failure — async queue 사이로.

🧪 검증 / 중복

  • Verified (Hohpe Enterprise Integration Patterns, Confluent docs, AWS EventBridge guide).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — SEP vs ESP vs CEP, Kafka/EventBridge/NATS patterns