mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-09 13:16:05 +00:00
Update msmq.js
This commit is contained in:
parent
c1aee7fb15
commit
c0f8159735
58
lib/msmq.js
58
lib/msmq.js
|
@ -7,45 +7,45 @@
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var MSMQObject = function(queueName) {
|
var MSMQObject = function(queueName) {
|
||||||
var MQ_SEND_ACCESS = 2;
|
var MQ_SEND_ACCESS = 2;
|
||||||
var MQ_DENY_NONE = 0;
|
var MQ_DENY_NONE = 0;
|
||||||
var MQ_RECEIVE_ACCESS = 1;
|
var MQ_RECEIVE_ACCESS = 1;
|
||||||
|
|
||||||
var MQ_NO_TRANSACTION = 0;
|
var MQ_NO_TRANSACTION = 0;
|
||||||
var MQ_MTS_TRANSACTION = 1;
|
var MQ_MTS_TRANSACTION = 1;
|
||||||
var MQ_SINGLE_MESSAGE = 3;
|
var MQ_SINGLE_MESSAGE = 3;
|
||||||
|
|
||||||
this.machineName = "localhost";
|
this.machineName = "localhost";
|
||||||
this.queueName = queueName;
|
this.queueName = queueName;
|
||||||
|
|
||||||
this.queueInfo = null;
|
this.queueInfo = null;
|
||||||
this.queue = null;
|
this.queue = null;
|
||||||
|
|
||||||
this.create = function() {
|
this.create = function() {
|
||||||
try {
|
try {
|
||||||
this.queueInfo = CreateObject("MSMQ.MSMQQueueInfo");
|
this.queueInfo = CreateObject("MSMQ.MSMQQueueInfo");
|
||||||
this.queueInfo.PathName = ".\\private$\\" + this.queueName;
|
this.queueInfo.PathName = ".\\private$\\" + this.queueName;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("MSMQObject.create() ->", e.message);
|
console.error("MSMQObject.create() ->", e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.open = function() {
|
this.open = function() {
|
||||||
this.queue = this.queueInfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE);
|
this.queue = this.queueInfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For example: .send("Sample Body", "LabelXX");
|
// For example: .send("Sample Body", "LabelXX");
|
||||||
this.send = function(body, label) {
|
this.send = function(body, label) {
|
||||||
var mqmsg = CreateObject("MSMQ.MSMQMessage");
|
var mqmsg = CreateObject("MSMQ.MSMQMessage");
|
||||||
mqmsg.Body = body
|
mqmsg.Body = body
|
||||||
mqmsg.Label = label
|
mqmsg.Label = label
|
||||||
mqmsg.Send(this.queue);
|
mqmsg.Send(this.queue);
|
||||||
mqmsg = null;
|
mqmsg = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.recv = function() {
|
this.recv = function() {
|
||||||
return this.queue.Receive(MQ_NO_TRANSACTION, false, true, 20000, false);
|
return this.queue.Receive(MQ_NO_TRANSACTION, false, true, 20000, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.create();
|
this.create();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user