The ideology of SimQ is closest to RabbitMQ. The differences are in several points:
Schematically , the structure of SimQ can be shown as follows:
Groups can include an unlimited number of channels. You can add and delete groups only through the console. To add a group, start the server with the admin parameter, for exmample ./simq-sever admin
Go to the groups section if you are not in it − cd /groups
To add a group, run add groupName - where groupName is the name of your group.
If a group with the same name already exists, you will see an error. If there is no group with this name, you will be prompted to enter a password and confirm it. After confirming the password, you will see a message that the group will be created by the server. The fact is that for the sake of data integrity, only a working server can apply changes that were created by the user. As a rule, when the server is running, changes are made very quickly. To see the newly added group, go to the groups section and run ls groupName. If the changes were applied by the server, you will see your group.
To delete a group, you also need to go to the groups section, then run rm groupName and confirm the deletion. If the group does not exist, you will see an error. Also, the received changes will be applied by the server a little later. To make sure that the group is deleted, run ls groupName in the groups section. If the changes were applied by the server, you will not see the name of the deleted group.
In order to change the password of the group, you need to log in to it. For example cd /groups/groupName Then run the passwd command, enter a new password and confirm it. If everything was successful, you will see a message that the changes will be applied by the server later.
use SimQ\Group;
$group = new Group( 'localhost', 4012, 'groupName', 'password' );
$group->updatePassword( 'current password', 'new password' );
Channels are used to store messages in a queue. The queue itself is arranged according to the FIFO principle.
Go to the desired group cd /groups/groupName and execute add channelName Next, you will need to enter the following parameters:
minMessageSize - minimum message length
maxMessageSize - maximum message length
maxMessagesInMemory - maximum number of messages in memory
maxMessagesOnDisk - maximum number of messages on disk
The minMessageSize parameter must not be greater than maxMessageSize and cannot be equal to zero.
maxMessagesInMemory - should be used if you want to get maximum performance from the queue. It should be set to zero if the messages are large (for example, images, video files, etc.)
maxMessagesOnDisk - should be used when the message size is large enough, but it leads to a decrease in performance.
You can also use these 2 parameters together, in which case maxMessagesOnDisk will act as a backup for messages that do not fit in memory. The total maximum number of messages in the channel cannot be more than 4 294 967 295. If everything was successful, you will see a message that the changes will be applied by the server.
To change the channel settings, go to cd /groups/groupName/channelName, and enter info. You will see a list of settings, to change a specific setting, enter for example set minMessageSize 1. If everything was successful, you will see a message that the changes will be applied by the server.
To delete a channel, go to the group cd /groups/groupName, and run rm channelName. Confirm the deletion. If everything was successful, you will see a message that the changes will be applied by the server.
use SimQ\Group;
$group = new Group( 'localhost', 4012, 'groupName', 'password' );
$channels = $group->getChannels();
$limits = $group->getChannelLimitMessages( 'channelName' );
Consumers are used to receive messages from the channel.
Go to the desired channel in the consumers section cd /groups/groupName/channelName/consumers and execute add consumerLogin. Enter the password and confirm it. If everything was successful, you will see a message that the changes will be applied by the server.
Go to the consumer cd/groups/groupName/channelName/consumers/consumerLogin and execute passwd. Enter a new password and confirm it. If everything was successful, you will see a message that the changes will be applied by the server.
Go to the desired channel in the consumers section cd /groups/groupName/channelName/consumers and execute rm consumerLogin. If everything was successful, you will see a message that the changes will be applied by the server.
use SimQ\Group;
$group = new Group( 'localhost', 4012, 'groupName', 'password' );
$consumers = $group->getConsumers( 'channelName' );
Producers are used to add messages to the channel.
Go to the desired channel in the producers section cd /groups/groupName/channelName/producers and execute add producerLogin. Enter the password and confirm it. If everything was successful, you will see a message that the changes will be applied by the server.
Go to the producer cd /groups/groupName/channelName/producers/producerLogin and execute passwd. Enter a new password and confirm it. If everything was successful, you will see a message that the changes will be applied by the server.
Go to the desired channel in the producers section cd /groups/groupName/channelName/producers and execute rm producerLogin. If everything was successful, you will see a message that the changes will be applied by the server.
use SimQ\Group;
$group = new Group( 'localhost', 4012, 'groupName', 'password' );
$producers = $group->getProducers( 'channelName' );