主题
发布队列文本消息 - MessageQueuePublishText
函数简介
发布文本消息到指定队列。
接口名称
MessageQueuePublishTextDLL调用
c
int32_t MessageQueuePublishText(int64_t instance, int64_t producer, char* body);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLA 实例句柄。 |
| producer | 长整数型 | 发布端句柄。 |
| body | 字符串 | 文本内容。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue");
if (producer > 0) {
int ret = ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose(producer);
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
long producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue");
if (producer > 0)
{
int ret = ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose(producer);
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue")
if producer > 0:
ret = ola.MessageQueuePublishText(producer, "hello ola")
ola.MessageQueueClose(producer)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue");
if (producer > 0) {
ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose(producer);
}cpp
var ola = com("OlaPlug.OlaSoft")
var producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue")
if(producer > 0) {
ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose(producer)
}vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue")
If producer > 0 Then
ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose(producer)
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
producer = ola.MessageQueueDeclare (1, 1, "127.0.0.1", 18890, "task_queue")
.如果真 (producer > 0)
ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose (producer)
.如果真结束aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue");
if(producer > 0){
ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose(producer);
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue")
如果真 (producer > 0)
{
ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose(producer)
}cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue");
if (producer > 0) {
ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose(producer);
}原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long producer = MessageQueueDeclare(instance, 1, 1, "127.0.0.1", 18890, "task_queue");
if (producer > 0) {
int ret = MessageQueuePublishText(instance, producer, "hello ola");
MessageQueueClose(instance, producer);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long MessageQueueDeclare(long ola, int type, int connect_type, string ip, int port, string queue_name);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int MessageQueueClose(long ola, long producer);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int MessageQueuePublishText(long ola, long producer, string body);
long instance = CreateCOLAPlugInterFace();
long producer = MessageQueueDeclare(instance, 1, 1, "127.0.0.1", 18890, "task_queue");
if (producer > 0) {
int ret = MessageQueuePublishText(instance, producer, "hello ola");
MessageQueueClose(instance, producer);
}python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
producer = ola.MessageQueueDeclare(instance, 1, 1, b"127.0.0.1", 18890, b"task_queue")
if producer:
int ret = ola.MessageQueuePublishText(instance, producer, "hello ola");
ola.MessageQueueClose(instance, producer)返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 大于等于 0 为投递数量;<0 为错误码。 |
