Click here to Skip to main content
15,905,504 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

Some one enlighten me how can i achieve the below scenario.

I have a setup in MSMQ called Error Queue,if any message fails ,my code forward those message to Error queue.(for eg: i have 10 error queues)

I have windows form in the front end.I have button in the form and planning to add datagrid view.

whenever the button clicks it will populate all the error queues (eg : 10 queues) in the datagrid view.

I have no idea how to call those queues.

so far i find these code but am not sure am trying to find the right one
VB
Private RequestQ As MSMQQueue
Private WithEvents RequestEvent As MSMQEvent

Private Sub Form_Load()

Dim QI As New MSMQQueueInfo

QI.PathName = "MyServer\QueueName"
Set RequestQ = QI.Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE)

Set RequestEvent = New MSMQEvent
RequestQ.EnableNotification RequestEvent

End Sub

Sub RequestEvent_Arrived(ByVal Queue as Object, ByVal Cursor As Long)

Dim InQueue As MSMQQueue
Dim msg As MSMQMessage

Set InQueue = Queue
Set msg = InQueue.Receive(ReceiveTimeOut:=0)
If Not msg is Nothing Then
' Process the message
End If

InQueue.EnableNotification RequestEvent

End Sub

Thanks in Advance
Posted
Updated 2-Aug-11 18:24pm
v2
Comments
shan1395 3-Aug-11 1:24am    
Find this code in codeproject ,in a realistic situation its really tough to write a code with out a help from code project ;)

the below code


private void btnRcv_Click(object sender, System.EventArgs e)
{
System.Messaging.Message mes;
string m;

try
{
mes = mq.Receive(new TimeSpan(0, 0, 3));
mes.Formatter = new XmlMessageFormatter(new String[] {"System.String,mscorlib"});
m = mes.Body.ToString();
MsgBox.Items.Add(m.ToString());
}
catch
{
m = "No Message";
}
}

Okie what am trying to do here is,one single click i want to populate all the receive messages in to MsgBox.Items.Add(m.ToString());

If you see the code there is no loop used and am wondering why it is delete the queue ? once its retrieved.

Some one help me to write a for each loop for all the mewssages

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900