Windows Communication Framework (Vista Series)

What are Dead letter queues?

The main use of queue is that you do not need the client and the server running at one time. So it’s possible that a message will lie in queue for long time until the server or client picks it up. But there are scenarios where a message is of no use after a certain time. So these kinds of messages if not delivered within that time span it should not be sent to the user.

Below is the config snippet which defines for how much time the message should be in queue.

<bindings>

<netMsmqBinding>

<binding

deadLetterQueue=”Custom”

customDeadLetterQueue=”net.msmq://localhost/private/ ServiceModelSamples”

timeToLive=”00:00:02″/> </netMsmqBinding>

More >

What are Volatile queues?

There are scenarios in the project when you want the message to deliver in proper time. The timely delivery of message is more important than losing message. In these scenarios Volatile queues are used.

Below is the code snippet which shows how to configure Volatile queues. You can see the bindingConfiguration property set to VolatileBinding. This code will assure that message will deliver on time but there is a possibility that you can lose data.

<appSettings>

<!– use appSetting to configure MSMQ queue name –>

<add key=”queueName” value=”.\private$\ServiceModelSamplesVolatile” /> </appSettings>

<system.serviceModel> <services>

<service name=”Samples.StockTickerServ”

behaviorConfiguration=”CalculatorServiceBehavior”>

<!– Define NetMsmqEndpoint –>

<endpoint address=”net.msmq://localhost/private/ServiceModelSamplesVolatile” binding=”netMsmqBinding”

bindingConfiguration=”volatileBinding”

contract=”Samples.InterfaceStockTicker” />

</service>

</services>

<bindings>

<netMsmqBinding>

<binding durable=”false”

exactlyOnce=”false”/> </netMsmqBinding> </bindings>

</system.serviceModel>

More >

Can we have two way communications in MSMQ?

Yes

Can we do transactions using MSMQ?

While doing MSMQ there can be scenarios in the project where we would like either all the messages are uploaded to MSMQ or all messages read from MSMQ. After any message is read from MSMQ it’s deleted from the queue. So some times this can be critical if there are exceptions in reading or uploading messages. As said before WCF transaction can be applied to database as well as other operations like MSMQ. So let’s try to understand the same by doing a small sample.

Below is a numbered code snippet of MSMQ transactions.

1 – Sendmessage is the exposed method in More >

What different transaction isolation levels provided in WCF?

Transactions assure that a group of related activity occurs as a single atomic unit. In simple words, every activity in the unit must either all succeed or all should fail. WCF provides a central transaction system that can be used to handle transaction operations. One of the things WCF provides is a single unified transaction system for both database and non-database activity. For instance BeginTrans and CommitTrans are database related syntaxes but we can not use the same for other activities like if we want to upload all message in a single transaction to a MSMQ server. One thing to More >

How can we use MSMQ bindings in WCF?

First let’s understand why MSMQ came in to picture and then rest will follow. Let’s take a scenario where your client needs to upload data to a central server. If everything will work fine and if server is available 24 hours to client then there are no issues. In case the server is not available the clients will fail and the data will not be delivered. There’s where MSMQ comes in to picture. It eliminates the need of persistent connection to a server. So what you do is deploy a MSMQ server and let the clients post message to this More >

How can we host a service on two different protocols on a single server?

Let’s first understand what this question actually means. Let’s say we have made a service and we want to host this service using HTTP as well as TCP. You must be wondering why to ever host services on two different types of protocol. When we host a service it’s consumed by multiple types of client and it’s very much possible that they have own protocol of communication. A good service has the capability to downgrade or upgrade its protocol according the client who is consuming him.

Let’s do a small sample in which we will host the ServiceGetCost on TCP and More >

Can you explain duplex contracts in WCF?

In duplex contracts when client initiates an operation the server service provides a reference call back Uri back to the client. So the client initiates a call using the proxy class and when server finishes its work it notifies the client using the callback channel. This is called as duplex messaging in WCF. If you remember in the previous question we had now way to know when the server finished its task.

What is one way operation?

IsOneWay equal to true ensures that the client does not have to wait for the response. So methods marked by IsOneWay to true should always return void. In this the caller does not get anything in return so it is called as one-way communication.

In order to understand one way implementation in WCF lets make a code walkthrough of a sample.

What are different bindings supported by WCF?

WCF includes predefined bindings. They cover most of bindings widely needed in day to day application. But just incase you find that you need to define something custom WCF does not stop you. So let’s try to understand what each binding provides.

BasicHttpBinding: – This binding is used when we need to use SOAP over HTTP. This binding can also be configured to be used as HTTPS. It can be also configured to send data in plain text or in optimized form like MTOM.

Note: – MTOM is discussed in on the questions in this chapter.

WsHttpBinding: – It is same like BasicHttpBinding. More >