Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2008, 05:17 AM
Authorized User
 
Join Date: Oct 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Receiving MSMQ Messages

Hi,

I have a separate windows application that sends a message to a message queue.

I then want a separate application to be able to check for messages in this queue. How do I do this check??

I am creating a service contract but not sure what I need to pass the message through it...

What do I need to add or change??? Thanks!!

Code:
[ServiceContract]
public interface Contract
{
[OperationContract(IsOneWay = true, Action = "*")]
void SubmitData(string eventMessage); // pass body msg and identifier
}
Here is my MSMQ Watcher Class...

Code:
public class MSMQWCFServiceWatcher : EventsContract
{
private ServiceHost serviceHost = null;

// Event fired when a watcher finds an order
public static event EventHandler DataFound;

public void WatchForData(string server)
{
Uri serviceUri = new Uri("msmq.formatname:DIRECT=OS:" + server);

MsmqIntegrationBinding serviceBinding = new MsmqIntegrationBinding();

serviceBinding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
serviceBinding.Security.Transport.MsmqProtectionLevel = System.Net.Security.ProtectionLevel.None;
serviceBinding.SerializationFormat = MsmqMessageSerializationFormat.Binary;
serviceHost = new ServiceHost(typeof(MSMQWCFServiceWatcher));
serviceHost.AddServiceEndpoint(typeof(EventsContract), serviceBinding, serviceUri);
serviceHost.Open();
}

public void StopWatchingForData()
{
if (serviceHost != null)
{
serviceHost.Close();
}
}

// Fires the OrderFound event
protected void OnDataFound(EventData data)
{
if (DataFound != null)
{
DataFound(this, new DataFoundEventArgs(data));
}
}

#region EventsContract Members
public void SubmitData(string eventMessage)
{
throw new NotImplementedException();
}
#endregion
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create memory structure for receiving messages remya1000 .NET Framework 1.x 3 March 6th, 2008 04:30 PM
Urgent.Recover MSMQ messages after system reboot veebhudhi.chandramouli Windows Workflow 0 October 23rd, 2007 01:47 AM
MSMQ with FormatName tyh79 VB Components 1 September 26th, 2007 02:44 AM
MSMQ Triggers Tofu General .NET 0 September 8th, 2004 08:52 PM
Configuring MSMQ mchu7aa3 VB Components 0 January 26th, 2004 01:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.