Giter Site home page Giter Site logo

oalles / sip-platform Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 100 KB

A Sip domain management application based on redis, redis gears v2 prerelease and kamailio

Java 77.52% JavaScript 22.48%
javascript kamailio redis redis-gears redis-om-spring redis-stack sip

sip-platform's Introduction

A SIP Domain Management Application with Java, Redis, Redis OM Spring, Redis Gears V2, and Kamailio

The goal is simply to experiment with the Redis Gears 2 (Triggers and Functions) prerelease, which includes V8 JavaScript Engine support, allowing us to subscribe JavaScript functions that automatically execute code on data changes directly in the Redis database.

Disclaimer: This project is all about the exploration rather than the end result.

Scenario

We will be developing a SIP domain management application to facilitate user registration and connection to a SIP domain.

Having chosen Redis as our backend database and Kamailio to manage SIP communications, our primary goal is to develop a real-time synchronization system that ensures consistent and accurate data between our custom SipPlatform business model and the required Kamailio model.

Diagram

Description

Our business logic is composed of two main components:

  1. Java Service: It serves as the primary interface for data manipulation.
  2. Redis Gears V2 functions: to ensure that any changes in the business model are promptly reflected in Kamailio's configuration for SIP registration and management.

Our custom domain model is inspired by the Twilio SIP API, focusing primarily on two classes: SipDomain and Credential.

With support from Spring OM Redis, built on Spring Data Redis, we will effectively map our Java model to RedisJSON documents. RedisJSON module, will enable us to use Redis as a high-performance NoSQL document database. SipDomain and Credential models will be stored as JSON documents.

We plan to use Redis Gears v2 to subscribe JavaScript functions to keyspace notifications which will help us:

  • include auditing metadata into our SIPPlatform domain entities.
  • ensure Kamailio's configuration consistency, as any updates to our domain entities will be immediately delivered.

Redis Gears V2 Functions

A more detailed description here.

SipPlatform Java Service

A more detailed description here.

SIP Domain Implementation with Kamailio and Redis

Kamailio is a powerful SIP (Session Initiation Protocol) server that can be customized to handle a wide range of SIP-related functionalities.

While Kamailio supports various databases, we're specifically choosing Redis for our example.

To enable Redis as the database backend for Kamailio, specific configurations need to be set. Here's an overview of what the Kamailio configuration file for Redis might look here.

Prerequisites

  • Node.js (v18.18.0) and npm(9.8.1) installed
  • Redis Stack Server running with Key Space Notifications enabled: CONFIG SET notify-keyspace-events KEA
  • Maven (3.8.3) and Java (11) installed
  • docker and docker-compose

Usage

  1. Start Redis Stack Server and Kamailio instances with docker-compose:
$ cd environment
$ docker-compose up
  1. Start the Redis Insights gui, start the profiler, open the CLI and run the following command in order check whether keyspace events notifications are enabled:
CONFIG GET notify-keyspace-events
# CONFIG SET notify-keyspace-events KEA
  1. Deploy javascript code to Redis Stack server:
$ cd redis-functions
$ npm install
$ npm run deploy
> [email protected] deploy
> gears-api index.js

Deployed! :)
  1. Run the java backend application. This will create the necessary Redis indexes. (If you flush all redis data, be sure to rerun it in order to recreate the indexes
$ cd backend
$ mvn spring-boot:run
  1. Try creating a SipDomain, a Credential entities and request a DomainReload to Kamailio:
POST http://localhost:8080/domains
{
    "name": "fictsip.com"
}
POST http://localhost:8080/credentials
{
    "domain": "fictsip.com",
    "username": "omar",
    "password": "omar"
}
POST http://localhost:5060/RPC
{
    "jsonrpc": "2.0",
    "method": "domain.reload",
    "id": 1 # increment this id for each request
}

A postman collection is provided:

Try with Postman

  1. Try SIP registration to the created domain with the created credentials with a soft phone. Zoiper registered

sip-platform's People

Contributors

oalles avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.