views:

337

answers:

2

Hi all,

this is a weird thing.

I created a simple SOAP based web service with WCF. When the 'SubmitTransaction' method is called, the transaction is being passed on to an application service. But if the application service is not available, it is being written to a MSMQ.

Like this:

public void SubmitTransaction(someTransaction)
{
  try
  {
     // pass transaction data to application
  }
  catch(SomeError)
  {
     // write to MSMQ
  }  
}

So when an error occures the transaction is written to the queue. Now, when using the MSMQ API directly in my WCF service, everything is fine. Each call takes a few milliseconds.

E.g.:

...
catch(SomeError)
{
  // write to MSMQ
  var messageQueue = new MessageQueue(queuePath);
  try
  {
    messageQueue.Send(accountingTransaction, MessageQueueTransactionType.Single);
  }
  finally
  {
    messageQueue.Close();
  }  
}

But since I want to use the message queue functionality at some other points of the system as well, I created a new assembly that takes care of the message queue writing.

Like:

...
catch(SomeError)
{
  // write to MSMQ
  var messageQueueService = new MessageQueueService();
  messageQueueService.WriteToQueue(accountingTransaction);
}

Now when using this setup, the web service is suddenly very slow. From the above-mentioned milliseconds, each call now takes up to 4 seconds. Only because the message queue stuff is encapsulated in a new assembly. The logic is exactly the same. Anyone knows what the problem could be...?

Thanks!

A: 

You have two new lines of code here:

var messageQueueService = new MessageQueueService();
messageQueueService.WriteToQueue(accountingTransaction);

Do you know which of the two is causing the problem? Perhaps add some logging, or profiling, or step through in a debugger to see which one seems slow.

1800 INFORMATION
I will try to measure the time. But these two lines are just a replacement for the message queue stuff I showed above. var messageQueueService = new MessageQueueService() does nothing but create a new instance.messageQueueService.WriteToQueue(accountingTransaction) does exactly the same as in the first example. If I copy paste the contents of this method in the service directly, everything is fast again. The only difference is, that it is in another assembly...
Chris
A: 

Ok, now I know. It has something to do with my logging setup (log4net). I'll have to check that first. Sorry for stealing your time..

Chris