I have a WCF host that listen to a topic and process incoming messages. the code look this:
using (ServiceHost host = new ServiceHost(MessagingServiceType))
{
host.Open();
}
and the MessagingServiceType looks like that:
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class MessagingServiceType : IMessagingService
{
/// <summary>
/// service instance
/// </summary>
private readonly MessagingService service;
/// <summary>
/// Initializes a new instance of the <see cref="MessagingServiceType"/> class.
/// </summary>
public MessagingServiceType()
{
// creating new messaging service
service = new Singleton<MessagingService>();
}
/// <summary>
/// Sends the message.
/// </summary>
/// <param name="messageContent">Content of the message.</param>
public void SendMessage(string messageContent)
{
Message msg = Message.CreateMessage(MessageVersion.Default, string.Empty, messageContent);
service.MessageReceived(msg);
}
}
The issue is that when i'm running it on a seperate test application, everything works fine and all the service receive all messages. However, when i take the exact same code and put it into my REAL application, no messages are being received.
my question is very simple: how can i "debug" this service to see what's wrong with it and why messages are not being processed? is there anyway to compare between the two?
Thanks
Sure your service won't receive anything.... just look at your code:
using (ServiceHost host = new ServiceHost(MessagingServiceType))
{
host.Open();
}
What exactly happens when you reach the "}" ?? The object in the "using" clause - your ServiceHost
- will be freed / disposed of! ==> before you know it, your service is gone again.....
You need to do something like:
ServiceHost host = new ServiceHost(MessagingServiceType);
host.Open();
Console.ReadLine(); // wait for a ENTER press
host.Close();
No big debugging needed........ :-)