- Details
- Written by: Stanko Milosev
- Category: MSMQ
- Hits: 5508
If you are using my application for MS MQ to deploy on another computer, to send messages you will need to do following:
1. Log on as the local administrator for the client computer, and then open Component Services. Click Start, point to All Programs, point to Administrative Tools, and then click Component Services.
2. In the console tree, click Component Services, click Computers, click My Computer, and then click DCOM config.
3. Right-click MSMQ, and then click Properties.
4. On the Location tab, select Run application on the following computer, and type the name of the Message Queuing server. Save the settings, and restart the computer
Taken from here.
- Details
- Written by: Stanko Milosev
- Category: MSMQ
- Hits: 7175
Here are few links, which I found interesting about MSMQ:
- Details
- Written by: Stanko Milosev
- Category: MSMQ
- Hits: 7540
First of all you have to install MSMQ. You will do it through Control panel->Add remove programs->Add/Remove Windows components.
Second you will need to access MSMQ for managing, you can do it through Computer Management->Services and Applications->Message Queuing
Now, create one queue, for example "test", under Private Queues.
Then, send a message through Delphi :)
Here is the code:
For sending messages:
procedure TForm3.Button1Click(Sender: TObject);
var
queuename, subject: string;
data: olevariant;
queueinfo, QueueInfosObj: IMSMQQueueInfo;
queue, QueryObj: IMSMQQueue;
msg: IMSMQMessage;
tr: OLEVariant;
begin
{ STANKO is name of my computer, test is name of queue}
queuename := 'Direct=OS:STANKOprivate$ est';
subject := Edit1.text;
data := Memo1.text;
try
queueinfo := CreateCOMObject (CLASS_MSMQQueueInfo) as IMSMQQueueInfo;
queueinfo.FormatName := queuename;
queue := queueinfo.Open (MQ_SEND_ACCESS, MQ_DENY_NONE);
if queue.IsOpen 1 then
statusbar1.Panels[0].Text := 'I can not get access to queue!'
else
begin
try
msg := CreateCOMObject (CLASS_MSMQMessage) as IMSMQMessage;
msg.label_ := subject;
msg.body := data;
tr := MQ_NO_TRANSACTION;
msg.Send (queue, tr);
statusbar1.Panels[0].Text := 'Sent!'
finally
queue.close;
end;
end;
except
on e: exception do showmessage (e.message);
end;
end;
Now, for receiving messages:
procedure TForm3.Button2Click(Sender: TObject);
var
queuename: string;
data: olevariant;
queueinfo: IMSMQQueueInfo;
queue: IMSMQQueue;
msg: IMSMQMessage;
tr, wdq, wb, rt: OLEVariant;
begin
queuename:= 'Direct=OS:STANKOprivate$ est';
try
queueinfo := CreateCOMObject (CLASS_MSMQQueueInfo) as IMSMQQueueInfo;
queueinfo.FormatName := queuename;
queue := queueinfo.Open (MQ_RECEIVE_ACCESS, MQ_DENY_NONE);
if queue.IsOpen 1 then
statusbar1.Panels[0].Text := 'I can not get access to queue!'
else
begin
try
tr := MQ_SINGLE_MESSAGE;
wdq := False;
wb := True;
rt := 1000;
msg := queue.Receive (tr, wdq, wb, rt);
if msg nil then
begin
data := msg.body;
statusbar1.Panels[0].Text := 'Received!';
memo2.text:=data;
edit2.text:=msg.label_;
end
else
statusbar1.Panels[0].Text := 'No messages'
finally
queue.close;
end;
end;
except
on e: exception do showmessage (e.message);
end;
end;
Code taken from here. It is on Slovenian, but I coudn't find it on English.
Here you can download source code created in D2007, and here is the exe file.
- Details
- Written by: Stanko Milosev
- Category: Oracle
- Hits: 8035