主题
关闭消息队列发布端 - MessageQueueClose
函数简介
关闭发布端句柄并释放资源。
接口名称
MessageQueueCloseDLL调用
c
int32_t MessageQueueClose(int64_t instance, int64_t producer);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLA 实例句柄。 |
| producer | 长整数型 | 发布端句柄(由 MessageQueueDeclare 返回)。 |
示例
SDK 调用
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); // 必须关闭
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)
{
ola.MessageQueuePublishText(producer, "hello ola");
ola.MessageQueueClose(producer); // 必须关闭
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:
ola.MessageQueuePublishText(producer, "hello ola")
ola.MessageQueueClose(producer)
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.MessageQueueClose(producer);
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.MessageQueueClose(producer);
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.MessageQueueClose(producer);
ola.MessageQueueClose(producer)
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
producer = ola.MessageQueueDeclare (1, 1, "127.0.0.1", 18890, "task_queue")
.如果真 (producer > 0)
ola.MessageQueueClose(producer);
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.MessageQueueClose(producer);
ola.MessageQueueClose(producer);
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 producer = ola.MessageQueueDeclare(1, 1, "127.0.0.1", 18890, "task_queue")
如果真 (producer > 0)
{
ola.MessageQueueClose(producer);
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.MessageQueueClose(producer);
ola.MessageQueueClose(producer);
}原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long producer = MessageQueueDeclare(instance, 1, 1, "127.0.0.1", 18890, "task_queue");
if (producer > 0) {
MessageQueuePublishText(instance, producer, "hello ola");
MessageQueueClose(instance, producer);
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) {
MessageQueuePublishText(instance, producer, "hello ola");
MessageQueueClose(instance, producer);
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:
ola.MessageQueuePublishText(instance, producer, "hello ola");
ola.MessageQueueClose(instance, producer);
ola.MessageQueueClose(instance, producer)返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 0 成功;<0 错误码。 |
