title: How sql dependency works for passing data back & forth
body: <p>1) i like to know how sql server establish a channel between client &amp; db. i guess there must be a channel and that why sql server can send notification to client through that channel. please discuss this issue in detail. because i saw many article on sql dependency but every body gives the code but no body explaining how it works in details.
  What is Service Broker?</p>
  
  <p>Service Broker architecture allows you to build loosely coupled SQL Server instances so that the instances talk with each other using normal form of messaging. Service Broker uses TCP/IP to transmit messages form the network and hence allows encrypted messaging. It is both for applications which use SQL Server instance or for applications that distribute the work into more than one SQL server instance. Service Broker allows to use Queue to hold messages and hence the messages are processed one by one without the caller to wait to receive the message.</p>
  
  <p>1) i like to know service broker pass the message always in encrypted format?</p>
  
  <p>2) Service Broker allows to use Queue to hold messages. what is the name of that queue used by service broker. how can i see what is stored in that queue?</p>
  
  <p>3) i saw many people create queue but did not mention why they created? they also did not use that queue in their code. here is one url &amp; sample code</p>
  
  <p><strong><a href="http://www.dreamincode.net/forums/topic/156991-using-sqldependency-to-monitor-sql-database-changes/" rel="noreferrer">http://www.dreamincode.net/forums/topic/156991-using-sqldependency-to-monitor-sql-database-changes/</a></strong></p>
  
  <pre><code>CREATE QUEUE NameChangeQueue;
  CREATE SERVICE NameChangeService ON QUEUE NameChangeQueue ([http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification]);
  
  GRANT SUBSCRIBE QUERY NOTIFICATIONS TO YourUserName;
  
  ALTER DATABASE YourDatabaseName SET ENABLE_BROKER;
  </code></pre>
  
  <p>they never use <code>NameChangeQueue</code> queue why ?? how do i know who will use this queue?</p>
  
  <p>4) even i saw people create role but never know why role would be require in this case?</p>
  
  <p>so please discuss ALL my points in detail because i need to understand all the points. thanks</p>