TongLinkQ消息中间件使用(c语言)

       该消息中间件安装部署较简单,直接解压后拷贝license后tlq执行即可启动服务,主要相关配置及代码有点绕。远程java或c链接需要配置瘦客户端。

/*服务启停*/
tlq -cstart
tlq -c stop

/*创建队列控制单元*/
tlqqcu TEST_QCU -a add QCUStatus[1]

/*控制单元创建队列-L(本地队列)*/
tlqque TEST_QCU oneque -a add queueType[L]

/*客户端编译需要加上T_CLI参数*/
cc -g -DT_CLI -o c_test -I/app/XXincl c_test.c -L/app/XXlib -lapi 

/*自定义属性使用*/
char *properties;
Tlq_BeginProperties(&properties,足够的长度空间);
Tlq_SetStringProperty(properties,"标签","值");
Tlq_PutMsg(&gid,&qcuId,&uMsg,&uMsgOpt,properties,filename,&errstru);
Tlq_EndProperties(properties);

/*获取属性域*/
Tlq_GetStringProperty(qcuId.appdesc_info.buf,长度,"标签","值",sizeof("值"));

/*存在自定义属性获取文件名时,需要使用偏移量*/

Tlq_GetMsg(&gid,&qcuId,&uMsg,&uMsgOpt,&msgcontent,&errstru);
printf("filename = [%s]",msgcontent + uMsg.UserPropertyLen);

猜你喜欢

转载自blog.csdn.net/woailp___2005/article/details/84581200