<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GoCamel Documentation :: GoCamel</title><link>https://gocamel.tranchida.cloud/en/index.html</link><description>Enterprise Integration Framework for Go
Welcome to the GoCamel documentation.
Quick Links Installation Quick Start Core Concepts Components Features API Reference Security Notice GoCamel includes built-in security utilities (security.go) to protect against common vulnerabilities:
Path traversal protection SQL injection prevention Input sanitization Safe file operations 🌐 🇫🇷 Version Française</description><generator>Hugo</generator><language>en</language><atom:link href="https://gocamel.tranchida.cloud/en/index.xml" rel="self" type="application/rss+xml"/><item><title>Features</title><link>https://gocamel.tranchida.cloud/en/features/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/features/index.html</guid><description>Core Capabilities Enterprise Integration Framework GoCamel is a lightweight, Go-native integration framework inspired by Apache Camel. It provides:
Modular Architecture — Component-based design Type Safety — Full Go type safety Concurrency — Built on Go goroutines Zero External Dependencies — Optional database drivers only Route &amp; Endpoint Model context := gocamel.NewCamelContext() route := context.CreateRouteBuilder(). From("direct:input"). // Consumer endpoint Process(myProcessor). // Custom processor To("direct:output"). // Producer endpoint Build() context.AddRoute(route) context.Start() Message Model ┌───────────────────────────────────────────────┐ │ Exchange │ │ ┌─────────────────────────────────────────┐ │ │ │ Properties │ │ │ │ correlationId: "abc-123" │ │ │ │ routeId: "route-1" │ │ │ └─────────────────────────────────────────┘ │ │ ┌─────────────────────────────────────────┐ │ │ │ In │ │ │ │ Headers: map[string]any │ │ │ │ Content-Type: "application/json" │ │ │ │ │ │ │ │ Body: any │ │ │ │ {"name": "John", "age": 30} │ │ │ └─────────────────────────────────────────┘ │ │ ┌─────────────────────────────────────────┐ │ │ │ Out │ │ │ │ Headers: map[string]any │ │ │ │ X-Processed: "true" │ │ │ │ │ │ │ │ Body: any │ │ │ │ {"name": "John", "age": 31} │ │ │ └─────────────────────────────────────────┘ │ └───────────────────────────────────────────────┘ Simple Language Dynamic expression language for routing and transformations:</description></item><item><title>Quick Start</title><link>https://gocamel.tranchida.cloud/en/quickstart/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/quickstart/index.html</guid><description>Hello World package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() route := ctx.CreateRouteBuilder(). From("timer:tick?period=5s"). SetBody("Hello World"). Log("${body}"). Build() ctx.AddRoute(route) ctx.Start() select {} } File Processing route := ctx.CreateRouteBuilder(). From("file://input?delete=true"). Log("Processing: ${body}"). To("file://output"). Build() HTTP Endpoint route := ctx.CreateRouteBuilder(). From("http://localhost:8080/hello"). SetBody("Hello ${header.name}!"). Build()</description></item><item><title>Core Concepts</title><link>https://gocamel.tranchida.cloud/en/concepts/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/concepts/index.html</guid><description>Message The fundamental unit of exchange containing:
Body: The message payload (any type) Headers: Key-value metadata (map[string]any) Messages provide typed accessors for convenience:
body, _ := msg.GetBodyAsString() count, _ := msg.GetHeaderAsInt("X-Count") Exchange Container for messages passing through a route:
In: Input message (from consumer) Out: Output message (to producer) Properties: Exchange-scoped metadata Context: Go context for cancellation Exchanges also proxy typed accessors to the In message:</description></item><item><title>Architecture</title><link>https://gocamel.tranchida.cloud/en/architecture/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/architecture/index.html</guid><description>Overview GoCamel follows a modular architecture inspired by Apache Camel but adapted to Go idioms.
graph LR subgraph "Core Layer" A[CamelContext] --&gt; B[Registry] A --&gt; C[RouteController] A --&gt; D[TypeConverter] end subgraph "Integration Layer" E[Components] --&gt; F[Endpoints] F --&gt; G[Consumers] F --&gt; H[Producers] end subgraph "DSL Layer" I[RouteBuilder] --&gt; J[Processors] J --&gt; K[EIP Patterns] end C --&gt; E K --&gt; G K --&gt; H Layers 1. Core Layer GoCamel core, independent of transports:</description></item><item><title>Components Reference</title><link>https://gocamel.tranchida.cloud/en/components/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/components/index.html</guid><description>Overview Complete reference of all available GoCamel components. Components provide connectivity to various systems and services.
Core Components Direct In-memory synchronous routing between routes in the same context.</description></item><item><title>Enterprise Integration Patterns</title><link>https://gocamel.tranchida.cloud/en/eip/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/eip/index.html</guid><description>Overview GoCamel implements the Enterprise Integration Patterns (EIP) from the classic book by Gregor Hohpe and Bobby Woolf.
Message Routing Choice Content-based routing with conditional branches.
builder.From("direct:start"). Choice(). When("${header.priority == 'high'}"). Log("High priority: ${body}"). To("direct:urgent"). When("${header.type} == 'order'&amp;&amp; ${body['amount']} &gt; 1000"). Log("Large order"). To("direct:large-orders"). When("${header.type} == 'email'"). To("direct:emails"). Otherwise(). Log("Default"). To("direct:normal"). EndChoice() Syntax:</description></item><item><title>Simple Language</title><link>https://gocamel.tranchida.cloud/en/simple-language/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/simple-language/index.html</guid><description>Overview Simple Language is a dynamic expression language inspired by Apache Camel. It enables embedding expression placeholders in strings for dynamic routing, message transformation, and conditional processing.
Syntax Expressions are enclosed in ${...}:
"Hello ${body}" // Message body "Priority: ${header.priority}" // Header value "ID: ${exchangeProperty.id}" // Exchange property Built-in Variables Variable Description Example ${body} Message body ${body} ${header.name} Header value ${header.Content-Type} ${exchangeProperty.name} Exchange property ${exchangeProperty.correlationId} Built-in Functions Function Description Example ${date:now:format} Current timestamp ${date:now:2006-01-02} ${date:command+offset:format} Date with arithmetic ${date:now+24h:2006-01-02} ${date:header.name:format} Date from header ${date:header.birthDate:2006} ${date:property.name:format} Date from property ${date:property.expiry:RFC3339} ${date:file:format} Last modified date of file ${date:file:2006-01-02} ${random(max)} Random number ${random(100)} ${uuid} UUID generation ${uuid} ${env:VAR} Environment variable ${env:USER} Arithmetic Offsets:</description></item><item><title>Installation</title><link>https://gocamel.tranchida.cloud/en/installation/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/installation/index.html</guid><description>Requirements Go 1.21 or later Module-aware Go project (go.mod) Install go get gitlab.com/tranchida/gocamel Or add to go.mod:
require gitlab.com/tranchida/gocamel v0.1.0 Then:
go mod tidy Verify package main import ( "fmt" "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() fmt.Println("GoCamel context created successfully!") } Run:</description></item><item><title>Configuration</title><link>https://gocamel.tranchida.cloud/en/configuration/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/configuration/index.html</guid><description>Overview GoCamel supports multiple configuration strategies for credentials, endpoints, and component settings.
Credential Sources gocamel.GetConfigValue(url, key) is the single entry point that every component uses to resolve a configuration value. It checks four sources in the following order — the first non-empty result wins:</description></item><item><title>Examples</title><link>https://gocamel.tranchida.cloud/en/examples/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/examples/index.html</guid><description>Overview Collection of practical examples demonstrating GoCamel features.
Hello World package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() route := ctx.CreateRouteBuilder(). From("timer:tick?period=5s"). SetBody("Hello GoCamel!"). Log("${body}"). Build() ctx.AddRoute(route) ctx.Start() select {} } OpenAI Integration package main import ( "fmt" "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() ctx.AddComponent("openai", gocamel.NewOpenAIComponent()) // Manual producer usage endpoint, _ := ctx.CreateEndpoint("openai:chat?model=gpt-3.5-turbo") producer, _ := endpoint.CreateProducer() exchange := gocamel.NewExchange(nil) exchange.GetIn().SetBody("Explain Go integration") producer.Send(exchange) fmt.Println(exchange.GetOut().GetBody()) } File Processing File to File package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() // Move files from input to output route := ctx.CreateRouteBuilder(). From("file://input?delete=true"). Log("Processing: ${header.CamelFileName}"). To("file://output"). Build() ctx.AddRoute(route) ctx.Start() select {} } File to File with Transformation route := ctx.CreateRouteBuilder(). From("file://input?include=*.txt&amp;delete=true"). ProcessFunc(func(e *gocamel.Exchange) error { content := e.GetIn().GetBody().(string) // Transform content e.GetOut().SetBody(strings.ToUpper(content)) return nil }). SetHeader("CamelFileName", "${header.CamelFileName}.processed"). To("file://output"). Build() HTTP Endpoints HTTP Echo Server package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() ctx.AddComponent("http", gocamel.NewHTTPComponent()) route := ctx.CreateRouteBuilder(). From("http://localhost:8080/hello"). SetBody("Hello ${header.name}!"). Build() ctx.AddRoute(route) // Management API mgmt := gocamel.NewManagementServer(ctx) mgmt.Start(":8081") ctx.Start() select {} } HTTP Consumer with Processing route := ctx.CreateRouteBuilder(). From("http://localhost:8080/api/process"). Choice(). When("${header.Content-Type} == 'application/json'"). ProcessFunc(func(e *gocamel.Exchange) error { // Process JSON e.GetOut().SetBody(`{"status":"ok"}`) e.GetOut().SetHeader("Content-Type", "application/json") return nil }). Otherwise(). SetBody("Unsupported content type"). EndChoice(). Build() FTP Integration FTP Download package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() ctx.AddComponent("ftp", gocamel.NewFTPComponent()) // Download from FTP route := ctx.CreateRouteBuilder(). From("ftp://ftp.example.com/incoming?delete=true&amp;passiveMode=true"). Log("Downloaded: ${header.CamelFileName}"). To("file://downloads"). Build() ctx.AddRoute(route) ctx.Start() select {} } SFTP with Key Auth route := ctx.CreateRouteBuilder(). From("sftp://secure.example.com/data?username=admin"). SetHeader("CamelFileName", "${header.CamelFileName}.secure"). To("file://secure-downloads"). Build() Content-Based Routing Choice Routing package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() route := ctx.CreateRouteBuilder(). From("direct:start"). Choice(). When("${header.priority == 'high'}"). SimpleSetBody("🚨 HIGH PRIORITY: ${body}"). SetHeader("X-Urgent", "true"). To("direct:urgent-queue"). When("${header.priority == 'medium'}"). SimpleSetBody("⚠️ MEDIUM: ${body}"). To("direct:normal-queue"). When("${body['count'] &gt; 100}"). SimpleSetBody("📦 LARGE BATCH: ${body['count']} items"). To("direct:batch-queue"). Otherwise(). SimpleSetBody("📄 LOW: ${body}"). To("direct:low-queue"). EndChoice(). Build() ctx.AddRoute(route) ctx.Start() select {} } Simple Language Transformation with Simple Language Expressions package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() route := ctx.CreateRouteBuilder(). From("direct:start"). SimpleSetBody("📨 Message: ${body}"). SimpleSetHeader("X-Timestamp", "${date:now}"). SimpleSetHeader("X-Request-ID", "${uuid}"). Log("Processing at ${header.X-Timestamp}"). To("direct:output"). Build() ctx.AddRoute(route) ctx.Start() select {} } JSON Processing with Simple Language package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() // Expected body: {"user": {"name": "John", "email": "john@example.com"}} route := ctx.CreateRouteBuilder(). From("direct:api"). Choice(). When("${header.Content-Type == 'application/json'}"). SimpleSetHeader("X-User-Name", "${body['user']['name']}"). SimpleSetHeader("X-User-Email", "${body['user']['email']}"). SimpleSetBody("👤 User ${body['user']['name']} registered"). Log("📝 User registration: ${body}"). To("direct:process-json"). When("${header.Content-Type == 'text/plain'}"). SimpleSetBody("📝 Message received: ${body}"). To("direct:process-text"). Otherwise(). SimpleSetBody("❌ Unsupported type: ${body}"). To("direct:error"). EndChoice(). Build() ctx.AddRoute(route) ctx.Start() select {} } Null-safe &amp; Collections package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() // Body: [{"name": "A"}, {"name": "B"}, {"name": "C"}] route := ctx.CreateRouteBuilder(). From("direct:start"). Log("First: ${body[0]['name']}"). Log("Last: ${body[last]['name']}"). Log("User (null-safe): ${body?.user?.name}"). SimpleSetHeader("X-First-Item", "${body[0]['name']}"). SimpleSetHeader("X-Last-Item", "${body[last]['name']}"). To("direct:output"). Build() ctx.AddRoute(route) ctx.Start() select {} } Message Splitting CSV Processing route := ctx.CreateRouteBuilder(). From("file://csv-input"). Split(func(e *gocamel.Exchange) (any, error) { body := e.GetIn().GetBody().(string) // Split CSV into lines return strings.Split(body, "\n"), nil }). Log("Processing line ${in.header.CamelSplitIndex}/${in.header.CamelSplitSize}"). ProcessFunc(func(e *gocamel.Exchange) error { // Process each line return nil }). To("direct:processed"). End(). // End split Log("All lines processed"). Build() Aggregation Split &amp; Aggregate package main import ( "strings" "gitlab.com/tranchida/gocamel" ) type StringConcatStrategy struct{} func (s *StringConcatStrategy) Aggregate( oldExchange, newExchange *gocamel.Exchange, ) *gocamel.Exchange { if oldExchange == nil { return newExchange } oldBody := oldExchange.GetOut().GetBody().(string) newBody := newExchange.GetOut().GetBody().(string) oldExchange.GetOut().SetBody(oldBody + newBody) return oldExchange } func main() { ctx := gocamel.NewCamelContext() strategy := &amp;StringConcatStrategy{} repo := gocamel.NewMemoryAggregationRepository() route := ctx.CreateRouteBuilder(). From("direct:start"). Split(func(e *gocamel.Exchange) (any, error) { body := e.GetIn().GetBody().(string) return strings.Split(body, ","), nil }). To("direct:transform"). End(). Aggregate(gocamel.NewAggregator( func(e *gocamel.Exchange) string { return "group" }, strategy, repo, ).SetCompletionSize(3)). Build() ctx.AddRoute(route) ctx.Start() select {} } Order Aggregation type OrderAggregationStrategy struct{} func (s *OrderAggregationStrategy) Aggregate( oldEx, newEx *gocamel.Exchange, ) *gocamel.Exchange { if oldEx == nil { return newEx } // Combine orders with same ID old := oldEx.GetIn().GetBody() new := newEx.GetIn().GetBody() combined := fmt.Sprintf("%s + %s", old, new) oldEx.GetIn().SetBody(combined) return oldEx } // Usage strategy := &amp;OrderAggregationStrategy{} repo := gocamel.NewMemoryAggregationRepository() aggregator := gocamel.NewAggregator("${header.orderId}", strategy, repo). SetCompletionSize(3). SetCompletionTimeout(30000) route := ctx.CreateRouteBuilder(). From("direct:line-items"). Aggregate(aggregator). Log("Order complete: ${body}"). To("direct:fulfillment"). End(). Build() Multicast Parallel Processing route := ctx.CreateRouteBuilder(). From("direct:incoming"). Multicast().ParallelProcessing(). To("direct:archive"). To("direct:audit"). To("direct:cache"). End(). Log("Multicast complete"). Build() Scheduled Jobs Timer package main import ( "gitlab.com/tranchida/gocamel" ) func main() { ctx := gocamel.NewCamelContext() // Run every 5 seconds route := ctx.CreateRouteBuilder(). From("timer:tick?period=5s"). Log("Tick at ${date:now}"). Build() ctx.AddRoute(route) ctx.Start() select {} } Cron Expression ctx.AddComponent("cron", gocamel.NewCronComponent()) // Run every minute route := ctx.CreateRouteBuilder(). From("cron://group/minutely?cron=0+*+*+*+*+*"). Log("Cron trigger at ${header.fireTime}"). Build() Database Integration SQL Query import ( "database/sql" _ "github.com/mattn/go-sqlite3" "gitlab.com/tranchida/gocamel" ) func main() { db, _ := sql.Open("sqlite3", "app.db") defer db.Close() ctx := gocamel.NewCamelContext() sqlComp := gocamel.NewSQLComponent() sqlComp.RegisterDataSource("appdb", db) ctx.AddComponent("sql", sqlComp) route := ctx.CreateRouteBuilder(). From("timer:poll?period=60s"). To("sql://appdb?query=SELECT+*+FROM+events+WHERE+processed=false"). Split(). Log("Event: ${body}"). To("direct:process-event"). End(). Build() ctx.AddRoute(route) ctx.Start() select {} } SQL Insert route := ctx.CreateRouteBuilder(). From("direct:new-user"). SetHeader("CamelSqlParameters", []any{ "${header.name}", "${header.email}", }). To("sql://appdb?query=INSERT+INTO+users(name,email)+VALUES(?,?)"). Log("User created, rows affected: ${header.CamelSqlRowCount}"). Build() Telegram Bot package main import ( "gitlab.com/tranchida/gocamel" ) func main() { // Set TELEGRAM_AUTHORIZATIONTOKEN env var ctx := gocamel.NewCamelContext() ctx.AddComponent("telegram", gocamel.NewTelegramComponent()) route := ctx.CreateRouteBuilder(). From("telegram:bots"). Log("Message from ${header.chatId}: ${body}"). SetBody("Echo: ${body}"). To("telegram:bots"). Build() ctx.AddRoute(route) ctx.Start() select {} } Template Processing Generating formatted messages with native Go templates (inspired by Apache Camel’s Velocity component).</description></item><item><title>API Reference</title><link>https://gocamel.tranchida.cloud/en/reference/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://gocamel.tranchida.cloud/en/reference/index.html</guid><description>CamelContext func NewCamelContext() *CamelContext Methods Method Description AddRoute(route *Route) Register a route AddComponent(name string, component Component) Register a component CreateEndpoint(uri string) (Endpoint, error) Create endpoint Start() Start all routes Stop() Stop all routes CreateRouteBuilder() *RouteBuilder Create route builder RouteBuilder Source Method Description From(uri string) *RouteBuilder Set source endpoint Processing Method Description To(uri string) *RouteBuilder Send to endpoint ToD(uri string) *RouteBuilder Dynamic destination Process(p Processor) *RouteBuilder Custom processor ProcessFunc(fn) *RouteBuilder Function processor ProcessRef(name) *RouteBuilder Reference from registry Log(msg string) *RouteBuilder Log static message LogSimple(expr) *RouteBuilder Log dynamic expression Message / Exchange Accessors Common methods available on Message and proxied on Exchange (accessing the In message):</description></item></channel></rss>