Awesome
LIBEMQ
libemq - is an open source client library for the EagleMQ written in C.
It has been designed to be light on memory usage, high performance, and provide full access to server side methods.
Methods
Common methods
emq_client *emq_tcp_connect(const char *addr, int port);
Connect to the EagleMQ server via TCP protocol.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>addr</td> <td>the server IP</td> </tr> <tr> <td>2</td> <td>port</td> <td>the server port</td> </tr> </table>Return: emq_client on success, NULL on error.
emq_client *emq_unix_connect(const char *path);
Connect to the EagleMQ server via unix domain socket.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>path</td> <td>the path to unix domain socket</td> </tr> </table>Return: emq_client on success, NULL on error.
void emq_disconnect(emq_client *client);
Disconnects the client from the server and removes the connection context.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>void emq_noack_enable(emq_client *client);
Enable noack mode.
When enabled, the server does not respond to commands status messages and the result is always EMQ_STATUS_OK. Using this option is useful for performance. Also, it should be used to send commands if you are subscribed to the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>void emq_noack_disable(emq_client *client);
Disable noack mode.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>int emq_process(emq_client *client);
Processing of all server events.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
void emq_list_rewind(emq_list *list, emq_list_iterator *iter);
Initialize the list iterator.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Direction</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>list</td> <td>in</td> <td>the list</td> </tr> <tr> <td>2</td> <td>iter</td> <td>out</td> <td>the list iterator</td> </tr> </table>emq_list_node *emq_list_next(emq_list_iterator *iter);
Gets the next value list.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>iter</td> <td>the list iterator</td> </tr> </table>Return: emq_list_node.
void emq_list_release(emq_list *list);
Delete list.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>list</td> <td>the list</td> </tr> </table>char *emq_last_error(emq_client *client);
Description of the last error client.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>Return: description of the error.
int emq_version(void);
Returns the version libemq.
Return: version libemq.
Messages methods
emq_msg *emq_msg_create(void *data, size_t size, int zero_copy);
Create a new message.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>data</td> <td>the message data</td> </tr> <tr> <td>2</td> <td>size</td> <td>the message size</td> </tr> <tr> <td>3</td> <td>zero_copy</td> <td>flag to use zero copy (EMQ_ZEROCOPY_ON, EMQ_ZEROCOPY_OFF)</td> </tr> </table>Return: new message.
emq_msg *emq_msg_copy(emq_msg *msg);
Copy the message.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>msg</td> <td>the message</td> </tr> </table>Return: copy of the message.
void emq_msg_expire(emq_msg *msg, emq_time time);
Set expiration time for message.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>msg</td> <td>the message</td> </tr> <tr> <td>2</td> <td>time</td> <td>the time (in miliseconds)</td> </tr> </table>void *emq_msg_data(emq_msg *msg);
Get the message data.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>msg</td> <td>the message</td> </tr> </table>Return: message data.
size_t emq_msg_size(emq_msg *msg);
Get the message size.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>msg</td> <td>the message</td> </tr> </table>Return: size of the message.
emq_tag emq_msg_tag(emq_msg *msg);
Get tag of the message.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>msg</td> <td>the message</td> </tr> </table>Return: tag of the message.
void emq_msg_release(emq_msg *msg)
Delete the message.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>msg</td> <td>the message</td> </tr> </table>Basic methods
int emq_auth(emq_client *client, const char *name, const char *password);
Client authentication on the server.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the user name</td> </tr> <tr> <td>3</td> <td>password</td> <td>the user password</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_ping(emq_client *client);
Ping server. Used to check the server status.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_stat(emq_client *client, emq_status *status);
Get server statistics.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Direction</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>in</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>status</td> <td>out</td> <td>the server statistics</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_save(emq_client *client, uint8_t async);
Saving data to disk.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>async</td> <td>Saving mode (0 - synchronously save, 1 - asynchronously save)</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_flush(emq_client *client, uint32_t flags);
Deleting the data on the server.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>flags</td> <td>flags to delete the data from the server (EMQ_FLUSH_ALL, EMQ_FLUSH_USER, EMQ_FLUSH_QUEUE, EMQ_FLUSH_CHANNEL)</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
User methods
int emq_user_create(emq_client *client, const char *name, const char *password, emq_perm perm);
Create a new user.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the user name</td> </tr> <tr> <td>3</td> <td>password</td> <td>the user password</td> </tr> <tr> <td>4</td> <td>perm</td> <td>the user permissions (see Table 1)</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
emq_list *emq_user_list(emq_client *client);
Get a list of all users.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>Return: list of users.
int emq_user_rename(emq_client *client, const char *from, const char *to);
Rename the user.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>from</td> <td>the old user name</td> </tr> <tr> <td>3</td> <td>to</td> <td>the new user name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_user_set_perm(emq_client *client, const char *name, emq_perm perm);
Set permissions to the user.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the user name</td> </tr> <tr> <td>3</td> <td>perm</td> <td>the user permissions (see Table 1)</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_user_delete(emq_client *client, const char *name);
Delete the user.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the user name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
Table 1. Description of user permissions
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Command</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>EMQ_QUEUE_PERM</td> <td> <i>.queue_create</i><br/> <i>.queue_declare</i><br/> <i>.queue_exist</i><br/> <i>.queue_list</i><br/> <i>.queue_rename</i><br/> <i>.queue_size</i><br/> <i>.queue_push</i><br/> <i>.queue_get</i><br/> <i>.queue_pop</i><br/> <i>.queue_confirm</i><br/> <i>.queue_subscribe</i><br/> <i>.queue_unsubscribe</i><br/> <i>.queue_purge</i><br/> <i>.queue_delete</i> </td> <td>The ability to perform all the commands associated with queues</td> </tr> <tr> <td>2</td> <td>EMQ_ROUTE_PERM</td> <td> <i>.route_create</i><br/> <i>.route_exist</i><br/> <i>.route_list</i><br/> <i>.route_keys</i><br/> <i>.route_rename</i><br/> <i>.route_bind</i><br/> <i>.route_unbind</i><br/> <i>.route_push</i><br/> <i>.route_delete</i><br/> </td> <td>The ability to perform all the commands associated with routes</td> </tr> <tr> <td>3</td> <td>EMQ_CHANNEL_PERM</td> <td> <i>.channel_create</i><br/> <i>.channel_exist</i><br/> <i>.channel_list</i><br/> <i>.channel_rename</i><br/> <i>.channel_publish</i><br/> <i>.channel_subscribe</i><br/> <i>.channel_psubscribe</i><br/> <i>.channel_unsubscribe</i><br/> <i>.channel_punsubscribe</i><br/> <i>.channel_delete</i><br/> </td> <td>The ability to perform all the commands associated with channel</td> </tr> <tr> <td>4</td> <td>EMQ_ADMIN_PERM</td> <td>-</td> <td>The ability to perform all the commands on the server (including the commands for working with users)</td> </tr> <tr> <td>5</td> <td>EMQ_NOT_CHANGE_PERM</td> <td>-</td> <td>If a user is created with the flag, then it can not be removed</td> </tr> <tr> <td>6</td> <td>EMQ_QUEUE_CREATE_PERM</td> <td>.queue_create</td> <td>Permission to create queues</td> </tr> <tr> <td>7</td> <td>EMQ_QUEUE_DECLARE_PERM</td> <td>.queue_declare</td> <td>Permission to declare the queue</td> </tr> <tr> <td>8</td> <td>EMQ_QUEUE_EXIST_PERM</td> <td>.queue_exist</td> <td>Permission to check the existence of the queue</td> </tr> <tr> <td>9</td> <td>EMQ_QUEUE_LIST_PERM</td> <td>.queue_list</td> <td>Permission to get a list of queues</td> </tr> <tr> <td>10</td> <td>EMQ_QUEUE_RENAME_PERM</td> <td>.queue_rename</td> <td>Permission to rename the queue</td> </tr> <tr> <td>11</td> <td>EMQ_QUEUE_SIZE_PERM</td> <td>.queue_size</td> <td>Permission to get the size of the queue</td> </tr> <tr> <td>12</td> <td>EMQ_QUEUE_PUSH_PERM</td> <td>.queue_push</td> <td>Permission to push messages to the queue</td> </tr> <tr> <td>13</td> <td>EMQ_QUEUE_GET_PERM</td> <td>.queue_get</td> <td>Permission to get messages from the queue</td> </tr> <tr> <td>14</td> <td>EMQ_QUEUE_POP_PERM</td> <td>.queue_pop</td> <td>Permission to pop messages from the queue</td> </tr> <tr> <td>15</td> <td>EMQ_QUEUE_CONFIRM_PERM</td> <td>.queue_confirm</td> <td>Permission to confirm delivery for the message</td> </tr> <tr> <td>16</td> <td>EMQ_QUEUE_SUBSCRIBE_PERM</td> <td>.queue_subscribe</td> <td>Permission to subscribe to the queue</td> </tr> <tr> <td>17</td> <td>EMQ_QUEUE_UNSUBSCRIBE_PERM</td> <td>.queue_unsubscribe</td> <td>Permission to unsubscribe from the queue</td> </tr> <tr> <td>18</td> <td>EMQ_QUEUE_PURGE_PERM</td> <td>.queue_purge</td> <td>Permission to delete all messages from the queue</td> </tr> <tr> <td>19</td> <td>EMQ_QUEUE_DELETE_PERM</td> <td>.queue_delete</td> <td>Permission to delete queue</td> </tr> <tr> <td>20</td> <td>EMQ_ROUTE_CREATE_PERM</td> <td>.route_create</td> <td>Permission to create route</td> </tr> <tr> <td>21</td> <td>EMQ_ROUTE_EXIST_PERM</td> <td>.route_exist</td> <td>Permission to check the existence of the route</td> </tr> <tr> <td>22</td> <td>EMQ_ROUTE_LIST_PERM</td> <td>.route_list</td> <td>Permission to get a list of routes</td> </tr> <tr> <td>23</td> <td>EMQ_ROUTE_KEYS_PERM</td> <td>.route_keys</td> <td>Permission to get a list of route keys</td> </tr> <tr> <td>24</td> <td>EMQ_ROUTE_RENAME_PERM</td> <td>.route_rename</td> <td>Permission to rename the route</td> </tr> <tr> <td>25</td> <td>EMQ_ROUTE_BIND_PERM</td> <td>.route_bind</td> <td>Permission to bind route with the queue</td> </tr> <tr> <td>26</td> <td>EMQ_ROUTE_UNBIND_PERM</td> <td>.route_unbind</td> <td>Permission to unbind route from the queue</td> </tr> <tr> <td>27</td> <td>EMQ_ROUTE_PUSH_PERM</td> <td>.route_push</td> <td>Permission to push messages to the route</td> </tr> <tr> <td>28</td> <td>EMQ_ROUTE_DELETE_PERM</td> <td>.route_delete</td> <td>Permission to delete route</td> </tr> <tr> <td>29</td> <td>EMQ_CHANNEL_CREATE_PERM</td> <td>.channel_create</td> <td>Permission to create channel</td> </tr> <tr> <td>30</td> <td>EMQ_CHANNEL_EXIST_PERM</td> <td>.channel_exist</td> <td>Permission to check the existence of the channel</td> </tr> <tr> <td>31</td> <td>EMQ_CHANNEL_LIST_PERM</td> <td>.channel_list</td> <td>Permission to get a list of channels</td> </tr> <tr> <td>32</td> <td>EMQ_CHANNEL_RENAME_PERM</td> <td>.channel_rename</td> <td>Permission to rename the channel</td> </tr> <tr> <td>33</td> <td>EMQ_CHANNEL_PUBLISH_PERM</td> <td>.channel_publish</td> <td>Permission to publish message to the channel</td> </tr> <tr> <td>34</td> <td>EMQ_CHANNEL_SUBSCRIBE_PERM</td> <td>.channel_subscribe</td> <td>Permission to subscribe to the channel by topic</td> </tr> <tr> <td>35</td> <td>EMQ_CHANNEL_PSUBSCRIBE_PERM</td> <td>.channel_psubscribe</td> <td>Permission to subscribe to the channel by pattern</td> </tr> <tr> <td>36</td> <td>EMQ_CHANNEL_UNSUBSCRIBE_PERM</td> <td>.channel_unsubscribe</td> <td>Permission to unsubscribe from channel by topic</td> </tr> <tr> <td>37</td> <td>EMQ_CHANNEL_PUNSUBSCRIBE_PERM</td> <td>.channel_punsubscribe</td> <td>Permission to unsubscribe from channel by pattern</td> </tr> <tr> <td>38</td> <td>EMQ_CHANNEL_DELETE_PERM</td> <td>.channel_delete</td> <td>Permission to delete channel</td> </tr> </table>Queue methods
int emq_queue_create(emq_client *client, const char *name, uint32_t max_msg, uint32_t max_msg_size, uint32_t flags);
Create the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> <tr> <td>3</td> <td>max_msg</td> <td>the maximum number of messages</td> </tr> <tr> <td>4</td> <td>max_msg_size</td> <td>the maximum message size</td> </tr> <tr> <td>5</td> <td>flags</td> <td>flags to create a queue (EMQ_QUEUE_NONE, EMQ_QUEUE_AUTODELETE, EMQ_QUEUE_FORCE_PUSH, EMQ_QUEUE_ROUND_ROBIN, EMQ_QUEUE_DURABLE)</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_queue_declare(emq_client *client, const char *name);
Declare the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_queue_exist(emq_client *client, const char *name);
Check the queue of existence.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> </table>Return: Value greater than 0 if the queue exists.
emq_list *emq_queue_list(emq_client *client);
Get a list of queues.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>Return: list of queues.
int emq_queue_rename(emq_client *client, const char *from, const char *to);
Rename the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>from</td> <td>the old queue name</td> </tr> <tr> <td>3</td> <td>to</td> <td>the new queue name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
size_t emq_queue_size(emq_client *client, const char *name);
Get the number of elements in the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> </table>Return: number of elements in the queue.
int emq_queue_push(emq_client *client, const char *name, emq_msg *msg);
Push a message to the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> <tr> <td>3</td> <td>msg</td> <td>the message</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
emq_msg *emq_queue_get(emq_client *client, const char *name);
Get a message from the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> </table>Return: message on success, NULL on error.
emq_msg *emq_queue_pop(emq_client *client, const char *name, uint32_t timeout);
Pop a message from the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> <tr> <td>3</td> <td>timeout</td> <td>the timeout for wait confirm delivery</td> </tr> </table>Return: message on success, NULL on error.
int emq_queue_confirm(emq_client *client, const char *name, emq_tag tag);
Confirm delivery message.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> <tr> <td>3</td> <td>tag</td> <td>the message tag</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_queue_subscribe(emq_client *client, const char *name, uint32_t flags, emq_msg_callback *callback);
Subscribe to the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> <tr> <td>3</td> <td>flags</td> <td>flags subscription (EMQ_QUEUE_SUBSCRIBE_MSG, EMQ_QUEUE_SUBSCRIBE_NOTIFY)</td> </tr> <tr> <td>4</td> <td>callback</td> <td>callback to the event subscription</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_queue_unsubscribe(emq_client *client, const char *name);
Unsubscribe from the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_queue_purge(emq_client *client, const char *name);
Purge the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_queue_delete(emq_client *client, const char *name);
Delete the queue.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the queue name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
Route methods
int emq_route_create(emq_client *client, const char *name, uint32_t flags);
Create the route.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the route name</td> </tr> <tr> <td>3</td> <td>flags</td> <td>flags to create a route (EMQ_ROUTE_NONE, EMQ_ROUTE_AUTODELETE, EMQ_ROUTE_ROUND_ROBIN, EMQ_ROUTE_DURABLE)</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_route_exist(emq_client *client, const char *name);
Check the route of existence.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the route name</td> </tr> </table>Return: Value greater than 0 if the route exists.
emq_list *emq_route_list(emq_client *client);
Get a list of route.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>Return: list of routes.
int emq_route_rename(emq_client *client, const char *from, const char *to);
Rename the route.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>from</td> <td>the old route name</td> </tr> <tr> <td>3</td> <td>to</td> <td>the new route name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
emq_list *emq_route_keys(emq_client *client, const char *name);
Get a list of route keys.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the route name</td> </tr> </table>Return: list of route keys.
int emq_route_bind(emq_client *client, const char *name, const char *queue, const char *key);
Bind the route with queue by key.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the route name</td> </tr> <tr> <td>3</td> <td>queue</td> <td>the queue name</td> </tr> <tr> <td>4</td> <td>key</td> <td>the key</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_route_unbind(emq_client *client, const char *name, const char *queue, const char *key);
Unbind the route from queue by a key.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the route name</td> </tr> <tr> <td>3</td> <td>queue</td> <td>the queue name</td> </tr> <tr> <td>4</td> <td>key</td> <td>the key</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_route_push(emq_client *client, const char *name, const char *key, emq_msg *msg);
Push a message to the route.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the route name</td> </tr> <tr> <td>3</td> <td>key</td> <td>the key</td> </tr> <tr> <td>4</td> <td>msg</td> <td>the message</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_route_delete(emq_client *client, const char *name);
Delete the route.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the route name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
Channel methods
int emq_channel_create(emq_client *client, const char *name, uint32_t flags);
Create the channel.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the channel name</td> </tr> <tr> <td>3</td> <td>flags</td> <td>flags to create a channel (EMQ_CHANNEL_NONE, EMQ_CHANNEL_AUTODELETE, EMQ_CHANNEL_ROUND_ROBIN, EMQ_CHANNEL_DURABLE)</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_channel_exist(emq_client *client, const char *name);
Check the channel of existence.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the channel name</td> </tr> </table>Return: Value greater than 0 if the channel exists.
emq_list *emq_channel_list(emq_client *client);
Get a list of channels.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> </table>Return: list of channels.
int emq_channel_rename(emq_client *client, const char *from, const char *to);
Rename the channel.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>from</td> <td>the old channel name</td> </tr> <tr> <td>3</td> <td>to</td> <td>the new channel name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_channel_publish(emq_client *client, const char *name, const char *topic, emq_msg *msg);
Publish a message to the channel.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the channel name</td> </tr> <tr> <td>3</td> <td>topic</td> <td>the channel topic</td> </tr> <tr> <td>4</td> <td>msg</td> <td>the message</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_channel_subscribe(emq_client *client, const char *name, const char *topic, emq_msg_callback *callback);
Subscribe to the channel by topic.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the channel name</td> </tr> <tr> <td>3</td> <td>topic</td> <td>the channel topic</td> </tr> <tr> <td>4</td> <td>callback</td> <td>callback to the event subscription</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_channel_psubscribe(emq_client *client, const char *name, const char *pattern, emq_msg_callback *callback);
Subscribe to the channel by pattern.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the channel name</td> </tr> <tr> <td>3</td> <td>pattern</td> <td>the channel pattern</td> </tr> <tr> <td>4</td> <td>callback</td> <td>callback to the event subscription</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_channel_unsubscribe(emq_client *client, const char *name, const char *topic);
Unsubscribe from the channel by topic.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the channel name</td> </tr> <tr> <td>3</td> <td>topic</td> <td>the channel topic</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_channel_punsubscribe(emq_client *client, const char *name, const char *pattern);
Unsubscribe from the channel by pattern.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the channel name</td> </tr> <tr> <td>3</td> <td>pattern</td> <td>the channel pattern</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
int emq_channel_delete(emq_client *client, const char *name);
Delete the channel.
<table> <tr> <td><b>№</b></td> <td><b>Name</b></td> <td><b>Description</b></td> </tr> <tr> <td>1</td> <td>client</td> <td>the context of a client connection</td> </tr> <tr> <td>2</td> <td>name</td> <td>the channel name</td> </tr> </table>Return: EMQ_STATUS_OK on success, EMQ_STATUS_ERR on error.
Author
libemq has written by Stanislav Yakush(st.yakush@yandex.ru) and is released under the BSD license.