A standalone AMQP server implementation in C# with in-memory queues that other applications can connect to for message queuing operations.
- .NET 9.0: Make sure you have .NET 9.0 SDK installed
- No external dependencies: This is a self-contained server with in-memory storage
- Navigate to the project directory
- Run the application:
dotnet run
- Choose mode:
- 1: Run as Server (hosts the AMQP service)
- 2: Run as Client Demo (connects to a running server)
Once the server is running, you can use these management commands:
create <queue_name>- Create a new queuedelete <queue_name>- Delete an existing queuelist- List all queues with message counts and subscriber countsstatus- Show server status (clients, queues, messages)clients- Show connected clientshelp- Show available commandsstop- Stop the server
> create myqueue
SUCCESS|Queue 'myqueue' created successfully
> list
SUCCESS|Queues: myqueue (0 messages, 0 subscribers)
> status
Server Status:
Running: True
Port: 5672
Connected Clients: 1
Total Queues: 1
Total Messages: 0
> stop
Stopping server...
The server accepts TCP connections on port 5672 and uses a simple text-based protocol.
CREATE_QUEUE|<queue_name>DELETE_QUEUE|<queue_name>SEND_MESSAGE|<queue_name>|<message>RECEIVE_MESSAGE|<queue_name>SUBSCRIBE|<queue_name>(for real-time message notifications)LIST_QUEUES
client> create testqueue
Server response: SUCCESS|Queue 'testqueue' created successfully
client> send testqueue Hello World!
Server response: SUCCESS|Message sent to queue 'testqueue'
client> subscribe testqueue
Server response: SUCCESS|Subscribed to queue 'testqueue'
You will now receive real-time messages from this queue.
client> receive testqueue
Server response: SUCCESS|Hello World!
You can use the included SimpleAmqpClient class in your applications:
var client = new SimpleAmqpClient();
await client.ConnectAsync();
// Create a queue
await client.CreateQueueAsync("myqueue");
// Send a message
await client.SendMessageAsync("myqueue", "Hello World!");
// Subscribe to real-time messages
client.MessageReceived += (queueName, message) => {
Console.WriteLine($"Received: {message}");
};
await client.SubscribeToQueueAsync("myqueue");
// Or poll for messages
var response = await client.ReceiveMessageAsync("myqueue");- In-Memory Queues: Fast, lightweight message storage
- TCP Server: Accepts multiple client connections
- Real-time Subscriptions: Clients can subscribe to queues for instant message delivery
- Management Interface: Command-line interface for server administration
- Thread-Safe: Concurrent queue operations using thread-safe collections
- Simple Protocol: Easy-to-implement text-based protocol
- Real-time Messages: Event-based message notifications
- Connection Management: Automatic reconnection handling
- Async Operations: Full async/await support
┌─────────────────┐ TCP/5672 ┌──────────────────┐
│ Client App │◄──────────────►│ AMQP Server │
└─────────────────┘ │ │
┌─────────────────┐ TCP/5672 │ ┌─────────────┐ │
│ Client App │◄──────────────►│ │ In-Memory │ │
└─────────────────┘ │ │ Queues │ │
┌─────────────────┐ TCP/5672 │ └─────────────┘ │
│ Client App │◄──────────────►│ │
└─────────────────┘ └──────────────────┘
COMMAND|parameter1|parameter2|...
STATUS|message
Where STATUS can be:
SUCCESS: Operation completed successfullyERROR: Operation failedINFO: Informational message
When subscribed to a queue, clients receive:
MESSAGE|<queue_name>|<message_id>|<message_content>
- In-Memory Storage: All data is lost when the server stops
- No Persistence: Messages are not saved to disk
- Simple Protocol: Easy to implement in any programming language
- Thread-Safe: Supports concurrent operations from multiple clients
- Port 5672: Uses the standard AMQP port for compatibility