Skip to content

noushkia/Message-Broker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kianoush Arshi 810198438

Introduction

In this project, we’ll implement a message queue broker in Go.
The broker has the following features:

How to run the project

The project includes a server, client and a broker.
To run the broker use the following command:
go run connection.go -port <port_num>-maxl <max queue length> -wsize <number of workers>
And for running servers and clients use:
go run client.go -host localhost -port <port_num>
go run server.go -host localhost -port <port_num>

Connection

The project runs on a tcp server; the broker listens on a socket and the clients/servers connect to that socket and communicate with the broker.

Synchronous messaging

The broker contains a queue of messages i.e. payloads. Each time the server requests a publishing, the broker appends the message on the queue with the respectable topic.
This appending is a critical section, thus we use a mutex lock to preserve integrity.
Whenever possible, the messages are sent to the topic's subscribers using subscriber handler.

Asynchronous messaging

In the async method, the broker sends each message (event) to a channel which will then be used by the workers (go routines) to be sent to the subscribers.
Note that the client is non-blocking and with each request, it doesn't expect a response. This was made possible by using a go routine for the response handling.

Overflow handling

If there is a new publish request, the broker checks if the queue of the request topic is full or not.
If the queue was full, it will return an OverflowError and cancel the publishing.

Two way communication

The client can both subscribe and publish to a topic using -subscribe and -publish commands.

Concurrent connection

Many servers and clients can connect to a broker, this is made possible using go routines.
Each time a new client is connected to the socket, a new go routine for the specific client is created and the communication is resumed in that routine.

References

About

A message broker implemented in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages