OCT 提交redis
This commit is contained in:
parent
99d2d892b6
commit
b560f74399
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,28 @@
|
||||||
|
#include "redisMq.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
bool ret = redisPubInit();
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
printf("Init failed.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = redisPubConnect();
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
printf("connect failed.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//while (true)
|
||||||
|
{
|
||||||
|
//redisPublish("test-channel", "Test message");
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
redisPubDisconnect();
|
||||||
|
redisPubUninit();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
#include "redisMq.h"
|
||||||
|
|
||||||
|
void test_func_recv(struct RecvMsg_t *msg)
|
||||||
|
{
|
||||||
|
if (msg->msg)
|
||||||
|
{
|
||||||
|
printf("%s,%d,%llu,%s,%d\n", __FUNCTION__, __LINE__, pthread_self(), msg->msg, msg->len);
|
||||||
|
freeMsg(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
bool ret = redisSubInit();
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
printf("Init failed.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
redisRegisterChannelFunc("test-channel",test_func_recv);
|
||||||
|
|
||||||
|
|
||||||
|
ret = redisSubConnect();
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
printf("Connect failed.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
redisSubscriber("test-channel");
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
redisSubDisconnect();
|
||||||
|
redisSubUninit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
#ifndef __REDIS_CHANNRL_H_
|
|
||||||
#define __REDIS_CHANNRL_H_
|
|
||||||
|
|
||||||
/* 建议 命名按照 redis_chan_模块名_功能*/
|
|
||||||
#define REDIS_CHAN_REDISMQ_TEST ("redis_chan_redismq_test")
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue