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
}