Type-Based Message Bus for Non-Object-Oriented Applications
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
String-based message buses in non-object oriented languages lack type safety and support for message type hierarchies, leading to runtime errors, cumbersome code maintenance, and extensive refactoring when adding new message types, due to lack of type hierarchies and type safety.
Innovation Solution
A type-based message bus that supports subscription and publication by type, using TypeScript to collect and store class metadata at startup, allowing for accurate type hierarchy modeling and ensuring type safety by checking listener method parameters against the subscribed message types, enabling subscribers to receive messages for current and future sub-types automatically.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Ease of manufacture
If string-based message buses are used in non-object oriented languages, then implementation simplicity is achieved, but type safety and support for message type hierarchies are lost
Solution Approach 1:
The patent introduces a type system as an intermediary layer between the string-based message bus and the application logic. This type system acts as a mediator that translates string-based messages into strongly-typed messages, providing type safety without requiring a complete rewrite of the message bus infrastructure. The type system intercepts and validates message types, preventing runtime type errors while maintaining the underlying string-based implementation.
Solution Approach 2:
The patent changes the parameter representation from raw strings to strongly-typed parameters with hierarchical type structures. By transforming message identifiers from simple strings to typed parameters that include type information and hierarchy relationships, the system gains type safety and hierarchical support while maintaining compatibility with the existing string-based message bus through parameter transformation.
2Ease of operation
If string-based message buses are used, then ease of operation is maintained, but runtime errors increase due to lack of type checking
Solution Approach 1:
The patent implements preliminary type checking at compile-time or message publication time, before messages are dispatched to subscribers. The type system validates message types and checks listener method parameters in advance, catching type mismatches before they cause runtime errors. This preliminary validation maintains ease of operation during runtime while preventing runtime errors through advance type verification.
3Device complexity
If string-based message buses are used, then device complexity is low, but maintenance difficulty increases when adding new message types
Solution Approach 1:
The patent segments the message type system into hierarchical components with clear separation between base types and derived types. New message types can be added as new subclasses without modifying existing type definitions or subscriber code. This segmentation isolates changes to specific type segments, reducing maintenance difficulty when adding new message types while keeping the overall system complexity manageable through modular type organization.
4Reliability
If type-based message bus is implemented, then type safety and hierarchical support are achieved, but implementation complexity increases
Solution Approach 1:
The patent creates a universal type system that can work with both object-oriented and non-object-oriented languages through a common interface and metadata approach. The type system is designed to be language-agnostic, using standardized type representations and reflection mechanisms that function across different programming paradigms. This universality reduces implementation complexity by providing a single type safety solution that serves multiple language environments without requiring separate implementations.
Data Source
AI summary
Techniques are provided for providing a type-based message bus with message type hierarchies for non-object oriented languages. In an example, a type-aware message bus receives a subscription message from a subscriber that identifies an object-oriented class. The message bus determines an event channel that corresponds to the class, and subscribes the subscriber to the event channel. The message bus also determines any event channels that correspond to a subclass of the class, and subscribes the subscriber to those event channels. When a publisher publishes a message to an event channel, the message bus publishes the message to each subscriber of the event channel, which can have the effect of publishing the message to subscribers that originally subscribed to superclass event channels of the event channel.


