Training Day

Messaging Systems

Using message queues and messaging systems for robust FileMaker integrations

Messaging systems provide robust, scalable communication between applications, enabling reliable data exchange even in complex or high-volume scenarios.

Messaging Systems Overview

Message-oriented middleware facilitates asynchronous communication between systems by:

  • Decoupling sender and receiver systems
  • Providing reliable message delivery guarantees
  • Supporting various messaging patterns
  • Handling system outages and temporary failures
  • Enabling scalable architectures

Key Messaging Concepts

Message Queues

Message queues store messages until they are processed:

  • Durability: Messages persist until successfully processed
  • Ordering: Can maintain message sequence when needed
  • Buffering: Absorb traffic spikes and rate differences
  • Decoupling: Sender and receiver don't need to be available simultaneously

Publish/Subscribe (Pub/Sub)

Pattern where publishers send messages to topics and subscribers receive them:

  • One-to-many: Single message can be delivered to multiple subscribers
  • Topic-based: Messages organized by subject/category
  • Filtering: Subscribers can filter messages by criteria

Message Brokers

Central components that manage routing, storage, and delivery of messages:

  • Routing logic: Direct messages to appropriate destinations
  • Transformation: Can modify message format during transfer
  • Protocol translation: Bridge between different communication protocols

Common Messaging Systems

RabbitMQ

Popular open-source message broker implementing AMQP:

  • Reliability: Supports message acknowledgments and persistence
  • Routing capabilities: Complex routing with exchanges and bindings
  • Multiple protocols: Supports AMQP, MQTT, STOMP
  • Clustering: Horizontal scaling and high availability

Apache Kafka

Distributed event streaming platform:

  • High throughput: Designed for massive scale
  • Log-based architecture: Messages are appended to logs
  • Long-term storage: Can retain messages for configurable time
  • Stream processing: Built-in stream processing capabilities

MQTT (Message Queuing Telemetry Transport)

Lightweight protocol designed for constrained devices and networks:

  • Low overhead: Minimal packet size
  • Pub/sub model: Topic-based message delivery
  • Quality of Service: Configurable delivery guarantees
  • Ideal for IoT: Designed for unreliable networks and small devices

Cloud-Based Services

Managed messaging solutions from cloud providers:

  • AWS SQS/SNS: Simple Queue Service and Simple Notification Service
  • Azure Service Bus: Enterprise messaging as a service
  • Google Pub/Sub: Global message service

FileMaker Integration Approaches

Middleware Component

Create a middleware layer between FileMaker and messaging systems:

# Send message to middleware
Set Variable [$url; Value: "https://middleware.example.com/api/queue/send"]
Set Variable [$payload; Value: JSONSetElement("{}";
  ["queue"; "orders"; JSONString];
  ["message"; $orderData; JSONObject]
)]
Set Variable [$options; Value: "-X POST -H \"Content-Type: application/json\" --data " & Quote($payload)]

Insert From URL [Select; $result; $url; cURL options: $options]

Direct Integration with REST APIs

Many messaging systems expose REST APIs that FileMaker can interact with directly:

# Send message to RabbitMQ via REST API
Set Variable [$url; Value: "https://rabbitmq.example.com/api/exchanges/vhost/amq.default/publish"]
Set Variable [$message; Value: JSONSetElement("{}";
  ["properties"; JSONSetElement("{}";"content_type";"application/json";JSONString); JSONObject];
  ["routing_key"; "orders"; JSONString];
  ["payload"; $orderData; JSONString];
  ["payload_encoding"; "string"; JSONString]
)]
Set Variable [$options; Value: "-X POST -H \"Content-Type: application/json\" --data " & Quote($message) & " -u username:password"]

Insert From URL [Select; $result; $url; cURL options: $options]

FileMaker as a Message Consumer

Implement a polling mechanism to check for new messages:

# Poll for messages from a queue
Set Variable [$url; Value: "https://api.example.com/queue/receive?queue=notifications"]
Insert From URL [Select; $result; $url; cURL options: "-X GET -u username:password"]

If [not IsEmpty($result)]
  # Process message
  Set Variable [$messageBody; Value: JSONGetElement($result; "body")]
  Set Variable [$messageId; Value: JSONGetElement($result; "id")]

  # Your message processing logic here
  ...

  # Delete/acknowledge message
  Set Variable [$ackUrl; Value: "https://api.example.com/queue/acknowledge?id=" & $messageId]
  Insert From URL [Select; $ackResult; $ackUrl; cURL options: "-X POST -u username:password"]
End If

Using Plugins

Several FileMaker plugins offer direct messaging system integration:

  • MBS Plugin: Offers MQTT client functionality
  • HTTP plugins: Can interact with messaging REST APIs
  • Custom plugins: Some organizations develop custom plugins for specific messaging systems

Implementation Patterns

Store and Forward

When connecting FileMaker to messaging systems:

  1. Create a local table to store outgoing messages
  2. Write messages to this table when created
  3. Use a scheduled script to send stored messages to the messaging system
  4. Mark messages as sent when confirmed
  5. Implement retry logic for failed deliveries

Event Sourcing

Capture all state changes as a sequence of events:

  1. Store all system events in an events table
  2. Push events to a messaging system
  3. Allow multiple subscribers to process events
  4. Rebuild application state from event history when needed

Command Query Responsibility Segregation (CQRS)

Separate write and read operations:

  1. Send commands (write operations) through message queues
  2. Process commands asynchronously
  3. Update read models after command processing
  4. Query read models directly for data retrieval

Use Cases for FileMaker

Asynchronous Processing

Use messaging to handle background tasks:

  • Document generation
  • Email notifications
  • Report creation
  • Data imports/exports

System Integration

Connect FileMaker to other enterprise systems:

  • ERP systems
  • CRM applications
  • E-commerce platforms
  • Accounting software

Event Notification

Inform external systems about FileMaker events:

  • Record creation/modification
  • Status changes
  • Workflow transitions
  • User actions

Best Practices

  1. Message schemas: Define clear message formats and versions
  2. Error handling: Implement dead letter queues for failed messages
  3. Monitoring: Track message flow, queue depths, and processing times
  4. Security: Implement proper authentication and authorization
  5. Performance tuning: Configure message sizes, batching, and processing parameters