AI Briefing
KO

Using Event-Driven Architecture Where It Fits Best

·2023.03.21 19:00

Key point

To efficiently handle complex Slack message structures, an event-driven architecture leveraging Jackson was implemented.

1 / 2

Details

The Slack bot 'Jordy Meeting Bot,' developed at an in-house hackathon, applied an event-driven structure to all of its business logic. Due to security policies, the Slack API uses WebSocket instead of webhooks, and a characteristic of this approach is that all kinds of interactions are delivered through a single endpoint in one JSON format.

Slack messages have a tree structure that branches from a parent type into subtypes, and identifying a specific message requires checking multiple levels of the type field. This causes the returned class type to vary during message interpretation, creating a problem where the internal data must be checked first before it can be converted into the appropriate class.

To solve this, a structure was designed that uses Jackson's JsonDeserializer to interpret messages and trigger events. In the Kotlin and Spring environment, the type field is recursively checked through an intermediate object, converting each message into its corresponding concrete SlackEvent class.

The events converted this way are published via EventPublisher, allowing flexible handling of complex message structures while cleanly separating business logic.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.