So I'm trying to configure my client code to send messages to MSMQ queue. I followed the steps described in here: https://msdn.microsoft.com/en-us/library/ms789008(v=vs.100).aspx?cs-save-lang=1&cs-lang=csharp and my client code looks as below:
class Program
{
static void Main(string[] args)
{
var binding = new MsmqIntegrationBinding("MyMessagesBinding");
var address = new EndpointAddress(@"msmq.formatname:DIRECT = OS:.\private$\MyMessages");
var channelFactory = new ChannelFactory<IDataRelayService>(binding, address);
var channel = channelFactory.CreateChannel();
while (true)
{
var message = new MyMessage
{
Content = "this is content!!!",
Id = "random uuid"
};
var msmqWrapper = new MsmqMessage<MyMessage>(message)
{
Priority = MessagePriority.Highest
};
channel.PassMessage(msmqWrapper);
Console.WriteLine("message sent");
Console.ReadLine();
}
}
}
App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<client>
<endpoint name="MyResponseEndpoint"
address="msmq.formatname:DIRECT=OS:.\private$\MyMessages"
binding="msmqIntegrationBinding"
bindingConfiguration="MyMessagesBinding"
contract="Client.IDataRelayService">
</endpoint>
</client>
<bindings>
<msmqIntegrationBinding>
<binding name="MyMessagesBinding">
<security mode="None" />
</binding>
</msmqIntegrationBinding>
</bindings>
</system.serviceModel>
</configuration>
IDataRelayService.cs:
[ServiceContract]
public interface IDataRelayService
{
[OperationContract(IsOneWay = true, Action = "*")]
void PassMessage(MsmqMessage<MyMessage> message);
}
IDataRelayServiceChannel.cs:
public interface IDataRelayServiceChannel : IDataRelayService, System.ServiceModel.IClientChannel
{
}
It compiles and runs with no problem, but when I open up evet viewer there are no events logged for MSMQ. If I open computer management tool to view queues it shows 0 messages in my queue. What am I doing wrong here?
EDIT:
I enabled event tracing for MSMQ and here's what event viewer is showing me: