AgentSkillsCN

integration-patterns

在基于霍普与伍尔夫的企业集成模式下,设计或评估企业集成架构时使用此功能。 适用场景:企业集成模式、消息传递架构、集成模式选择、管道与过滤器、面向消息的中间件。 不适用场景:在代码中实现具体模式(使用子技能)、API设计(使用Dev/Backend/API设计)、事件溯源(使用Dev/Architecture/Event-Driven)。

SKILL.md
--- frontmatter
name: integration-patterns
description: |
    Use when designing or evaluating enterprise integration architectures based on Hohpe & Woolf's Enterprise Integration Patterns.
    USE FOR: Enterprise Integration Patterns, messaging architecture, choosing integration patterns, pipes and filters, message-oriented middleware
    DO NOT USE FOR: specific pattern implementations in code (use sub-skills), API design (use dev/backend/api-design), event sourcing (use dev/architecture/event-driven)
license: MIT
metadata:
  displayName: "Integration Patterns"
  author: "Tyler-R-Kendrick"
compatibility: claude, copilot, cursor

Enterprise Integration Patterns

Overview

Enterprise Integration Patterns (EIP), catalogued by Gregor Hohpe and Bobby Woolf, define a vocabulary of 65 patterns for designing robust, asynchronous messaging systems. The patterns describe how to connect applications, transform data in flight, route messages intelligently, and manage messaging infrastructure -- all while keeping systems loosely coupled and independently deployable.

The book organises patterns around the pipes-and-filters architectural style: messages flow through a series of processing steps (filters) connected by channels (pipes).

Pattern Categories

code
┌─────────────────────────────────────────────────────────────────┐
│                   Enterprise Integration Patterns               │
├───────────────┬───────────────┬───────────────┬─────────────────┤
│  Messaging    │  Message      │  Message      │  Message        │
│  Channels     │  Construction │  Routing      │  Transformation │
│               │               │               │                 │
│  How messages │  How messages │  How messages  │  How messages   │
│  travel       │  are built    │  are directed │  are reshaped   │
├───────────────┴───────────────┴───────────────┴─────────────────┤
│  Messaging Endpoints          │  System Management              │
│                               │                                 │
│  How applications connect     │  How to monitor, test, and      │
│  to the messaging system      │  control the messaging system   │
└───────────────────────────────┴─────────────────────────────────┘

Pipes-and-Filters Architecture

code
┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐
│  Source   │───>│ Filter A │───>│ Filter B │───>│  Sink    │
│ (Producer)│    │(Transform│    │ (Route)  │    │(Consumer)│
└──────────┘    └──────────┘    └──────────┘    └──────────┘
      pipe           pipe           pipe
    (channel)      (channel)      (channel)

Each filter performs a single processing step (validate, enrich, transform, route). Each pipe is a message channel connecting one filter to the next. This architecture provides:

  • Composability -- combine simple filters into complex workflows.
  • Replaceability -- swap a filter without touching others.
  • Scalability -- scale individual filters independently.
  • Testability -- test each filter in isolation.

When to Use Messaging vs. Direct Calls

ConcernDirect / Synchronous CallsMessaging / Asynchronous
CouplingCaller must know callee's address and APISender only knows the channel
AvailabilityCallee must be runningCallee can be offline; messages queue
LatencyImmediate response requiredEventual response acceptable
ThroughputLimited by slowest participantBuffer with queues; scale consumers
Error handlingCaller handles errors in real timeDead-letter channels, retries, compensation
ComplexitySimple for 1:1 interactionsWorth it when >2 participants or reliability matters

Rule of thumb: Start synchronous. Move to messaging when you need temporal decoupling, load levelling, reliable delivery, or fan-out to multiple consumers.

Pattern Selection Guide

ProblemPattern CategoryKey Patterns
How do I send a message from A to B?Messaging ChannelsPoint-to-Point Channel, Channel Adapter
How do I notify many subscribers?Messaging ChannelsPublish-Subscribe Channel
What goes inside a message?Message ConstructionCommand Message, Event Message, Document Message
How do I correlate request and reply?Message ConstructionCorrelation Identifier, Return Address
How do I route to the right consumer?Message RoutingContent-Based Router, Recipient List
How do I split and reassemble?Message RoutingSplitter, Aggregator
How do I orchestrate a multi-step flow?Message RoutingProcess Manager, Routing Slip
How do I reshape data between systems?Message TransformationContent Enricher, Normalizer, Canonical Data Model
How do I reduce message size?Message TransformationClaim Check, Content Filter
How do I consume messages reliably?Messaging EndpointsCompeting Consumers, Idempotent Receiver
How do I monitor and debug?System ManagementWire Tap, Message Store, Control Bus

Reference Implementations

TechnologyLanguage / PlatformStrengths
Apache CamelJava / JVMBroadest connector ecosystem; DSL routes map 1:1 to EIP
Spring IntegrationJava / SpringDeep Spring ecosystem integration; annotation-driven
MassTransitC# / .NETFirst-class saga support; RabbitMQ & Azure Service Bus transports
NServiceBusC# / .NETCommercial-grade; strong tooling and monitoring
MediatRC# / .NETIn-process mediator; great for CQRS without infrastructure
Azure Service BusCloud (Azure)Managed broker; topics, subscriptions, sessions
RabbitMQAny (AMQP)Lightweight broker; exchanges map to routing patterns
Apache KafkaAnyLog-based streaming; high throughput; replay capability

Best Practices

  • Learn the pattern language before choosing a framework -- the vocabulary transcends any single implementation.
  • Prefer idempotent message handlers; at-least-once delivery is the norm.
  • Design messages as immutable, self-describing contracts with schema versioning.
  • Keep channels focused on a single data type or purpose (Datatype Channel).
  • Use Dead Letter Channels for every queue -- never silently drop messages.
  • Instrument messaging with Wire Taps and Message Stores from day one; debugging async flows without observability is painful.
  • Start with the simplest topology (point-to-point) and evolve toward pub-sub or content-based routing only when the need is proven.