Asynchronous TCP communication system in order to support micro-service architecture.
A high-performance C++20 messaging framework designed for distributed applications. Built on lock-free thread pools and featuring type-safe containers, PostgreSQL integration, and asynchronous TCP networking.
This messaging system now includes the latest thread_system with:
git clone <repository-url> messaging_system
cd messaging_system
git submodule update --init --recursive
# Automated dependency installation
./dependency.sh
# On macOS with Homebrew
brew install postgresql cmake
# On Ubuntu/Debian
sudo apt update && sudo apt install postgresql-dev cmake build-essential
# Quick build (Release mode)
./build.sh
# Build with tests
./build.sh --tests
# Clean build
./build.sh --clean
# Build specific modules only
./build.sh --no-database --no-python
# Run all tests
./build.sh --tests
# Or run individual test suites
cd build/bin
./container_test
./database_test
./network_test
./integration_test
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_UNIT_TEST=ON
cmake --build . --parallel
container/
)Type-safe, high-performance data containers
database/
)PostgreSQL integration with enterprise features
network/
)High-performance TCP messaging infrastructure
thread_system/
)Lock-free concurrent processing framework
#include <container/container.h>
using namespace container_module;
int main() {
// Create a type-safe container
auto container = std::make_shared<value_container>();
// Set various value types
container->set_source("client_01", "session_1");
container->set_target("server", "main");
container->set_message_type("user_data");
// Serialize and deserialize
std::string serialized = container->serialize();
auto restored = std::make_shared<value_container>(serialized);
return 0;
}
#include <network/messaging_server.h>
#include <network/messaging_client.h>
using namespace network_module;
int main() {
// Create server
auto server = std::make_shared<messaging_server>("main_server");
server->start_server(8080);
// Create client
auto client = std::make_shared<messaging_client>("client_01");
client->start_client("127.0.0.1", 8080);
// Server and client automatically handle messaging
// Cleanup
client->stop_client();
server->stop_server();
return 0;
}
#include <database/database_manager.h>
using namespace database;
int main() {
// Configure database
database_manager manager;
manager.set_mode(database_types::postgres);
// Connect and execute queries
if (manager.connect("host=localhost dbname=mydb")) {
auto result = manager.select_query("SELECT * FROM users");
// Process results...
manager.disconnect();
}
return 0;
}
from messaging_system import Container, MessagingClient, Value
import time
# Create and populate a container
container = Container()
container.create(
target_id="server",
source_id="python_client",
message_type="data_update",
values=[
Value("user_id", "9", "12345"),
Value("message", "f", "Hello from Python!"),
Value("timestamp", "9", str(int(time.time())))
]
)
# Network client
client = MessagingClient(
source_id="py_client",
connection_key="secure_key",
recv_callback=lambda msg: print(f"Received: {msg}")
)
if client.start("localhost", 8080):
# Send container as message
serialized = container.serialize()
client.send_raw_message(serialized)
client.stop()
Component | Metric | Lock-free | Mutex-based | Improvement |
---|---|---|---|---|
Thread Pool | Throughput | 2.48M jobs/sec | 1.16M jobs/sec | 2.14x |
Job Queue | Latency | 250ns | 1.2μs | 4.8x |
Container | Serialization | 15M ops/sec | 12M ops/sec | 1.25x |
Network | Connections | 10K concurrent | 8K concurrent | 1.25x |
┌─────────────────────────────────────────────────────────┐
│ Application Layer │
├─────────────────────────────────────────────────────────┤
│ C++ API │ Python Bindings │ REST API │
├─────────────────────────────────────────────────────────┤
│ Container │ Database │ Network │
│ Module │ Module │ Module │
├─────────────────────────────────────────────────────────┤
│ Thread System (Lock-free) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │Thread Pools │ │ Job Queues │ │ Hazard Pointers │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
├─────────────────────────────────────────────────────────┤
│ Foundation Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Utilities │ │ Monitoring │ │ Logging │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────┘
# All tests with coverage
./build.sh --tests
# Specific test modules
cd build/bin
./container_test --gtest_filter="ContainerTest.*"
./database_test --gtest_filter="DatabaseTest.SingletonAccess"
./network_test --gtest_filter="NetworkTest.ServerClientIntegration"
# Performance benchmarks
cd build
./thread_system/bin/lockfree_performance_benchmark
./thread_system/bin/container_benchmark
git checkout -b feature/amazing-feature
./build.sh --tests
git commit -m 'feat: add amazing feature'
git push origin feature/amazing-feature
BSD 3-Clause License
Copyright (c) 2021-2025, Messaging System Contributors
All rights reserved.
See LICENSE file for full license text.