Message model

更新时间:
复制 MD 格式

The message (Timeline) model is designed for message data scenarios. It provides message ordering, massive message storage, and real-time synchronization. The model also supports full-text search and multi-dimensional queries. It is suitable for scenarios such as Instant Messaging (IM) and feed streams.

Model structure

The message model has a simple and modular structure. It is highly flexible, which lets you choose the most suitable implementation for your scenario. The message model consists of the following components:

  • Store: A Timeline data store, which is similar to a table in a database.

  • Identifier: A unique identity that distinguishes a timeline.

  • Meta: The metadata that describes a timeline. The metadata has a free-schema structure and can contain any columns.

  • Queue: A queue that stores all messages within a timeline.

  • SequenceId: The serial number of a message in the queue. It must be unique and incremental. The model supports two implementation patterns: auto-increment columns or custom settings.

  • Message: The message body transmitted within a timeline. It has a free-schema structure and can contain any columns.

  • Index: Includes a meta index and a message index. You can create custom indexes on any column in the metadata or message to enable flexible multi-conditional queries and searches.

Model structure

Features

The message model supports the following features.

  • Basic management of metadata and messages, including Create, Read, Update, and Delete (CRUD) operations.

  • Multi-dimensional queries and full-text search for metadata and messages.

  • Two ways to set the SequenceId: auto-increment column or manual setting.

  • Multi-column timeline identifiers.

  • Compatibility with the Timeline 1.X model. The provided `TimelineMessageForV1` sample can directly read and write Version 1 messages.

Notes

When you add the dependency for the Tablestore Java software development kit (SDK) in your Maven project, configure it based on the version number as follows.

  • For SDK versions 4.12.1 and later, the message model is already included. You only need to add the Tablestore dependency.

    <dependency>
        <groupId>com.aliyun.openservices</groupId>
        <artifactId>tablestore</artifactId>
        <version>4.12.1</version>
    </dependency>
  • For SDK versions earlier than 4.12.1, you must add both the Tablestore dependency and the Timeline dependency.

    <dependency>
        <groupId>com.aliyun.openservices.tablestore</groupId>
        <artifactId>Timeline</artifactId>
        <version>2.0.0</version>
    </dependency>

Solutions

  • Feed stream products are widely used in many popular applications, such as Weibo, news recommendations, and short video recommendations. To learn how to build a feed stream system that supports tens of millions of users with the message model, see How to build a feed stream system for tens of millions of users.

  • Modern IM systems built on the message model, such as DingTalk, support multiple messaging features. These features include multi-device synchronization, message roaming, and online search. In terms of performance and scale, these systems can store and index all messages in the cloud. They support millions of Transactions Per Second (TPS) for writes and provide message synchronization and retrieval with millisecond latency. For more information, see Implement DingTalk's IM features based on the Tablestore message model.