<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>Clemens Vasters - Azure</title>
    <link>http://vasters.com/clemensv/</link>
    <description>Cloud Development and Alien Abductions</description>
    <language>en-us</language>
    <copyright>Clemens Vasters</copyright>
    <lastBuildDate>Tue, 15 Jan 2013 18:56:36 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.7067.0</generator>
    <managingEditor>cvasters@guhhome.com</managingEditor>
    <webMaster>cvasters@guhhome.com</webMaster>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=4718bf97-cc2e-46ba-854a-f4a1d93fb2a9</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,4718bf97-cc2e-46ba-854a-f4a1d93fb2a9.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,4718bf97-cc2e-46ba-854a-f4a1d93fb2a9.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=4718bf97-cc2e-46ba-854a-f4a1d93fb2a9</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://en.wikipedia.org/wiki/File:ESB.png">
            <img style="BORDER-LEFT-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px; BACKGROUND-IMAGE: none; BORDER-BOTTOM-WIDTH: 0px; FLOAT: right; PADDING-TOP: 0px; PADDING-LEFT: 0px; MARGIN: 2px 0px 2px 5px; DISPLAY: inline; PADDING-RIGHT: 0px; BORDER-TOP-WIDTH: 0px" border="0" alt="File:ESB.png" align="right" src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/80/ESB.png/751px-ESB.png" width="300" height="240" />
          </a>The
basic idea of the Enterprise Service Bus paints a wonderful picture of a harmonious
coexistence, integration, and collaboration of software services. Services for a particular
general cause are built or procured once and reused across the Enterprise by ways
of publishing them and their capabilities in a corporate services repository from
where they can be discovered. The repository holds contracts and policy that allows
dynamically generating functional adapters to integrate with services. Collaboration
and communication is virtualized through an intermediary layer that knows how to translate
messages from and to any other service hooked into the ESB like a babel fish in the
Hitchhiker’s Guide to the Galaxy. The ESB is a bus, meaning it aspires to be a smart,
virtualizing, mediating, orchestrating messaging substrate permeating the Enterprise,
providing uniform and mediated access anytime and anywhere throughout today’s global
Enterprise. That idea is so beautiful, it rivals My Little Pony. Sadly, it’s also
about as realistic. We tried regardless.
</p>
        <p>
As with many utopian ideas, before we can get to the pure ideal of an ESB, there’s
some less ideal and usually fairly ugly phase involved where non-conformant services
are made conformant. Until they are turned into WS-* services, any CICS transaction
and SAP BAPI is fronted with a translator and as that skinning renovation takes place,
there’s also some optimization around message flow, meaning messages get batched or
de-batched, enriched or reduced. In that phase, there was also learning of the value
and lure of the benefits of central control. SOA Governance is an interesting idea
to get customers drunk on. That ultimately led to cheating on the ‘B’. When you look
around and look at products proudly carrying the moniker ‘Enterprise Service Bus’
you will see hubs. In practice, the B in ESB is mostly just a lie. Some vendors sell
ESB servers, some even sell ESB appliances. If you need to walk to a central place
to talk to anyone, it’s a hub. Not a bus. 
</p>
        <p>
Yet, the bus does exist. The IP network is the bus. It turns out to suit us well on
the Internet. Mind that I’m explicitly talking about “IP network” and not “Web” as
I do believe that there are very many useful protocols beyond HTTP. The Web is obviously
the banner example for a successful implementation of services on the IP network that
does just fine without any form of centralized services other than the highly redundant
domain name system. 
</p>
        <p>
Centralized control over services does not scale in any dimension. Intentionally creating
a bottleneck through a centrally controlling committee of ESB machines, however far
scaled out, is not a winning proposition in a time where every potential or actual
customer carries a powerful computer in their pockets allowing to initiate ad-hoc
transactions at any time and from anywhere and where we see vehicles, machines and
devices increasingly spew out telemetry and accept remote control commands. Central
control and policy driven governance over all services in an Enterprise also kills
all agility and reduces the ability to adapt services to changing needs because governance
invariably implies process and certification. Five-year plan, anyone? 
</p>
        <p>
If the ESB architecture ideal weren’t a failure already, the competitive pressure
to adopt direct digital interaction with customers via Web and Apps, and therefore
scale up not to the scale of the enterprise, but to scale up to the scale of the enterprise’s
customer base will seal its collapse. 
</p>
        <h3>Service Orientation
</h3>
        <p>
While the ESB as a concept permeating the entire Enterprise is dead, the related notion
of Service Orientation is thriving even though the <a href="http://msdn.microsoft.com/en-us/library/ff648318.aspx#SOATenets">four
tenets of SOA</a> are rarely mentioned anymore. HTTP-based services on the Web embrace
explicit message passing. They mostly do so over the baseline application contract
and negotiated payloads that the HTTP specification provides for. In the case of SOAP
or XML-RPC, they are using abstractions on top that have their own application protocol
semantics. Services are clearly understood as units of management, deployment, and
versioning and that understanding is codified in most platform-as-a-service offerings. 
</p>
        <p>
That said, while explicit boundaries, autonomy, and contract sharing have been clearly
established, the notion of policy-driven compatibility – arguably a political addition
to the list to motivate WS-Policy as the time – has generally been replaced by something
even more powerful: Code. JavaScript code to be more precise. Instead of trying to
tell a generic client how to adapt to service settings by ways of giving it a complex
document explaining what switches to turn, clients now get code that turns the switches
outright. The successful alternative is to simply provide no choice. There’s one way
to gain access authorization for a service, period. The “policy” is in the docs. 
</p>
        <p>
The REST architecture model is service oriented – and I am not meaning to imply that
it is so because of any particular influence. The foundational principles were becoming
common sense around the time when these terms were coined and as the notion of broadly
interoperable programmable services started to gain traction in the late 1990s – the
subsequent grand dissent that arose was around whether pure HTTP was sufficient to
build these services, or whether the ambitious multi-protocol abstraction for WS-*
would be needed. I think it’s fairly easy to declare the winner there. 
</p>
        <h3>Federated Autonomous Services
</h3>
        <p>
          <a href="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/Utopia-ESB_87DD/image_2.png">
            <img title="image" style="BORDER-LEFT-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px; BACKGROUND-IMAGE: none; BORDER-BOTTOM-WIDTH: 0px; FLOAT: right; PADDING-TOP: 0px; PADDING-LEFT: 0px; DISPLAY: inline; PADDING-RIGHT: 0px; BORDER-TOP-WIDTH: 0px" border="0" alt="image" align="right" src="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/Utopia-ESB_87DD/image_thumb.png" width="240" height="213" />
          </a>Windows
Azure, to name a system that would surely be one to fit the kind of solution complexity
that ESBs were aimed at, is a very large distributed system with a significant number
of independent multi-tenant services and deployments that are spread across many data
centers. In addition to the publicly exposed capabilities, there are quite a number
of “invisible” services for provisioning, usage tracking and analysis, billing, diagnostics,
deployment, and other purposes.  Some components of these internal services integrate
with external providers. Windows Azure doesn’t use an ESB. Windows Azure is a federation
of autonomous services.
</p>
        <p>
The basic shape of each of these services is effectively identical and that’s not
owing, at least not to my knowledge, to any central architectural directive even though
the services that shipped after the initial wave certainly took a good look at the
patterns that emerged. Practically all services have a gateway whose purpose it is
to handle and dispatch and sometimes preprocess incoming network requests or sessions
and a backend that ultimately fulfills the requests. The services interact through
public IP space, meaning that if Service Bus wants to talk to its SQL Database backend
it is using a public IP address and not some private IP. The Internet is the bus.
The backend and its structure is entirely a private implementation matter.  It
could be a single role or many roles. 
</p>
        <p>
Any gateway’s job is to provide network request management, which includes establishing
and maintaining sessions, session security and authorization, API versioning where
multiple variants of the same API are often provided in parallel, usage tracking,
defense mechanisms, and diagnostics for its areas of responsibility. This functionality
is specific and inherent to the service. And it’s not all HTTP. SQL database has a
gateway that speaks the Tabular Data Stream protocol (TDS) over TCP, for instance,
and Service Bus has a gateway that speaks AMQP and the binary proprietary Relay and
Messaging protocols.
</p>
        <p>
Governance and diagnostics doesn’t work by putting a man in the middle and watching
the traffic coming by, which is akin to trying the tell whether a business is healthy
by counting the trucks going to their warehouse. Instead we are integrating the data
feeds that come out of the respective services and are generated fully knowing the
internal state, and concentrate these data streams, like the billing stream, in yet
other services that are also autonomous and have their own gateways. All these services
interact and integrate even though they’re built by a composite team far exceeding
the scale of most Enterprise’s largest projects, and while teams run on separate schedules
where deployments into the overall system happen multiple times daily. It works because
each service owns its gateway, is explicit about its versioning strategy, and has
a very clear mandate to honor published contracts, which includes explicit regression
testing. It would be unfathomable to maintain a system of this scale through a centrally
governed switchboard service like an ESB.
</p>
        <p>
Well, where does that leave “ESB technologies” like BizTalk Server? The answer is
simply that they’re being used for what they’re commonly used for in practice. As
a gateway technology. Once a service in such a federation would have to adhere to
a particular industry standard for commerce, for instance if it would have to understand
EDIFACT or X.12 messages sent to it, the Gateway would employ an appropriate and proven
implementation and thus likely rely on BizTalk if implemented on the Microsoft stack.
If a service would have to speak to an external service for which it would have to
build EDI exchanges, it would likely be very cost effective to also use BizTalk as
the appropriate tool for that outbound integration. Likewise, if data would have to
be extracted from backend-internal message traffic for tracking purposes and BizTalk’s
BAM capabilities would be a fit, it might be a reasonable component to use for that.
If there’s a long running process around exchanging electronic documents, BizTalk
Orchestration might be appropriate, if there’s a document exchange involving humans
then SharePoint and/or Workflow would be a good candidate from the toolset. 
</p>
        <p>
For most services, the key gateway technology of choice is HTTP using frameworks like
ASP.NET, Web API, probably paired with IIS features like application request routing
and the gateway is largely stateless.
</p>
        <p>
In this context, <em>Windows Azure Service Bus</em> is, in fact, a technology choice
to implement application gateways. A Service Bus namespace thus forms a message bus
for “a service” and not for “all services”. It’s as scoped to a service or a set of
related services as an IIS site is usually scoped to one or a few related services.
The Relay is a way to place a gateway into the cloud for services where the backend
resides outside of the cloud environment and it also allows for multiple systems,
e.g. branch systems, to be federated into a single gateway to be addressed from other
systems and thus form a gateway of gateways. The messaging capabilities with Queues
and Pub/Sub Topics provide a way for inbound traffic to be authorized and queued up
on behalf of the service, with Service Bus acting as the mediator and first line of
defense and where a service will never get a message from the outside world unless
it explicitly fetches it from Service Bus. The service can’t be overstressed and it
can’t be accessed except through sending it a message. 
</p>
        <p>
The next logical step on that journey is to provide federation capabilities with reliable
handoff of message between services, meaning that you can safely enqueue a message
within a service and then have Service Bus replicate that message (or one copy in
the case of pub/sub) over to another service’s Gateway – across namespaces and across
datacenters or your own sites, and using the open AMQP protocol. You can do that today
with a few lines of code, but this will become inherent to the system later this year. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=4718bf97-cc2e-46ba-854a-f4a1d93fb2a9" />
      </body>
      <title>Utopia ESB</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,4718bf97-cc2e-46ba-854a-f4a1d93fb2a9.aspx</guid>
      <link>http://vasters.com/clemensv/2013/01/15/Utopia+ESB.aspx</link>
      <pubDate>Tue, 15 Jan 2013 18:56:36 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://en.wikipedia.org/wiki/File:ESB.png"&gt;&lt;img style="BORDER-LEFT-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px; BACKGROUND-IMAGE: none; BORDER-BOTTOM-WIDTH: 0px; FLOAT: right; PADDING-TOP: 0px; PADDING-LEFT: 0px; MARGIN: 2px 0px 2px 5px; DISPLAY: inline; PADDING-RIGHT: 0px; BORDER-TOP-WIDTH: 0px" border=0 alt=File:ESB.png align=right src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/80/ESB.png/751px-ESB.png" width=300 height=240&gt;&lt;/a&gt;The
basic idea of the Enterprise Service Bus paints a wonderful picture of a harmonious
coexistence, integration, and collaboration of software services. Services for a particular
general cause are built or procured once and reused across the Enterprise by ways
of publishing them and their capabilities in a corporate services repository from
where they can be discovered. The repository holds contracts and policy that allows
dynamically generating functional adapters to integrate with services. Collaboration
and communication is virtualized through an intermediary layer that knows how to translate
messages from and to any other service hooked into the ESB like a babel fish in the
Hitchhiker’s Guide to the Galaxy. The ESB is a bus, meaning it aspires to be a smart,
virtualizing, mediating, orchestrating messaging substrate permeating the Enterprise,
providing uniform and mediated access anytime and anywhere throughout today’s global
Enterprise. That idea is so beautiful, it rivals My Little Pony. Sadly, it’s also
about as realistic. We tried regardless.
&lt;/p&gt;
&lt;p&gt;
As with many utopian ideas, before we can get to the pure ideal of an ESB, there’s
some less ideal and usually fairly ugly phase involved where non-conformant services
are made conformant. Until they are turned into WS-* services, any CICS transaction
and SAP BAPI is fronted with a translator and as that skinning renovation takes place,
there’s also some optimization around message flow, meaning messages get batched or
de-batched, enriched or reduced. In that phase, there was also learning of the value
and lure of the benefits of central control. SOA Governance is an interesting idea
to get customers drunk on. That ultimately led to cheating on the ‘B’. When you look
around and look at products proudly carrying the moniker ‘Enterprise Service Bus’
you will see hubs. In practice, the B in ESB is mostly just a lie. Some vendors sell
ESB servers, some even sell ESB appliances. If you need to walk to a central place
to talk to anyone, it’s a hub. Not a bus. 
&lt;/p&gt;
&lt;p&gt;
Yet, the bus does exist. The IP network is the bus. It turns out to suit us well on
the Internet. Mind that I’m explicitly talking about “IP network” and not “Web” as
I do believe that there are very many useful protocols beyond HTTP. The Web is obviously
the banner example for a successful implementation of services on the IP network that
does just fine without any form of centralized services other than the highly redundant
domain name system. 
&lt;/p&gt;
&lt;p&gt;
Centralized control over services does not scale in any dimension. Intentionally creating
a bottleneck through a centrally controlling committee of ESB machines, however far
scaled out, is not a winning proposition in a time where every potential or actual
customer carries a powerful computer in their pockets allowing to initiate ad-hoc
transactions at any time and from anywhere and where we see vehicles, machines and
devices increasingly spew out telemetry and accept remote control commands. Central
control and policy driven governance over all services in an Enterprise also kills
all agility and reduces the ability to adapt services to changing needs because governance
invariably implies process and certification. Five-year plan, anyone? 
&lt;/p&gt;
&lt;p&gt;
If the ESB architecture ideal weren’t a failure already, the competitive pressure
to adopt direct digital interaction with customers via Web and Apps, and therefore
scale up not to the scale of the enterprise, but to scale up to the scale of the enterprise’s
customer base will seal its collapse. 
&lt;/p&gt;
&lt;h3&gt;Service Orientation
&lt;/h3&gt;
&lt;p&gt;
While the ESB as a concept permeating the entire Enterprise is dead, the related notion
of Service Orientation is thriving even though the &lt;a href="http://msdn.microsoft.com/en-us/library/ff648318.aspx#SOATenets"&gt;four
tenets of SOA&lt;/a&gt; are rarely mentioned anymore. HTTP-based services on the Web embrace
explicit message passing. They mostly do so over the baseline application contract
and negotiated payloads that the HTTP specification provides for. In the case of SOAP
or XML-RPC, they are using abstractions on top that have their own application protocol
semantics. Services are clearly understood as units of management, deployment, and
versioning and that understanding is codified in most platform-as-a-service offerings. 
&lt;/p&gt;
&lt;p&gt;
That said, while explicit boundaries, autonomy, and contract sharing have been clearly
established, the notion of policy-driven compatibility – arguably a political addition
to the list to motivate WS-Policy as the time – has generally been replaced by something
even more powerful: Code. JavaScript code to be more precise. Instead of trying to
tell a generic client how to adapt to service settings by ways of giving it a complex
document explaining what switches to turn, clients now get code that turns the switches
outright. The successful alternative is to simply provide no choice. There’s one way
to gain access authorization for a service, period. The “policy” is in the docs. 
&lt;/p&gt;
&lt;p&gt;
The REST architecture model is service oriented – and I am not meaning to imply that
it is so because of any particular influence. The foundational principles were becoming
common sense around the time when these terms were coined and as the notion of broadly
interoperable programmable services started to gain traction in the late 1990s – the
subsequent grand dissent that arose was around whether pure HTTP was sufficient to
build these services, or whether the ambitious multi-protocol abstraction for WS-*
would be needed. I think it’s fairly easy to declare the winner there. 
&lt;/p&gt;
&lt;h3&gt;Federated Autonomous Services
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/Utopia-ESB_87DD/image_2.png"&gt;&lt;img title=image style="BORDER-LEFT-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px; BACKGROUND-IMAGE: none; BORDER-BOTTOM-WIDTH: 0px; FLOAT: right; PADDING-TOP: 0px; PADDING-LEFT: 0px; DISPLAY: inline; PADDING-RIGHT: 0px; BORDER-TOP-WIDTH: 0px" border=0 alt=image align=right src="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/Utopia-ESB_87DD/image_thumb.png" width=240 height=213&gt;&lt;/a&gt;Windows
Azure, to name a system that would surely be one to fit the kind of solution complexity
that ESBs were aimed at, is a very large distributed system with a significant number
of independent multi-tenant services and deployments that are spread across many data
centers. In addition to the publicly exposed capabilities, there are quite a number
of “invisible” services for provisioning, usage tracking and analysis, billing, diagnostics,
deployment, and other purposes.&amp;nbsp; Some components of these internal services integrate
with external providers. Windows Azure doesn’t use an ESB. Windows Azure is a federation
of autonomous services.
&lt;/p&gt;
&lt;p&gt;
The basic shape of each of these services is effectively identical and that’s not
owing, at least not to my knowledge, to any central architectural directive even though
the services that shipped after the initial wave certainly took a good look at the
patterns that emerged. Practically all services have a gateway whose purpose it is
to handle and dispatch and sometimes preprocess incoming network requests or sessions
and a backend that ultimately fulfills the requests. The services interact through
public IP space, meaning that if Service Bus wants to talk to its SQL Database backend
it is using a public IP address and not some private IP. The Internet is the bus.
The backend and its structure is entirely a private implementation matter.&amp;nbsp; It
could be a single role or many roles. 
&lt;/p&gt;
&lt;p&gt;
Any gateway’s job is to provide network request management, which includes establishing
and maintaining sessions, session security and authorization, API versioning where
multiple variants of the same API are often provided in parallel, usage tracking,
defense mechanisms, and diagnostics for its areas of responsibility. This functionality
is specific and inherent to the service. And it’s not all HTTP. SQL database has a
gateway that speaks the Tabular Data Stream protocol (TDS) over TCP, for instance,
and Service Bus has a gateway that speaks AMQP and the binary proprietary Relay and
Messaging protocols.
&lt;/p&gt;
&lt;p&gt;
Governance and diagnostics doesn’t work by putting a man in the middle and watching
the traffic coming by, which is akin to trying the tell whether a business is healthy
by counting the trucks going to their warehouse. Instead we are integrating the data
feeds that come out of the respective services and are generated fully knowing the
internal state, and concentrate these data streams, like the billing stream, in yet
other services that are also autonomous and have their own gateways. All these services
interact and integrate even though they’re built by a composite team far exceeding
the scale of most Enterprise’s largest projects, and while teams run on separate schedules
where deployments into the overall system happen multiple times daily. It works because
each service owns its gateway, is explicit about its versioning strategy, and has
a very clear mandate to honor published contracts, which includes explicit regression
testing. It would be unfathomable to maintain a system of this scale through a centrally
governed switchboard service like an ESB.
&lt;/p&gt;
&lt;p&gt;
Well, where does that leave “ESB technologies” like BizTalk Server? The answer is
simply that they’re being used for what they’re commonly used for in practice. As
a gateway technology. Once a service in such a federation would have to adhere to
a particular industry standard for commerce, for instance if it would have to understand
EDIFACT or X.12 messages sent to it, the Gateway would employ an appropriate and proven
implementation and thus likely rely on BizTalk if implemented on the Microsoft stack.
If a service would have to speak to an external service for which it would have to
build EDI exchanges, it would likely be very cost effective to also use BizTalk as
the appropriate tool for that outbound integration. Likewise, if data would have to
be extracted from backend-internal message traffic for tracking purposes and BizTalk’s
BAM capabilities would be a fit, it might be a reasonable component to use for that.
If there’s a long running process around exchanging electronic documents, BizTalk
Orchestration might be appropriate, if there’s a document exchange involving humans
then SharePoint and/or Workflow would be a good candidate from the toolset. 
&lt;/p&gt;
&lt;p&gt;
For most services, the key gateway technology of choice is HTTP using frameworks like
ASP.NET, Web API, probably paired with IIS features like application request routing
and the gateway is largely stateless.
&lt;/p&gt;
&lt;p&gt;
In this context, &lt;em&gt;Windows Azure Service Bus&lt;/em&gt; is, in fact, a technology choice
to implement application gateways. A Service Bus namespace thus forms a message bus
for “a service” and not for “all services”. It’s as scoped to a service or a set of
related services as an IIS site is usually scoped to one or a few related services.
The Relay is a way to place a gateway into the cloud for services where the backend
resides outside of the cloud environment and it also allows for multiple systems,
e.g. branch systems, to be federated into a single gateway to be addressed from other
systems and thus form a gateway of gateways. The messaging capabilities with Queues
and Pub/Sub Topics provide a way for inbound traffic to be authorized and queued up
on behalf of the service, with Service Bus acting as the mediator and first line of
defense and where a service will never get a message from the outside world unless
it explicitly fetches it from Service Bus. The service can’t be overstressed and it
can’t be accessed except through sending it a message. 
&lt;/p&gt;
&lt;p&gt;
The next logical step on that journey is to provide federation capabilities with reliable
handoff of message between services, meaning that you can safely enqueue a message
within a service and then have Service Bus replicate that message (or one copy in
the case of pub/sub) over to another service’s Gateway – across namespaces and across
datacenters or your own sites, and using the open AMQP protocol. You can do that today
with a few lines of code, but this will become inherent to the system later this year. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=4718bf97-cc2e-46ba-854a-f4a1d93fb2a9" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,4718bf97-cc2e-46ba-854a-f4a1d93fb2a9.aspx</comments>
      <category>Architecture</category>
      <category>Architecture/SOA</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=13a56656-e8f4-4154-8cf9-cf2480536389</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,13a56656-e8f4-4154-8cf9-cf2480536389.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,13a56656-e8f4-4154-8cf9-cf2480536389.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=13a56656-e8f4-4154-8cf9-cf2480536389</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This session explains how to secure Service Bus using the Access Control Service.
This is also an extension session for <a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-862T">my
session at BUILD</a>, but watching the BUILD session is not a strict prerequisite.
</p>
        <iframe style="WIDTH: 512px; HEIGHT: 288px" src="http://channel9.msdn.com/posts/Securing-Service-Bus-with-ACS/player?w=512&amp;h=288" frameborder="0" scrolling="no">
        </iframe>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=13a56656-e8f4-4154-8cf9-cf2480536389" />
      </body>
      <title>Securing Service Bus with the Access Control Service</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,13a56656-e8f4-4154-8cf9-cf2480536389.aspx</guid>
      <link>http://vasters.com/clemensv/2011/09/19/Securing+Service+Bus+With+The+Access+Control+Service.aspx</link>
      <pubDate>Mon, 19 Sep 2011 19:00:29 GMT</pubDate>
      <description>&lt;p&gt;
This session explains how to secure Service Bus using the Access Control Service.
This is also an extension session for &lt;a href="http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-862T"&gt;my
session at BUILD&lt;/a&gt;, but watching the BUILD session is not a strict prerequisite.
&lt;/p&gt;
&lt;iframe style="WIDTH: 512px; HEIGHT: 288px" src="http://channel9.msdn.com/posts/Securing-Service-Bus-with-ACS/player?w=512&amp;amp;h=288" frameborder=0 scrolling=no&gt;
&lt;/iframe&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=13a56656-e8f4-4154-8cf9-cf2480536389" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,13a56656-e8f4-4154-8cf9-cf2480536389.aspx</comments>
      <category>.NET Services</category>
      <category>AppFabric</category>
      <category>Azure</category>
      <category>Talks</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=44c95cba-0951-4f92-96e2-1366b516f72c</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,44c95cba-0951-4f92-96e2-1366b516f72c.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,44c95cba-0951-4f92-96e2-1366b516f72c.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=44c95cba-0951-4f92-96e2-1366b516f72c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This session is a followup to the Service Bus session <a href="http://vasters.com/clemensv/2011/09/16/Building+Looselycoupled+Apps+With+Windows+Azure+Service+Bus+Topics+And+Queues.aspx">that
I did at the build conference</a> and explains advanced usage patterns:
</p>
        <p>
          <iframe style="WIDTH: 512px; HEIGHT: 288px" src="http://channel9.msdn.com/posts/ServiceBusTopicsAndQueues/player?w=512&amp;h=288" frameborder="0" scrolling="no">
          </iframe>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=44c95cba-0951-4f92-96e2-1366b516f72c" />
      </body>
      <title>Service Bus Topics and Queues &amp;ndash; Advanced</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,44c95cba-0951-4f92-96e2-1366b516f72c.aspx</guid>
      <link>http://vasters.com/clemensv/2011/09/19/Service+Bus+Topics+And+Queues+Ndash+Advanced.aspx</link>
      <pubDate>Mon, 19 Sep 2011 02:15:26 GMT</pubDate>
      <description>&lt;p&gt;
This session is a followup to the Service Bus session &lt;a href="http://vasters.com/clemensv/2011/09/16/Building+Looselycoupled+Apps+With+Windows+Azure+Service+Bus+Topics+And+Queues.aspx"&gt;that
I did at the build conference&lt;/a&gt; and explains advanced usage patterns:
&lt;/p&gt;
&lt;p&gt;
&lt;iframe style="WIDTH: 512px; HEIGHT: 288px" src="http://channel9.msdn.com/posts/ServiceBusTopicsAndQueues/player?w=512&amp;amp;h=288" frameborder=0 scrolling=no&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=44c95cba-0951-4f92-96e2-1366b516f72c" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,44c95cba-0951-4f92-96e2-1366b516f72c.aspx</comments>
      <category>.NET Services</category>
      <category>AppFabric</category>
      <category>Azure</category>
      <category>Talks</category>
      <category>Technology/MSMQ</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=d2926b39-5935-449b-927a-2a2421c1aaeb</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,d2926b39-5935-449b-927a-2a2421c1aaeb.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,d2926b39-5935-449b-927a-2a2421c1aaeb.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=d2926b39-5935-449b-927a-2a2421c1aaeb</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <iframe title="YouTube video player" height="390" src="http://www.youtube.com/embed/EqDKRCucIL8" frameborder="0" width="640" allowfullscreen="allowfullscreen">
        </iframe>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=d2926b39-5935-449b-927a-2a2421c1aaeb" />
      </body>
      <title>What I do at work &amp;ndash; Cloud and Service Bus for Normal People</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,d2926b39-5935-449b-927a-2a2421c1aaeb.aspx</guid>
      <link>http://vasters.com/clemensv/2011/03/19/What+I+Do+At+Work+Ndash+Cloud+And+Service+Bus+For+Normal+People.aspx</link>
      <pubDate>Sat, 19 Mar 2011 05:06:43 GMT</pubDate>
      <description>&lt;iframe title="YouTube video player" height="390" src="http://www.youtube.com/embed/EqDKRCucIL8" frameborder="0" width="640" allowfullscreen="allowfullscreen"&gt;
&lt;/iframe&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=d2926b39-5935-449b-927a-2a2421c1aaeb" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,d2926b39-5935-449b-927a-2a2421c1aaeb.aspx</comments>
      <category>Architecture</category>
      <category>Azure</category>
      <category>Technology</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=f5707b54-5d11-4b5a-a1c4-cfc65faca55e</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,f5707b54-5d11-4b5a-a1c4-cfc65faca55e.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,f5707b54-5d11-4b5a-a1c4-cfc65faca55e.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=f5707b54-5d11-4b5a-a1c4-cfc65faca55e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
My PDC10 session is available online (it was pre-recorded). I talk about the new ‘Labs’
release that we released into the datacenter this week and about a range of future
capabilities that we’re planning for Service Bus. Some of those future capabilities
that are a bit further out are about bringing back some popular capabilities from
back in the .NET Services incubation days (like Push and Service Orchestration), some
are entirely new.
</p>
        <p>
One important note about the new release at <a href="http://portal.appfabriclabs.com">http://portal.appfabriclabs.com</a> –
for Service Bus, this is a focused release that provides mostly only new features
and doesn’t provide the full capability scope of the production system and SDK. The
goal here is to provide insight into an ongoing development process and opportunity
for feedback as we’re continuing to evolve AppFabric. So don’t derive any implications
from this release on what we’re going to do with the capabilities already in production.
</p>
        <p>
          <a href="http://player.microsoftpdc.com/Session/1f7d009e-29cb-4a15-a1bf-91ffd115c54d">Click
here to go to the talk.</a>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=f5707b54-5d11-4b5a-a1c4-cfc65faca55e" />
      </body>
      <title>PDC10 Windows Azure AppFabric - Service Bus Futures</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,f5707b54-5d11-4b5a-a1c4-cfc65faca55e.aspx</guid>
      <link>http://vasters.com/clemensv/2010/10/29/PDC10+Windows+Azure+AppFabric+Service+Bus+Futures.aspx</link>
      <pubDate>Fri, 29 Oct 2010 18:20:38 GMT</pubDate>
      <description>&lt;p&gt;
My PDC10 session is available online (it was pre-recorded). I talk about the new ‘Labs’
release that we released into the datacenter this week and about a range of future
capabilities that we’re planning for Service Bus. Some of those future capabilities
that are a bit further out are about bringing back some popular capabilities from
back in the .NET Services incubation days (like Push and Service Orchestration), some
are entirely new.
&lt;/p&gt;
&lt;p&gt;
One important note about the new release at &lt;a href="http://portal.appfabriclabs.com"&gt;http://portal.appfabriclabs.com&lt;/a&gt; –
for Service Bus, this is a focused release that provides mostly only new features
and doesn’t provide the full capability scope of the production system and SDK. The
goal here is to provide insight into an ongoing development process and opportunity
for feedback as we’re continuing to evolve AppFabric. So don’t derive any implications
from this release on what we’re going to do with the capabilities already in production.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://player.microsoftpdc.com/Session/1f7d009e-29cb-4a15-a1bf-91ffd115c54d"&gt;Click
here to go to the talk.&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=f5707b54-5d11-4b5a-a1c4-cfc65faca55e" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,f5707b54-5d11-4b5a-a1c4-cfc65faca55e.aspx</comments>
      <category>AppFabric</category>
      <category>Azure</category>
      <category>Technology</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=1772c4e3-2eed-4c74-b716-fe073a44adc8</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,1772c4e3-2eed-4c74-b716-fe073a44adc8.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,1772c4e3-2eed-4c74-b716-fe073a44adc8.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=1772c4e3-2eed-4c74-b716-fe073a44adc8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We know that there’s a number of you out there who have outbound firewall rules in
place on your corporate infrastructures that are based on IP address whitelisting.
So if you want to make Service Bus or Access Control work, you need to know where
our services reside. Below is the current list of where the services are deployed
as of today, but be aware that it’s in the nature of cloud infrastructures that things
can and will move over time.IP address whitelisting strategy isn’t really the right
thing to do when the other side is a massively multi-tenant infrastructure such as
Windows Azure (or any other public cloud platform, for that matter)
</p>
        <ul>
          <li>
Asia (SouthEast): 207.46.48.0/20, 111.221.16.0/21, 111.221.80.0/20 
</li>
          <li>
Asia (East): 111.221.64.0/22, 65.52.160.0/19 
</li>
          <li>
Europe (West): 94.245.97.0/24, 65.52.128.0/19 
</li>
          <li>
Europe (North): 213.199.128.0/20, 213.199.160.0/20, 213.199.184.0/21, 94.245.112.0/20,
94.245.88.0/21, 94.245.104.0/21, 65.52.64.0/20, 65.52.224.0/19 
</li>
          <li>
US (North/Central): 207.46.192.0/20, 65.52.0.0/19, 65.52.48.0/20, 65.52.192.0/19,
209.240.220.0/23 
</li>
          <li>
US (South/Central): 65.55.80.0/20, 65.54.48.0/21, 65.55.64.0/20, 70.37.48.0/20, 70.37.64.0/18,
65.52.32.0/21, 70.37.160.0/21</li>
        </ul>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=1772c4e3-2eed-4c74-b716-fe073a44adc8" />
      </body>
      <title>Windows Azure AppFabric Datacenter IP ranges</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,1772c4e3-2eed-4c74-b716-fe073a44adc8.aspx</guid>
      <link>http://vasters.com/clemensv/2010/10/25/Windows+Azure+AppFabric+Datacenter+IP+Ranges.aspx</link>
      <pubDate>Mon, 25 Oct 2010 17:11:08 GMT</pubDate>
      <description>&lt;p&gt;
We know that there’s a number of you out there who have outbound firewall rules in
place on your corporate infrastructures that are based on IP address whitelisting.
So if you want to make Service Bus or Access Control work, you need to know where
our services reside. Below is the current list of where the services are deployed
as of today, but be aware that it’s in the nature of cloud infrastructures that things
can and will move over time.IP address whitelisting strategy isn’t really the right
thing to do when the other side is a massively multi-tenant infrastructure such as
Windows Azure (or any other public cloud platform, for that matter)
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Asia (SouthEast): 207.46.48.0/20, 111.221.16.0/21, 111.221.80.0/20 
&lt;li&gt;
Asia (East): 111.221.64.0/22, 65.52.160.0/19 
&lt;li&gt;
Europe (West): 94.245.97.0/24, 65.52.128.0/19 
&lt;li&gt;
Europe (North): 213.199.128.0/20, 213.199.160.0/20, 213.199.184.0/21, 94.245.112.0/20,
94.245.88.0/21, 94.245.104.0/21, 65.52.64.0/20, 65.52.224.0/19 
&lt;li&gt;
US (North/Central): 207.46.192.0/20, 65.52.0.0/19, 65.52.48.0/20, 65.52.192.0/19,
209.240.220.0/23 
&lt;li&gt;
US (South/Central): 65.55.80.0/20, 65.54.48.0/21, 65.55.64.0/20, 70.37.48.0/20, 70.37.64.0/18,
65.52.32.0/21, 70.37.160.0/21&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=1772c4e3-2eed-4c74-b716-fe073a44adc8" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,1772c4e3-2eed-4c74-b716-fe073a44adc8.aspx</comments>
      <category>AppFabric</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=83f937f7-b838-43d0-ad61-74605eceafa2</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,83f937f7-b838-43d0-ad61-74605eceafa2.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,83f937f7-b838-43d0-ad61-74605eceafa2.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=83f937f7-b838-43d0-ad61-74605eceafa2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p align="justify">
As our team was starting to transform our parts of the Azure Services Platform from
a CTP ‘labs’ service exploring features into a full-on commercial service, it started
to dawn on us that we had set ourselves up for writing a bunch of ‘enterprise apps’.
The shiny parts of Service Bus and Access Control that we parade around are all about
user-facing features, but if I look back at the work we had to go from a toy service
to a commercial offering, I’d guess that 80%-90% of the effort went into aspects like
infrastructure, deployment, upgradeability, billing, provisioning, throttling, quotas,
security hardening, and service optimization. The lesson there was: when you’re boarding
the train to shipping a V1, you don’t load new features on that train –  you
rather throw some off. 
</p>
        <p align="justify">
The most interesting challenge for these infrastructure apps sitting on the backend
was that we didn’t have much solid ground to stand on. Remember – these were very
early days, so we couldn’t use SQL Azure since the folks over in SQL were on a pretty
heroic schedule themselves and didn’t want to take on any external dependencies even
from close friends. We also couldn’t use any of the capabilities of our own bits because
building infrastructure for your features on your features would just be plain dumb.
And while we could use capabilities of the Windows Azure platform we were building
on, a lot of those parts still had rough edges as those folks were going through a
lot of the same that we went through. In those days, the table store would be very
moody, the queue store would sometimes swallow or duplicate messages, the Azure fabric
controller would occasionally go around and kill things. All normal –  bugs.
</p>
        <p align="justify">
So under those circumstances we had to figure out the architecture for some subsystems
where we need to do a set of coordinated action across a distributed set of resources
– a distributed transaction or saga of sorts. The architecture had a few simple goals:
when we get an activation request, we must not fumble that request under any circumstance,
we must run the job to completion for all resources and, at the same time, we need
to minimize any potential for required operator intervention, i.e. if something goes
wrong, the system better knows how to deal with it – at best it should self-heal. 
</p>
        <p align="justify">
My solution to that puzzle is a pattern I call “Scheduler-Agent-Supervisor Pattern”
or, short, “Supervisor Pattern”. We keep finding applications for this pattern in
different places, so I think it’s worth writing about it in generic terms – even without
going into the details of our system.
</p>
        <p align="justify">
The pattern foots on two seemingly odd and very related assumptions: <em>‘</em><strong><em>the
system is perfect’</em></strong>and<strong><em>‘all error conditions are transient’</em>.</strong> As
a consequence, the architecture has some character traits of a toddler. It’s generally
happily optimistic and gets very grumpy, very quickly when things go wrong – to the
point that it will simply drop everything and run away screaming. It’s very precisely
like that, in fact.
</p>
        <p>
          <a href="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_2.png">
            <img style="BACKGROUND-IMAGE: none; BORDER-RIGHT-WIDTH: 0px; MARGIN: 3px 0px 3px 10px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: ; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px" title="image" border="0" alt="image" src="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_thumb.png" width="600" height="290" />
          </a>
        </p>
        <p align="justify">
The first picture here shows all key pieces except the <em>Supervisor</em> that I’ll
introduce later. At the core we have a <em>Scheduler</em> that manages a simple state
machine made up of <em>Jobs</em> and those jobs have <em>Steps</em>. The steps may
have a notion of interdependency or may be completely parallelizable. There is a <em>Job
Store</em> that holds jobs and steps and there are <em>Agents</em> that execute operations
on some resource.  Each <em>Agent</em> is (usually) fronted by a queue and the <em>Scheduler</em> has
a queue (or service endpoint) through which it receives reply messages from the <em>Agents</em>.
</p>
        <p align="justify">
Steps are recorded in a durable storage table of some sort that has at least the following
fields: <em>Current State</em> (say: Disabled, Active), <em>Desired State</em> (say:
Disabled, Active), <em>LockedUntil</em> (Date/Time value), and <em>Actor</em> plus
any step specific information you want to store and eventually submit with the job
to the step agent.
</p>
        <h3>When Things Go Right
</h3>
        <p>
The initial flow is as follows:
</p>
        <blockquote>
          <p>
            <strong>(1)a</strong> – Submit a new job into the Scheduler (and wait) 
<br /><strong>(2)a</strong> – The Scheduler creates a new job and steps with an initial
current state (<em>‘Disabled’</em>) in the job store  
<br /><strong>(2)b</strong> – The Scheduler sets ‘desired state’ of the job and of all schedulable
steps (dependencies?) to the target state (<em>‘Active’</em>) and sets the ‘locked
until’ timeout of the step to a value in the near future, e.g. ‘Now’ + 2 minutes. 
<br /><strong>(1)b</strong> – Job submission request unblocks and returns
</p>
        </blockquote>
        <p align="justify">
If all went well, we now have a job record and, here in this example, two step records
in our store. They have a current state of <em>‘Disabled’</em> and a desired state
of <em>‘Active’</em>. If things didn’t go well, we’d have incomplete or partially
wedged records or nothing in the job store, at all. The client would also know about
it since we’ve held on to the reply until we have everything done – so the client
is encouraged to retry. If we have nothing in the store and the client doesn’t retry
– well, then the job probably wasn’t all that important, after all. But if we have
at least a job record, we can make it all right later. We’re optimists, though; let’s
assume it all went well.
</p>
        <p align="justify">
For the next steps we assume that there’s a notion of dependencies between the steps
and the second steps depends on the first. If that were not the case, the two actions
would just be happening in parallel.
</p>
        <blockquote>
          <p>
            <strong>(3)</strong> – Place a step message into the queue for the actor for the first
step; Agent 1 in this case. The message contains all the information about the step,
including the current and desired state and also the <em>LockedUntil</em> that puts
an ultimatum on the activity. The message may further contain an action indicator
or arguments that are taken from the step record. 
<br /><strong>(4)</strong> – After the agent has done the work, it places a completion record
into the reply queue of the Scheduler. 
<br /><strong>(5)</strong> – The Scheduler records the step as complete by setting the current
state from ‘Disabled’ to ‘Active’; as a result the desired and the current state are
now equal. 
<br /><strong>(6)</strong> – The Scheduler sets the next step’s desired state to the target
state (<em>‘Active’</em>) and sets the <em>LockedUntil</em> timeout of the step to
a value in the near future, e.g. ‘Now’ + 1 minute. The lock timeout value is an ultimatum
for when the operation is expected to be complete and reported back as being complete
in a worst-case success case. The actual value therefore depends on the common latency
of operations in the system. If operations usually complete in milliseconds and at
worst within a second, the lock timeout can be short – but not too short. We’ll discuss
this  value in more detail a bit later. 
<br /><strong>(7)</strong>, <strong>(8)</strong>, <strong>(9)</strong> are equivalent to <strong>(3)</strong>, <strong>(4)</strong>, <strong>(5)</strong>.
</p>
        </blockquote>
        <p align="justify">
Once the last step’s current state is equal to the current state, the job’s current
state gets set to the desired state and we’re done. So that was the “99% of the time”
happy path.
</p>
        <p>
          <a href="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_4.png">
            <img style="BACKGROUND-IMAGE: none; BORDER-RIGHT-WIDTH: 0px; MARGIN: 3px 0px 3px 10px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: ; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px" title="image" border="0" alt="image" src="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_thumb_1.png" width="591" height="286" />
          </a>
        </p>
        <h3>When Things Go Wrong
</h3>
        <p align="justify">
So what happens when anything goes wrong? Remember the principle <strong>‘all errors
are transient’</strong>. What we do in the error case – anywhere – is to log the error
condition and then promptly drop everything and simply hope that time, a change in
system conditions, human or divine intervention, or – at worst – a patch will heal
matters. That’s what the second principle <strong>‘the system is perfect’<em> </em></strong>is
about; the system obviously isn’t really perfect, but if we construct it in a way
that we can either wait for it to return from a wedged state into a functional state
or where we enable someone to go in and apply a fix for a blocking bug while preserving
the system state, we can consider the system ‘perfect’ in the sense that pretty much
any conceivable job that’s already in the system can be driven to completion.
</p>
        <p align="justify">
In the second picture, we have Agent 2 blowing up as it is processing the step it
got handed in <strong>(7)</strong>. If the agent just can’t get its work done since
some external dependency isn’t available – maybe a database can’t be reached or a
server it’s talking to spews out ‘server too busy’ errors – it may be able to back
off for a moment and retry. However, it must not retry past the <em>LockedUntil</em> ultimatum
that’s in the step record. When things fail and the agent is still breathing, it may,
as a matter of courtesy, notify the scheduler of the fact and report that the step
was completed with no result, i.e. the desired state and the achieved state don’t
match. That notification may also include diagnostic information. Once the <em>LockedUntil</em> ultimatum
has passed, the Agent no longer owns the job and must drop it. It must even not report
failure state back to the Scheduler past that point. 
</p>
        <p align="justify">
If the agent keels over and dies as it is processing the step (or right before or
right after), it is obviously no longer in a position to let the scheduler know about
its fate. Thus, there won’t be any message flowing back to the scheduler and the job
is stalled. But we expect that. In fact, we’re ok with any failure anywhere in the
system. We could lose or fumble a queue message, we could get a duplicate message,
we could have the scheduler die a fiery death (or just being recycled for patching
at some unfortunate moment) – all of those conditions are fine since we’ve brought
the doctor on board with us: the <em>Supervisor.</em> 
</p>
        <p align="justify">
          <a href="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_6.png">
            <img style="BACKGROUND-IMAGE: none; BORDER-RIGHT-WIDTH: 0px; MARGIN: 3px 10px 3px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: ; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px" title="image" border="0" alt="image" src="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_thumb_2.png" width="558" height="297" />
          </a>
        </p>
        <h3>The Supervisor
</h3>
        <p>
The Supervisor is a schedule driven process (or thread) of which one or a few instances
may run occasionally. The frequency depends on much on the average duration of operations
and the expected overall latency for completion of jobs. 
</p>
        <p>
The Supervisor’s job is to recover steps or jobs that have failed – and we’re assuming
that failures are due to some transient condition. So if the system would expect a
transient resource failure condition that prevented a job from completing just a second
ago to be healed two seconds later, it’d depend on the kind of system and resource
whether that’d be a good strategy.  What’s described here is a pattern, not a
solution, so it depends on the concrete scenario to get the  timing right for
when to try operations again once they fail.
</p>
        <p>
This desired back-off time manifests in the <em>LockedUntil</em> value.  When
a step gets scheduled, the <em>Scheduler</em> needs to state how long it is willing
to wait for that step to complete; this includes some back-off time padding. Once
that ultimatum has passed and the step is still in an inconsistent state (desired
state doesn’t equal the current state)  the <em>Supervisor</em> can pick it up
at any time and schedule it.
</p>
        <blockquote>
          <p>
            <strong>(1)</strong> – Supervisor queries the job store for any inconsistent steps
whose <em>LockedUntil</em> value has expired. 
<br /><strong>(2) – </strong>The Supervisor schedules the step again by setting the <em>LockedUntil </em>value
to a new timeout and submitting the step into the target actor’s queue 
<br /><strong>(3)</strong> – Once the step succeeds, the step is reported as complete on
the regular path back to the <em>Scheduler</em>  where it completes normally
as in steps <strong>(8)</strong>, <strong>(9)</strong> from the happy-path scenario
above. If it fails, we simply drop it again. For failures that allow reporting an
error back to the <em>Scheduler</em> it may make sense to introduce an error counter
that round-trips with the step so that the system could detect poisonous steps that
fail ‘forever’ and have the <em>Supervisor</em> ignore those after some threshold.
</p>
        </blockquote>
        <p>
The Supervisor can pursue a range of strategies for recovery. It can just take a look
at individual steps and recover them by rescheduling them – assuming the steps are
implemented as idempotent operations. If it were a bit cleverer, it may consider error
information that a cooperative (and breathing) agent has submitted back to the Scheduler
and even go as far as to fire an alert to an operator if the error condition were
to require intervention and then take the step out of the loop by marking it and setting
the <em>LockedUntil</em> value to some longer timeout so it’s taken out of the loop
and someone can take a look. 
</p>
        <p>
At the job-scope, the Supervisor may want to perform recovery such that it first schedules
all previously executed steps to revert back to the initial state by performing compensation
work (all resources that got set to active are getting disabled again here in our
example) and then scheduling another attempt at getting to the desired state. 
</p>
        <p>
In step <strong>(2)b</strong> up above, we’ve been logging current and desired state
at the job-scope and with that we can also always find inconsistent jobs where all
steps are consistent and wouldn’t show up in the step-level recovery query. That situation
can occur if the <em>Scheduler</em> were to crash between logging one step as complete
and scheduling the next step. If we find inconsistent jobs with all-consistent steps,
we just need to reschedule the next step in the dependency sequence whose desired
state isn’t matching the desired state of the overall job.
</p>
        <p>
To be thorough, we could now take a look at all the places where things can go wrong
in the system. I expect that survey to yield that at as long we can successfully get
past step <strong>(2)b </strong>from the first diagram, the <em>Supervisor</em> is
always in a position to either detect that a job isn’t making progress and help with
recovery or can at least call for help. The system always knows what its current <strong>intent</strong> is,
i.e. which state transitions it wants to drive, and never forgets about that intent
since that intent is logged in the job store at all times and all progress against
that intent is logged as well.  The submission request <strong>(1)</strong> depends
on the outcome of <strong>(2)a/b </strong>to guard against failures while putting
a job and its steps into the system so that a client can take corrective action. In
fact, once the job record is marked as inconsistent in step <strong>(2)b</strong>,
the scheduler could already report success back to the submitting party even before
the first step is scheduled, because the <em>Supervisor</em> would pick up that inconsistency
eventually.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=83f937f7-b838-43d0-ad61-74605eceafa2" />
      </body>
      <title>Cloud Architecture: The Scheduler-Agent-Supervisor Pattern</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,83f937f7-b838-43d0-ad61-74605eceafa2.aspx</guid>
      <link>http://vasters.com/clemensv/2010/09/28/Cloud+Architecture+The+SchedulerAgentSupervisor+Pattern.aspx</link>
      <pubDate>Tue, 28 Sep 2010 01:55:18 GMT</pubDate>
      <description>&lt;p align=justify&gt;
As our team was starting to transform our parts of the Azure Services Platform from
a CTP ‘labs’ service exploring features into a full-on commercial service, it started
to dawn on us that we had set ourselves up for writing a bunch of ‘enterprise apps’.
The shiny parts of Service Bus and Access Control that we parade around are all about
user-facing features, but if I look back at the work we had to go from a toy service
to a commercial offering, I’d guess that 80%-90% of the effort went into aspects like
infrastructure, deployment, upgradeability, billing, provisioning, throttling, quotas,
security hardening, and service optimization. The lesson there was: when you’re boarding
the train to shipping a V1, you don’t load new features on that train –&amp;nbsp; you
rather throw some off. 
&lt;/p&gt;
&lt;p align=justify&gt;
The most interesting challenge for these infrastructure apps sitting on the backend
was that we didn’t have much solid ground to stand on. Remember – these were very
early days, so we couldn’t use SQL Azure since the folks over in SQL were on a pretty
heroic schedule themselves and didn’t want to take on any external dependencies even
from close friends. We also couldn’t use any of the capabilities of our own bits because
building infrastructure for your features on your features would just be plain dumb.
And while we could use capabilities of the Windows Azure platform we were building
on, a lot of those parts still had rough edges as those folks were going through a
lot of the same that we went through. In those days, the table store would be very
moody, the queue store would sometimes swallow or duplicate messages, the Azure fabric
controller would occasionally go around and kill things. All normal –&amp;nbsp; bugs.
&lt;/p&gt;
&lt;p align=justify&gt;
So under those circumstances we had to figure out the architecture for some subsystems
where we need to do a set of coordinated action across a distributed set of resources
– a distributed transaction or saga of sorts. The architecture had a few simple goals:
when we get an activation request, we must not fumble that request under any circumstance,
we must run the job to completion for all resources and, at the same time, we need
to minimize any potential for required operator intervention, i.e. if something goes
wrong, the system better knows how to deal with it – at best it should self-heal. 
&lt;/p&gt;
&lt;p align=justify&gt;
My solution to that puzzle is a pattern I call “Scheduler-Agent-Supervisor Pattern”
or, short, “Supervisor Pattern”. We keep finding applications for this pattern in
different places, so I think it’s worth writing about it in generic terms – even without
going into the details of our system.
&lt;/p&gt;
&lt;p align=justify&gt;
The pattern foots on two seemingly odd and very related assumptions: &lt;em&gt;‘&lt;/em&gt;&lt;strong&gt;&lt;em&gt;the
system is perfect’&lt;/em&gt; &lt;/strong&gt;and&lt;strong&gt; &lt;em&gt;‘all error conditions are transient’&lt;/em&gt;.&lt;/strong&gt; As
a consequence, the architecture has some character traits of a toddler. It’s generally
happily optimistic and gets very grumpy, very quickly when things go wrong – to the
point that it will simply drop everything and run away screaming. It’s very precisely
like that, in fact.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_2.png"&gt;&lt;img style="BACKGROUND-IMAGE: none; BORDER-RIGHT-WIDTH: 0px; MARGIN: 3px 0px 3px 10px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: ; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px" title=image border=0 alt=image src="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_thumb.png" width=600 height=290&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p align=justify&gt;
The first picture here shows all key pieces except the &lt;em&gt;Supervisor&lt;/em&gt; that I’ll
introduce later. At the core we have a &lt;em&gt;Scheduler&lt;/em&gt; that manages a simple state
machine made up of &lt;em&gt;Jobs&lt;/em&gt; and those jobs have &lt;em&gt;Steps&lt;/em&gt;. The steps may
have a notion of interdependency or may be completely parallelizable. There is a &lt;em&gt;Job
Store&lt;/em&gt; that holds jobs and steps and there are &lt;em&gt;Agents&lt;/em&gt; that execute operations
on some resource.&amp;nbsp; Each &lt;em&gt;Agent&lt;/em&gt; is (usually) fronted by a queue and the &lt;em&gt;Scheduler&lt;/em&gt; has
a queue (or service endpoint) through which it receives reply messages from the &lt;em&gt;Agents&lt;/em&gt;.
&lt;/p&gt;
&lt;p align=justify&gt;
Steps are recorded in a durable storage table of some sort that has at least the following
fields: &lt;em&gt;Current State&lt;/em&gt; (say: Disabled, Active), &lt;em&gt;Desired State&lt;/em&gt; (say:
Disabled, Active), &lt;em&gt;LockedUntil&lt;/em&gt; (Date/Time value), and &lt;em&gt;Actor&lt;/em&gt; plus
any step specific information you want to store and eventually submit with the job
to the step agent.
&lt;/p&gt;
&lt;h3&gt;When Things Go Right
&lt;/h3&gt;
&lt;p&gt;
The initial flow is as follows:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;strong&gt;(1)a&lt;/strong&gt; – Submit a new job into the Scheduler (and wait) 
&lt;br&gt;
&lt;strong&gt;(2)a&lt;/strong&gt; – The Scheduler creates a new job and steps with an initial
current state (&lt;em&gt;‘Disabled’&lt;/em&gt;) in the job store&amp;nbsp; 
&lt;br&gt;
&lt;strong&gt;(2)b&lt;/strong&gt; – The Scheduler sets ‘desired state’ of the job and of all schedulable
steps (dependencies?) to the target state (&lt;em&gt;‘Active’&lt;/em&gt;) and sets the ‘locked
until’ timeout of the step to a value in the near future, e.g. ‘Now’ + 2 minutes. 
&lt;br&gt;
&lt;strong&gt;(1)b&lt;/strong&gt; – Job submission request unblocks and returns
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p align=justify&gt;
If all went well, we now have a job record and, here in this example, two step records
in our store. They have a current state of &lt;em&gt;‘Disabled’&lt;/em&gt; and a desired state
of &lt;em&gt;‘Active’&lt;/em&gt;. If things didn’t go well, we’d have incomplete or partially
wedged records or nothing in the job store, at all. The client would also know about
it since we’ve held on to the reply until we have everything done – so the client
is encouraged to retry. If we have nothing in the store and the client doesn’t retry
– well, then the job probably wasn’t all that important, after all. But if we have
at least a job record, we can make it all right later. We’re optimists, though; let’s
assume it all went well.
&lt;/p&gt;
&lt;p align=justify&gt;
For the next steps we assume that there’s a notion of dependencies between the steps
and the second steps depends on the first. If that were not the case, the two actions
would just be happening in parallel.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;strong&gt;(3)&lt;/strong&gt; – Place a step message into the queue for the actor for the first
step; Agent 1 in this case. The message contains all the information about the step,
including the current and desired state and also the &lt;em&gt;LockedUntil&lt;/em&gt; that puts
an ultimatum on the activity. The message may further contain an action indicator
or arguments that are taken from the step record. 
&lt;br&gt;
&lt;strong&gt;(4)&lt;/strong&gt; – After the agent has done the work, it places a completion record
into the reply queue of the Scheduler. 
&lt;br&gt;
&lt;strong&gt;(5)&lt;/strong&gt; – The Scheduler records the step as complete by setting the current
state from ‘Disabled’ to ‘Active’; as a result the desired and the current state are
now equal. 
&lt;br&gt;
&lt;strong&gt;(6)&lt;/strong&gt; – The Scheduler sets the next step’s desired state to the target
state (&lt;em&gt;‘Active’&lt;/em&gt;) and sets the &lt;em&gt;LockedUntil&lt;/em&gt; timeout of the step to
a value in the near future, e.g. ‘Now’ + 1 minute. The lock timeout value is an ultimatum
for when the operation is expected to be complete and reported back as being complete
in a worst-case success case. The actual value therefore depends on the common latency
of operations in the system. If operations usually complete in milliseconds and at
worst within a second, the lock timeout can be short – but not too short. We’ll discuss
this&amp;nbsp; value in more detail a bit later. 
&lt;br&gt;
&lt;strong&gt;(7)&lt;/strong&gt;, &lt;strong&gt;(8)&lt;/strong&gt;, &lt;strong&gt;(9)&lt;/strong&gt; are equivalent to &lt;strong&gt;(3)&lt;/strong&gt;, &lt;strong&gt;(4)&lt;/strong&gt;, &lt;strong&gt;(5)&lt;/strong&gt;.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p align=justify&gt;
Once the last step’s current state is equal to the current state, the job’s current
state gets set to the desired state and we’re done. So that was the “99% of the time”
happy path.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_4.png"&gt;&lt;img style="BACKGROUND-IMAGE: none; BORDER-RIGHT-WIDTH: 0px; MARGIN: 3px 0px 3px 10px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: ; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px" title=image border=0 alt=image src="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_thumb_1.png" width=591 height=286&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;h3&gt;When Things Go Wrong
&lt;/h3&gt;
&lt;p align=justify&gt;
So what happens when anything goes wrong? Remember the principle &lt;strong&gt;‘all errors
are transient’&lt;/strong&gt;. What we do in the error case – anywhere – is to log the error
condition and then promptly drop everything and simply hope that time, a change in
system conditions, human or divine intervention, or – at worst – a patch will heal
matters. That’s what the second principle &lt;strong&gt;‘the system is perfect’&lt;em&gt;&amp;nbsp;&lt;/em&gt;&lt;/strong&gt;is
about; the system obviously isn’t really perfect, but if we construct it in a way
that we can either wait for it to return from a wedged state into a functional state
or where we enable someone to go in and apply a fix for a blocking bug while preserving
the system state, we can consider the system ‘perfect’ in the sense that pretty much
any conceivable job that’s already in the system can be driven to completion.
&lt;/p&gt;
&lt;p align=justify&gt;
In the second picture, we have Agent 2 blowing up as it is processing the step it
got handed in &lt;strong&gt;(7)&lt;/strong&gt;. If the agent just can’t get its work done since
some external dependency isn’t available – maybe a database can’t be reached or a
server it’s talking to spews out ‘server too busy’ errors – it may be able to back
off for a moment and retry. However, it must not retry past the &lt;em&gt;LockedUntil&lt;/em&gt; ultimatum
that’s in the step record. When things fail and the agent is still breathing, it may,
as a matter of courtesy, notify the scheduler of the fact and report that the step
was completed with no result, i.e. the desired state and the achieved state don’t
match. That notification may also include diagnostic information. Once the &lt;em&gt;LockedUntil&lt;/em&gt; ultimatum
has passed, the Agent no longer owns the job and must drop it. It must even not report
failure state back to the Scheduler past that point. 
&lt;/p&gt;
&lt;p align=justify&gt;
If the agent keels over and dies as it is processing the step (or right before or
right after), it is obviously no longer in a position to let the scheduler know about
its fate. Thus, there won’t be any message flowing back to the scheduler and the job
is stalled. But we expect that. In fact, we’re ok with any failure anywhere in the
system. We could lose or fumble a queue message, we could get a duplicate message,
we could have the scheduler die a fiery death (or just being recycled for patching
at some unfortunate moment) – all of those conditions are fine since we’ve brought
the doctor on board with us: the &lt;em&gt;Supervisor.&lt;/em&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p align=justify&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_6.png"&gt;&lt;img style="BACKGROUND-IMAGE: none; BORDER-RIGHT-WIDTH: 0px; MARGIN: 3px 10px 3px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: ; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px" title=image border=0 alt=image src="http://vasters.com/clemensv/content/binary/Windows-Live-Writer/d4c99e27e28d_1248C/image_thumb_2.png" width=558 height=297&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;h3&gt;The Supervisor
&lt;/h3&gt;
&lt;p&gt;
The Supervisor is a schedule driven process (or thread) of which one or a few instances
may run occasionally. The frequency depends on much on the average duration of operations
and the expected overall latency for completion of jobs. 
&lt;/p&gt;
&lt;p&gt;
The Supervisor’s job is to recover steps or jobs that have failed – and we’re assuming
that failures are due to some transient condition. So if the system would expect a
transient resource failure condition that prevented a job from completing just a second
ago to be healed two seconds later, it’d depend on the kind of system and resource
whether that’d be a good strategy.&amp;nbsp; What’s described here is a pattern, not a
solution, so it depends on the concrete scenario to get the&amp;nbsp; timing right for
when to try operations again once they fail.
&lt;/p&gt;
&lt;p&gt;
This desired back-off time manifests in the &lt;em&gt;LockedUntil&lt;/em&gt; value.&amp;nbsp; When
a step gets scheduled, the &lt;em&gt;Scheduler&lt;/em&gt; needs to state how long it is willing
to wait for that step to complete; this includes some back-off time padding. Once
that ultimatum has passed and the step is still in an inconsistent state (desired
state doesn’t equal the current state)&amp;nbsp; the &lt;em&gt;Supervisor&lt;/em&gt; can pick it up
at any time and schedule it.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;strong&gt;(1)&lt;/strong&gt; – Supervisor queries the job store for any inconsistent steps
whose &lt;em&gt;LockedUntil&lt;/em&gt; value has expired. 
&lt;br&gt;
&lt;strong&gt;(2) – &lt;/strong&gt;The Supervisor schedules the step again by setting the &lt;em&gt;LockedUntil &lt;/em&gt;value
to a new timeout and submitting the step into the target actor’s queue 
&lt;br&gt;
&lt;strong&gt;(3)&lt;/strong&gt; – Once the step succeeds, the step is reported as complete on
the regular path back to the &lt;em&gt;Scheduler&lt;/em&gt;&amp;nbsp; where it completes normally
as in steps &lt;strong&gt;(8)&lt;/strong&gt;, &lt;strong&gt;(9)&lt;/strong&gt; from the happy-path scenario
above. If it fails, we simply drop it again. For failures that allow reporting an
error back to the &lt;em&gt;Scheduler&lt;/em&gt; it may make sense to introduce an error counter
that round-trips with the step so that the system could detect poisonous steps that
fail ‘forever’ and have the &lt;em&gt;Supervisor&lt;/em&gt; ignore those after some threshold.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The Supervisor can pursue a range of strategies for recovery. It can just take a look
at individual steps and recover them by rescheduling them – assuming the steps are
implemented as idempotent operations. If it were a bit cleverer, it may consider error
information that a cooperative (and breathing) agent has submitted back to the Scheduler
and even go as far as to fire an alert to an operator if the error condition were
to require intervention and then take the step out of the loop by marking it and setting
the &lt;em&gt;LockedUntil&lt;/em&gt; value to some longer timeout so it’s taken out of the loop
and someone can take a look. 
&lt;/p&gt;
&lt;p&gt;
At the job-scope, the Supervisor may want to perform recovery such that it first schedules
all previously executed steps to revert back to the initial state by performing compensation
work (all resources that got set to active are getting disabled again here in our
example) and then scheduling another attempt at getting to the desired state. 
&lt;/p&gt;
&lt;p&gt;
In step &lt;strong&gt;(2)b&lt;/strong&gt; up above, we’ve been logging current and desired state
at the job-scope and with that we can also always find inconsistent jobs where all
steps are consistent and wouldn’t show up in the step-level recovery query. That situation
can occur if the &lt;em&gt;Scheduler&lt;/em&gt; were to crash between logging one step as complete
and scheduling the next step. If we find inconsistent jobs with all-consistent steps,
we just need to reschedule the next step in the dependency sequence whose desired
state isn’t matching the desired state of the overall job.
&lt;/p&gt;
&lt;p&gt;
To be thorough, we could now take a look at all the places where things can go wrong
in the system. I expect that survey to yield that at as long we can successfully get
past step &lt;strong&gt;(2)b &lt;/strong&gt;from the first diagram, the &lt;em&gt;Supervisor&lt;/em&gt; is
always in a position to either detect that a job isn’t making progress and help with
recovery or can at least call for help. The system always knows what its current &lt;strong&gt;intent&lt;/strong&gt; is,
i.e. which state transitions it wants to drive, and never forgets about that intent
since that intent is logged in the job store at all times and all progress against
that intent is logged as well.&amp;nbsp; The submission request &lt;strong&gt;(1)&lt;/strong&gt; depends
on the outcome of &lt;strong&gt;(2)a/b &lt;/strong&gt;to guard against failures while putting
a job and its steps into the system so that a client can take corrective action. In
fact, once the job record is marked as inconsistent in step &lt;strong&gt;(2)b&lt;/strong&gt;,
the scheduler could already report success back to the submitting party even before
the first step is scheduled, because the &lt;em&gt;Supervisor&lt;/em&gt; would pick up that inconsistency
eventually.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=83f937f7-b838-43d0-ad61-74605eceafa2" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,83f937f7-b838-43d0-ad61-74605eceafa2.aspx</comments>
      <category>Architecture</category>
      <category>Architecture/SOA</category>
      <category>Azure</category>
      <category>Technology</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=6a3321d3-1e96-47ae-8c5e-9d60346627de</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,6a3321d3-1e96-47ae-8c5e-9d60346627de.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,6a3321d3-1e96-47ae-8c5e-9d60346627de.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=6a3321d3-1e96-47ae-8c5e-9d60346627de</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://oreilly.com/catalog/9780596805494">
            <img style="MARGIN: 5px; DISPLAY: inline" alt="Book cover of Programming WCF Services" align="right" src="http://covers.oreilly.com/images/9780596805494/cat.gif" width="180" />
          </a>
        </p>
        <p>
Juval Löwy’s very successful WCF book is now available in its third edition – and
Juval asked me to update the foreword this time around. It’s been over three years
since I wrote the foreword to the first edition and thus it was time for an update
since WCF has moved on quite a bit and the use of it in the customer landscape and
inside of MS has deepened where we’re building a lot of very interesting products
on top of the WCF technology across all businesses – not least of which is the Azure
AppFabric Service Bus that I work on and that’s entirely based on WCF services.
</p>
        <p>
You can take a peek into the latest edition <a href="http://oreilly.com/catalog/9780596805494/preview#preview">at
the O’Reilly website</a> and read my foreword if you care. To be clear: It’s the least
important part of the whole book :-)
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6a3321d3-1e96-47ae-8c5e-9d60346627de" />
      </body>
      <title>Programming WCF Services, Third Edition</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,6a3321d3-1e96-47ae-8c5e-9d60346627de.aspx</guid>
      <link>http://vasters.com/clemensv/2010/09/11/Programming+WCF+Services+Third+Edition.aspx</link>
      <pubDate>Sat, 11 Sep 2010 03:10:05 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://oreilly.com/catalog/9780596805494"&gt;&lt;img style="MARGIN: 5px; DISPLAY: inline" alt="Book cover of Programming WCF Services" align=right src="http://covers.oreilly.com/images/9780596805494/cat.gif" width=180&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Juval Löwy’s very successful WCF book is now available in its third edition – and
Juval asked me to update the foreword this time around. It’s been over three years
since I wrote the foreword to the first edition and thus it was time for an update
since WCF has moved on quite a bit and the use of it in the customer landscape and
inside of MS has deepened where we’re building a lot of very interesting products
on top of the WCF technology across all businesses – not least of which is the Azure
AppFabric Service Bus that I work on and that’s entirely based on WCF services.
&lt;/p&gt;
&lt;p&gt;
You can take a peek into the latest edition &lt;a href="http://oreilly.com/catalog/9780596805494/preview#preview"&gt;at
the O’Reilly website&lt;/a&gt; and read my foreword if you care. To be clear: It’s the least
important part of the whole book :-)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6a3321d3-1e96-47ae-8c5e-9d60346627de" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,6a3321d3-1e96-47ae-8c5e-9d60346627de.aspx</comments>
      <category>AppFabric</category>
      <category>Azure</category>
      <category>Technology/WCF</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=a14d84f7-0d07-49da-a5d8-35088052c3e5</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,a14d84f7-0d07-49da-a5d8-35088052c3e5.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,a14d84f7-0d07-49da-a5d8-35088052c3e5.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=a14d84f7-0d07-49da-a5d8-35088052c3e5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In case you need a refresher or update about the things me and our team work on at
Microsoft, <a href="http://www.msteched.com/2010/Australia/COS230">go here</a> for
a very recent and very good presentation by my PM colleague <a href="http://twitter.com/mmyslin">Maggie
Myslinska</a> from TechEd Australia 2010 about Windows Azure AppFabric with Service
Bus demos and a demo of the new Access Control V2 CTP
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=a14d84f7-0d07-49da-a5d8-35088052c3e5" />
      </body>
      <title>Windows Azure AppFabric Overview session from TechEd Australia 2010 </title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,a14d84f7-0d07-49da-a5d8-35088052c3e5.aspx</guid>
      <link>http://vasters.com/clemensv/2010/09/09/Windows+Azure+AppFabric+Overview+Session+From+TechEd+Australia+2010.aspx</link>
      <pubDate>Thu, 09 Sep 2010 01:08:52 GMT</pubDate>
      <description>&lt;p&gt;
In case you need a refresher or update about the things me and our team work on at
Microsoft, &lt;a href="http://www.msteched.com/2010/Australia/COS230"&gt;go here&lt;/a&gt; for
a very recent and very good presentation by my PM colleague &lt;a href="http://twitter.com/mmyslin"&gt;Maggie
Myslinska&lt;/a&gt; from TechEd Australia 2010 about Windows Azure AppFabric with Service
Bus demos and a demo of the new Access Control V2 CTP
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=a14d84f7-0d07-49da-a5d8-35088052c3e5" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,a14d84f7-0d07-49da-a5d8-35088052c3e5.aspx</comments>
      <category>AppFabric</category>
      <category>Architecture/SOA</category>
      <category>Azure</category>
      <category>Technology</category>
      <category>Technology/ISB</category>
      <category>Technology/WCF</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=3ce38507-44b7-4a2a-bacb-aeb7aaacdf56</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,3ce38507-44b7-4a2a-bacb-aeb7aaacdf56.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,3ce38507-44b7-4a2a-bacb-aeb7aaacdf56.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=3ce38507-44b7-4a2a-bacb-aeb7aaacdf56</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Room 265, Thursday June 10 
<br />
9:45AM – 11:00 AM 
<br /><br />
Session Type: Breakout Session 
<br />
Track: Application Server &amp; Infrastructure 
<br />
Speaker(s): Clemens Vasters, Juval Lowy<strong><br /></strong>Level: 300 - Advanced 
</p>
        <p>
          <em>The availability of the Service Bus in Windows Azure AppFabric is disruptive since
it enables new design and deployment patterns that are simply inconceivable without
it, opening new horizons for architecture, integration, interoperability, deployment,
and productivity. In this unique session organized especially for Tech·Ed, Clemens
Vasters and Juval Lowy share their perspective, techniques, helper classes, insight,
and expertise in architecting solutions using the service bus. Learn how to manage
discrete events, how to achieve structured programming over the Service Bus buffers,
what options you have for discovery and even how to mimic WCF discovery, what are
the recommended options for transfer security and application authentication, and
how to use AppFabric Service Bus for tunneling for diagnostics or logging, to enabling
edge devices. The session ends with a glimpse at what is in store for the next versions
of the service bus and the future patterns.</em>
        </p>
        <p>
Yes, that's Juval and myself on the same stage. That'll be interesting.<em> </em></p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3ce38507-44b7-4a2a-bacb-aeb7aaacdf56" />
      </body>
      <title>TechEd: ASI302 Design Patterns, Practices, and Techniques with the Service Bus in Windows Azure AppFabric</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,3ce38507-44b7-4a2a-bacb-aeb7aaacdf56.aspx</guid>
      <link>http://vasters.com/clemensv/2010/05/28/TechEd+ASI302+Design+Patterns+Practices+And+Techniques+With+The+Service+Bus+In+Windows+Azure+AppFabric.aspx</link>
      <pubDate>Fri, 28 May 2010 11:40:19 GMT</pubDate>
      <description>&lt;p&gt;
Room 265, Thursday June 10 
&lt;br&gt;
9:45AM – 11:00 AM 
&lt;br&gt;
&lt;br&gt;
Session Type: Breakout Session 
&lt;br&gt;
Track: Application Server &amp;amp; Infrastructure 
&lt;br&gt;
Speaker(s): Clemens Vasters, Juval Lowy&lt;strong&gt; 
&lt;br&gt;
&lt;/strong&gt;Level: 300 - Advanced 
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;The availability of the Service Bus in Windows Azure AppFabric is disruptive since
it enables new design and deployment patterns that are simply inconceivable without
it, opening new horizons for architecture, integration, interoperability, deployment,
and productivity. In this unique session organized especially for Tech·Ed, Clemens
Vasters and Juval Lowy share their perspective, techniques, helper classes, insight,
and expertise in architecting solutions using the service bus. Learn how to manage
discrete events, how to achieve structured programming over the Service Bus buffers,
what options you have for discovery and even how to mimic WCF discovery, what are
the recommended options for transfer security and application authentication, and
how to use AppFabric Service Bus for tunneling for diagnostics or logging, to enabling
edge devices. The session ends with a glimpse at what is in store for the next versions
of the service bus and the future patterns.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
Yes, that's&amp;nbsp;Juval and myself on the same stage. That'll be interesting.&lt;em&gt;&amp;nbsp;&lt;/em&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3ce38507-44b7-4a2a-bacb-aeb7aaacdf56" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,3ce38507-44b7-4a2a-bacb-aeb7aaacdf56.aspx</comments>
      <category>AppFabric</category>
      <category>Azure</category>
      <category>Talks</category>
      <category>Talks/TechEd US</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=29ec4fe1-65d8-467e-8360-ce50a2ccd1ff</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,29ec4fe1-65d8-467e-8360-ce50a2ccd1ff.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,29ec4fe1-65d8-467e-8360-ce50a2ccd1ff.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=29ec4fe1-65d8-467e-8360-ce50a2ccd1ff</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I put the slides for my talks at NT Konferenca 2010 <a href="http://cid-123ccd2a7ab10107.skydrive.live.com/browse.aspx/NT%20Konferenca%202010">on
SkyDrive</a>. The major difference from my <a href="http://vasters.com/clemensv/PermaLink,guid,cb6599da-5785-4186-8ca1-68a0f32f4495.aspx">APAC
slides</a> is that I had to put compute and storage <a href="http://cid-123ccd2a7ab10107.skydrive.live.com/self.aspx/NT%20Konferenca%202010/NTK2010-Azure-CapabilitiesAndTips.pptx">into
one deck</a> due to the conference schedule, but instead of purely consolidating and
cutting down the slide count,  I also incorporated some common patterns coming
out from debates in Asia and added slides on predictable and dynamic scaling as well
as on multitenancy. Sadly, I need to rush through all that in 45 minutes
today. 
</p>
        <p>
          <iframe style="PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #fcfcfc; PADDING-LEFT: 0px; WIDTH: 98px; PADDING-RIGHT: 0px; HEIGHT: 115px; PADDING-TOP: 0px" title="Preview" marginheight="0" src="http://cid-123ccd2a7ab10107.skydrive.live.com/embedicon.aspx/NT%20Konferenca%202010" frameborder="0" marginwidth="0" scrolling="no">
          </iframe>
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=29ec4fe1-65d8-467e-8360-ce50a2ccd1ff" />
      </body>
      <title>NT Konferenca 2010 - Windows Azure Slidedecks</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,29ec4fe1-65d8-467e-8360-ce50a2ccd1ff.aspx</guid>
      <link>http://vasters.com/clemensv/2010/05/25/NT+Konferenca+2010+Windows+Azure+Slidedecks.aspx</link>
      <pubDate>Tue, 25 May 2010 07:08:59 GMT</pubDate>
      <description>&lt;p&gt;
I put the slides for my talks at NT Konferenca 2010 &lt;a href="http://cid-123ccd2a7ab10107.skydrive.live.com/browse.aspx/NT%20Konferenca%202010"&gt;on
SkyDrive&lt;/a&gt;.&amp;nbsp;The major difference from my&amp;nbsp;&lt;a href="http://vasters.com/clemensv/PermaLink,guid,cb6599da-5785-4186-8ca1-68a0f32f4495.aspx"&gt;APAC
slides&lt;/a&gt;&amp;nbsp;is that I had to put compute and storage&amp;nbsp;&lt;a href="http://cid-123ccd2a7ab10107.skydrive.live.com/self.aspx/NT%20Konferenca%202010/NTK2010-Azure-CapabilitiesAndTips.pptx"&gt;into
one deck&lt;/a&gt; due to the conference schedule, but instead of purely consolidating and
cutting down the slide count,&amp;nbsp; I also incorporated some common patterns coming
out from debates in Asia and added slides on predictable and dynamic scaling as well
as on&amp;nbsp;multitenancy. Sadly, I need to rush&amp;nbsp;through all that in&amp;nbsp;45 minutes
today. 
&lt;/p&gt;
&lt;p&gt;
&lt;iframe style="PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #fcfcfc; PADDING-LEFT: 0px; WIDTH: 98px; PADDING-RIGHT: 0px; HEIGHT: 115px; PADDING-TOP: 0px" title=Preview marginheight=0 src="http://cid-123ccd2a7ab10107.skydrive.live.com/embedicon.aspx/NT%20Konferenca%202010" frameborder=0 marginwidth=0 scrolling=no&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=29ec4fe1-65d8-467e-8360-ce50a2ccd1ff" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,29ec4fe1-65d8-467e-8360-ce50a2ccd1ff.aspx</comments>
      <category>AppFabric</category>
      <category>Architecture</category>
      <category>Azure</category>
      <category>Talks</category>
      <category>Technology</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=cb6599da-5785-4186-8ca1-68a0f32f4495</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,cb6599da-5785-4186-8ca1-68a0f32f4495.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,cb6599da-5785-4186-8ca1-68a0f32f4495.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=cb6599da-5785-4186-8ca1-68a0f32f4495</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm on a tour through several countries right now and I'm talking to ISVs about
the Windows Azure platform, its capabilities and the many opportunities ISVs have
to transform the way they do business by moving to the cloud. The first day of the
events is an introduction to the platform at the capability level; it's not a coding
class, that would be impossible to fit.
</p>
        <p>
          <a href="http://cid-123ccd2a7ab10107.skydrive.live.com/browse.aspx/APAC%20Azure%20ISV">I've
shared the slides on SkyDrive</a>. Steal liberally if you find the material useful.
</p>
        <p>
 
</p>
        <iframe style="PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #fcfcfc; PADDING-LEFT: 0px; WIDTH: 98px; PADDING-RIGHT: 0px; HEIGHT: 115px; PADDING-TOP: 0px" title="Preview" marginheight="0" src="http://cid-123ccd2a7ab10107.skydrive.live.com/embedicon.aspx/APAC%20Azure%20ISV" frameborder="0" marginwidth="0" scrolling="no">
        </iframe>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=cb6599da-5785-4186-8ca1-68a0f32f4495" />
      </body>
      <title>Windows Azure Speaking Tour Slides</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,cb6599da-5785-4186-8ca1-68a0f32f4495.aspx</guid>
      <link>http://vasters.com/clemensv/2010/05/16/Windows+Azure+Speaking+Tour+Slides.aspx</link>
      <pubDate>Sun, 16 May 2010 08:31:17 GMT</pubDate>
      <description>&lt;p&gt;
I'm on a tour through several countries right now&amp;nbsp;and I'm talking to ISVs about
the Windows Azure platform, its capabilities and the many opportunities ISVs have
to transform the way they do business by moving to the cloud. The first day of the
events is an introduction to the platform at the capability level; it's not a coding
class, that would be impossible to fit.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://cid-123ccd2a7ab10107.skydrive.live.com/browse.aspx/APAC%20Azure%20ISV"&gt;I've
shared the slides on SkyDrive&lt;/a&gt;. Steal liberally if you find the material&amp;nbsp;useful.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;iframe style="PADDING-BOTTOM: 0px; BACKGROUND-COLOR: #fcfcfc; PADDING-LEFT: 0px; WIDTH: 98px; PADDING-RIGHT: 0px; HEIGHT: 115px; PADDING-TOP: 0px" title=Preview marginheight=0 src="http://cid-123ccd2a7ab10107.skydrive.live.com/embedicon.aspx/APAC%20Azure%20ISV" frameborder=0 marginwidth=0 scrolling=no&gt;
&lt;/iframe&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=cb6599da-5785-4186-8ca1-68a0f32f4495" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,cb6599da-5785-4186-8ca1-68a0f32f4495.aspx</comments>
      <category>AppFabric</category>
      <category>Architecture</category>
      <category>Azure</category>
      <category>Talks</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=238db3c9-4d49-4c6f-8ff9-a37eaae3eeaa</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,238db3c9-4d49-4c6f-8ff9-a37eaae3eeaa.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,238db3c9-4d49-4c6f-8ff9-a37eaae3eeaa.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=238db3c9-4d49-4c6f-8ff9-a37eaae3eeaa</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
My office neighbor, our Service Bus Test Lead Vishal Chowdhary put together a bundle
of code and documentation for how to use Service Bus with Server AppFabric and IIS
7.5. Here: <a title="http://code.msdn.microsoft.com/ServiceBusDublinIIS" href="http://code.msdn.microsoft.com/ServiceBusDublinIIS">http://code.msdn.microsoft.com/ServiceBusDublinIIS</a></p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=238db3c9-4d49-4c6f-8ff9-a37eaae3eeaa" />
      </body>
      <title>Hosting Service Bus endpoints in IIS and Server AppFabric (Dublin)</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,238db3c9-4d49-4c6f-8ff9-a37eaae3eeaa.aspx</guid>
      <link>http://vasters.com/clemensv/2010/05/09/Hosting+Service+Bus+Endpoints+In+IIS+And+Server+AppFabric+Dublin.aspx</link>
      <pubDate>Sun, 09 May 2010 23:45:33 GMT</pubDate>
      <description>&lt;p&gt;
My office neighbor, our Service Bus Test Lead Vishal Chowdhary put together a bundle
of code and documentation for how to use Service Bus with Server AppFabric and IIS
7.5. Here: &lt;a title=http://code.msdn.microsoft.com/ServiceBusDublinIIS href="http://code.msdn.microsoft.com/ServiceBusDublinIIS"&gt;http://code.msdn.microsoft.com/ServiceBusDublinIIS&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=238db3c9-4d49-4c6f-8ff9-a37eaae3eeaa" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,238db3c9-4d49-4c6f-8ff9-a37eaae3eeaa.aspx</comments>
      <category>AppFabric</category>
      <category>Azure</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=bf4c0637-7829-44e3-a2c4-0f2f135fb686</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,bf4c0637-7829-44e3-a2c4-0f2f135fb686.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,bf4c0637-7829-44e3-a2c4-0f2f135fb686.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=bf4c0637-7829-44e3-a2c4-0f2f135fb686</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At the bottom of this post you’ll find the DinnerNow version that I’ve been using
for my PDC09 talk. The video of that talk is now available at <a title="http://microsoftpdc.com/Sessions/SVC18" href="http://microsoftpdc.com/Sessions/SVC18">http://microsoftpdc.com/Sessions/SVC18</a> and
I recommend that you listen to the talk for context. 
</p>
        <p>
The DinnerNow drop I’m sharing here is a customized version of the <a href="http://dinnernow.net/">DinnerNow
3.1 version that’s up on CodePlex</a>. If I were you, I’d install the original version
and then unpack my zip file alongside of it and then use some kind of diff tool (the
Windows SDK’s WinDiff tool is a start) to look at the differences between the versions.
That will give you a raw overview of what I had to do. You’ll find that I had to add
and move a few things, but that the app didn’t change in any radical way.
</p>
        <p>
Remember that looking at the code is more important that making it run. There’s one
particular challenge you’d have right now with the Windows Azure CTP and that’s getting
the two (!) Windows Azure compute tokens needed for separating out the web and the
service tier as I’ve done here. It’s not difficult to consolidate the Web and the
Web Service tier into a single role, but since I had to do the migration within a
short period of time, I chose to split them up. 
</p>
        <p>
FWIW, I time-boxed the migration to 3 work days – which included learning about what
our buddies over in SQL Azure had done in the past months — and that turned out to
be a comfortable fit in terms of time.
</p>
        <p>
Another function of time-boxing is that you’re finding me disabling security on most
endpoints, including disabling the Access Control integration with Service Bus for
most endpoints by setting the <em>relayClientAuthenticationType</em> attribute on
the respective binding elements to <em>None</em>. 
</p>
        <p>
I know that’s a sin, but I didn’t want to cause too much churn in the first iteration.
The original version of DinnerNow is conveniently using Windows authentication/authorization
for its communication paths. While that’s ok for a LAN setup, things get more complicated
for an actual WAN setup that the DinnerNow scenario calls for. That would spawn a
wholly different discussion that shines the spotlight on our Access Control service
and why it’s useful – even required – for that scenario. In order not to overwhelm
everyone, I left that out for this round and will revisit that aspect in the next
weeks – or maybe one of our (aspiring?) MVPs or RDs will beat me to it.
</p>
        <p>
I’m also going to work with the guys who wrote DinnerNow to find a way to host this
modified version of Dinner Now with the on-premise runtime bits expressly not on my
primary dev machine, where they’d live now. 
</p>
        <p>
 
</p>
        <p>
          <strong>Here what you need to do to get it to run</strong>
        </p>
        <p>
I know this is rough. Writing up the long version of this is going to take some time
and I prefer getting the bits to you early over me sitting here writing pages of docs.
Maybe you can even help ;-) 
</p>
        <ol>
          <li>
First, you’ll need to go to the Windows Azure portal and get the SDKs and tokens/accounts.
The <a href="http://www.microsoft.com/windowsazure/getstarted/">Getting Started</a> page
has all the data and links you need so I’m not going to repeat them here in much detail.
You will need at least one Windows Azure compute account (<a href="https://connect.microsoft.com/Survey/NominationSurvey.aspx?SurveyID=7044&amp;ProgramID=2500&amp;SiteID=681">apply
here</a>), one SQL Azure account (<a href="https://connect.microsoft.com/SQLAzure/Survey/NominationSurvey.aspx?SurveyID=5719&amp;ProgramID=2089">apply
here</a>), and an AppFabric account (no application needed, <a href="https://netservices.azure.com/">just
log in w/ LiveID</a>).  
</li>
          <li>
Download and install the regular version <a href="http://dinnernow.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=31480">DinnerNow
3.1 from Codeplex</a>. This will drop a “Configure DinnerNow 3.1” shortcut on your
desktop. Run that, install all prerequisites and make sure DinnerNow runs locally
before you proceed. 
</li>
          <li>
You will later need the databases that the setup created in your local SQLEXPRESS
instance by setup. You’ll have to make a few changes, though. 
<ol><li>
First, (<a href="http://www.microsoft.com/downloads/details.aspx?familyid=08E52AC2-1D62-45F6-9A4A-4B76A8564A2B&amp;displaylang=en">download,
install</a>, and) open SQL Server Management Studio, connect to your SQL Server Express
instance and switch to “SQL Server and Windows Authentication mode” on the <em>Server
Properties</em> under <em>Security</em>. Then you’ll need to go to to the Security
settings and either create a new account and grant it all rights on the <strong>aspnetdb</strong> database
or just enable the ‘sa’ account and set its password.  
</li><li>
Then you need to find the “SQL Server Configuration Manager” and enable TCP for your
SQLEXPRESS instance <a href="http://msdn.microsoft.com/en-us/library/ms165718.aspx">like
this</a>. The default port will be 1433. If you have a full SQL Server instance on
your dev machine and it’s configured for TCP the easiest is to suspend that for the
moment and allow the SQLEXPRESS instance to squat the port.</li></ol></li>
          <li>
Unpack the ZIP file appended below into a directory on your machine. At this point
it should be ok to override the existing DinnerNow directory, but I’d keep things
side-by-side for reference. If you copy side-by-side, grab the ./solution/DinnerNow
– Web/DinnerNow.WebUX/images/’ directory from your local installation and copy it
into the location where you unzipped the file here. I left out the images due to their
size. And just as with the normal DinnerNow installation you’ll find a solution file
named “<strong>DinnerNow  - Main.sln</strong>” in the unpacked directory – open
that in Visual Studio 2008 (not 2010!) because you’ll have to make some changes and
edits. 
</li>
          <li>
If you are lucky enough to have two Windows Azure compute accounts, you can skip this
step. Otherwise, you will have to restructure the application a bit:  
<ol><li>
In the <em>“DinnerNow – WA” </em>solution branch where the Windows Azure deployment
project reside you’ll have to consolidate the <em>DinnerNow.WindowsAzure</em> project
and the <em>DinnerNow.WindowsAzureAppSrv </em>projects into one by replicating the <em>DinnerNow.DBBridge</em> reference
into the <em>DinnerNow.WindowsAzure</em> project and abandoning/deleting the rest. 
</li><li>
In the “<em>DinnerNow – Web”</em> solution branch you will have to modify the <em>DinnerNow.WebUX</em> project
by merging the DinnerNow.ServiceHost project from the “<em>DinnerNow -ServicePortfolio2” </em>branch
into it, including merging the config files. In the original DinnerNow the hosting
default is that the ServiceHost  project lives in the ./services subdirectory
of the WebUX app. You can also do it that way, but you’ll have to change the respective
client URIs to point to the right path.</li></ol></li>
          <li>
In the ./database directory is a file called <em>SQLAzureImport.sql. </em>That’s the
exported and customized script for the DinnerNow restaurants and menus database. Create
a new database (1GB is enough) and load the DB with this script. You can do this with
the command line or with SQL Management Studio. <a href="http://msdn.microsoft.com/en-us/library/ee621784.aspx">The
SQL Azure docs will tell you how</a>. 
</li>
          <li>
Now you’ll need to do a range of search/replace steps across the whole project. These
are mostly in *.config files - a few places are in the code, which I count as bugs,
but those are faithfully carried over from the original: 
<ol><li>
Find all occurrences of <strong>sqlazure-instance</strong> and replace them with your
unqualified SQL Azure <em>server name</em> (might look like this: tn0a1b2c3d) 
</li><li>
Find all occurrences of <strong>sqlazure-dbname</strong> and replace them with your
SQL Azure <em>database name</em></li><li>
Find all occurrences of <strong>sqlazure-acct</strong> and replace them with your
SQL Azure <em>administrator username</em></li><li>
Find all occurrences of <strong>sqlazure-password</strong> and replace them with your
SQL Azure <em>administrator password</em></li><li>
Find all occurrences of <strong>appfabricservicebus-ns</strong> and replace them with
your unqualified AppFabric <em>namespace name</em></li><li>
Find all occurrences of <strong>appfabricservicebus-key</strong> and replace them
with your AppFabric <em>Service Bus</em><em>issuer key</em></li><li>
Find all occurrences of <strong>windowsazuresvcrole-acct</strong> and replace them
with the name of your Windows Azure compute account. If you have just one, use that
(given you’ve done the rework in step 4), if you have two use the account-name where
you will host the service tier. 
</li><li>
Find all occurrences of <strong>sqlserver-password</strong> and replace them with
your <em>local<strong></strong></em>SQL Server Express instance’s ‘sa’ account password. 
</li></ol></li>
          <li>
Do a full batch Rebuild of the whole project 
</li>
          <li>
Go to the “DinnerNow –WA” solution and publish the project(s) to your Windows Azure
compute account(s). If you had to consolidate them you’ll have one package to deploy,
if you left things as they are you’ll have two packages to deploy. You can also run
these packages in the local DevFabric to test things out. 
</li>
          <li>
The executables you need to run are going to be dropped into the .\bin directory by
the build. You need to run all 6 apps – but you could run them on 6 different machines
– the two workflow hosts each assume the local presence of the DinnerNowWF database: 
<ol><li><strong>CloudTraceRecorder.exe</strong> – this is the simple event listener app. You
can run this right away to observe the apps starting up inside of Azure as they write
events to the event listener. You can and should run this as you deploy. You can run
any number of instances of CloudTraceRecorder anywhere. 
</li><li><strong>PortBridge.exe</strong> – this is the on-premise bridge-head for bridging
to your local SQL Server Express instance so that the cloud application can get at
its membership database that you host for it on your machine. After the search/replace
steps you will notice that you have modified connection strings that point to a SQL
Server role peeking out of your *AppSrv role. The secret ingredient is in the DinnerNow.DBBridge
role that’s listening for TCP connections on behalf of your on-premise SQL Server
and that connects them down to your local server with the logic in <em>Microsoft.Samples.ServiceBus.Connections</em>.
This is the same code that’s in <a href="http://vasters.com/clemensv/PermaLink,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx">PortBridge</a>. 
</li><li><strong>DinnerNow.OrderProcessingHost.exe</strong> is the (new) host application for
the workflow that handles the order process. 
</li><li><strong>DinnerNow.RestaurantProcessingHost.exe</strong> is the (new) host application
for the workflow that handles the restaurant process. 
</li><li><strong>DinnerNowKiosk.exe</strong> is the only slightly modified version of the DinnerNow
in-restaurant kiosk 
</li><li>
Not in .\bin but rather to be started/deployed from VS is the also just slightly modified
Windows Mobile app for the delivery app</li></ol></li>
        </ol>
        <p>
 
</p>
        <p>
Please also mind that the DinnerNow Powershell support and the other test and diagnostics
capabilities haven’t been touched here, yet. 
</p>
        <p>
Oh, and … this is provided as-is … I’ll do my best to discuss some of the patterns
over the next several weeks, but I don’t have time to provide 1:1 support.
</p>
        <p>
Here’s the code:
</p>
        <a href="http://vasters.com/clemensv/content/binary/DinnerNow-SVC18-PDC09.zip">DinnerNow-SVC18-PDC09.zip
(2.35 MB)</a>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=bf4c0637-7829-44e3-a2c4-0f2f135fb686" />
      </body>
      <title>The Rough Setup Script for PDC09 SVC18 - Getting DinnerNow! to run on Windows Azure</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,bf4c0637-7829-44e3-a2c4-0f2f135fb686.aspx</guid>
      <link>http://vasters.com/clemensv/2009/11/23/The+Rough+Setup+Script+For+PDC09+SVC18+Getting+DinnerNow+To+Run+On+Windows+Azure.aspx</link>
      <pubDate>Mon, 23 Nov 2009 23:42:16 GMT</pubDate>
      <description>&lt;p&gt;
At the bottom of this post you’ll find the DinnerNow version that I’ve been using
for my PDC09 talk. The video of that talk is now available at &lt;a title=http://microsoftpdc.com/Sessions/SVC18 href="http://microsoftpdc.com/Sessions/SVC18"&gt;http://microsoftpdc.com/Sessions/SVC18&lt;/a&gt; and
I recommend that you listen to the talk for context. 
&lt;/p&gt;
&lt;p&gt;
The DinnerNow drop I’m sharing here is a customized version of the &lt;a href="http://dinnernow.net/"&gt;DinnerNow
3.1 version that’s up on CodePlex&lt;/a&gt;. If I were you, I’d install the original version
and then unpack my zip file alongside of it and then use some kind of diff tool (the
Windows SDK’s WinDiff tool is a start) to look at the differences between the versions.
That will give you a raw overview of what I had to do. You’ll find that I had to add
and move a few things, but that the app didn’t change in any radical way.
&lt;/p&gt;
&lt;p&gt;
Remember that looking at the code is more important that making it run. There’s one
particular challenge you’d have right now with the Windows Azure CTP and that’s getting
the two (!) Windows Azure compute tokens needed for separating out the web and the
service tier as I’ve done here. It’s not difficult to consolidate the Web and the
Web Service tier into a single role, but since I had to do the migration within a
short period of time, I chose to split them up. 
&lt;/p&gt;
&lt;p&gt;
FWIW, I time-boxed the migration to 3 work days – which included learning about what
our buddies over in SQL Azure had done in the past months — and that turned out to
be a comfortable fit in terms of time.
&lt;/p&gt;
&lt;p&gt;
Another function of time-boxing is that you’re finding me disabling security on most
endpoints, including disabling the Access Control integration with Service Bus for
most endpoints by setting the &lt;em&gt;relayClientAuthenticationType&lt;/em&gt; attribute on
the respective binding elements to &lt;em&gt;None&lt;/em&gt;. 
&lt;/p&gt;
&lt;p&gt;
I know that’s a sin, but I didn’t want to cause too much churn in the first iteration.
The original version of DinnerNow is conveniently using Windows authentication/authorization
for its communication paths. While that’s ok for a LAN setup, things get more complicated
for an actual WAN setup that the DinnerNow scenario calls for. That would spawn a
wholly different discussion that shines the spotlight on our Access Control service
and why it’s useful – even required – for that scenario. In order not to overwhelm
everyone, I left that out for this round and will revisit that aspect in the next
weeks – or maybe one of our (aspiring?) MVPs or RDs will beat me to it.
&lt;/p&gt;
&lt;p&gt;
I’m also going to work with the guys who wrote DinnerNow to find a way to host this
modified version of Dinner Now with the on-premise runtime bits expressly not on my
primary dev machine, where they’d live now. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Here what you need to do to get it to run&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I know this is rough. Writing up the long version of this is going to take some time
and I prefer getting the bits to you early over me sitting here writing pages of docs.
Maybe you can even help ;-) 
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
First, you’ll need to go to the Windows Azure portal and get the SDKs and tokens/accounts.
The &lt;a href="http://www.microsoft.com/windowsazure/getstarted/"&gt;Getting Started&lt;/a&gt; page
has all the data and links you need so I’m not going to repeat them here in much detail.
You will need at least one Windows Azure compute account (&lt;a href="https://connect.microsoft.com/Survey/NominationSurvey.aspx?SurveyID=7044&amp;amp;ProgramID=2500&amp;amp;SiteID=681"&gt;apply
here&lt;/a&gt;), one SQL Azure account (&lt;a href="https://connect.microsoft.com/SQLAzure/Survey/NominationSurvey.aspx?SurveyID=5719&amp;amp;ProgramID=2089"&gt;apply
here&lt;/a&gt;), and an AppFabric account (no application needed, &lt;a href="https://netservices.azure.com/"&gt;just
log in w/ LiveID&lt;/a&gt;).&amp;nbsp; 
&lt;li&gt;
Download and install the regular version &lt;a href="http://dinnernow.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=31480"&gt;DinnerNow
3.1 from Codeplex&lt;/a&gt;. This will drop a “Configure DinnerNow 3.1” shortcut on your
desktop. Run that, install all prerequisites and make sure DinnerNow runs locally
before you proceed. 
&lt;li&gt;
You will later need the databases that the setup created in your local SQLEXPRESS
instance by setup. You’ll have to make a few changes, though. 
&lt;ol&gt;
&lt;li&gt;
First, (&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=08E52AC2-1D62-45F6-9A4A-4B76A8564A2B&amp;amp;displaylang=en"&gt;download,
install&lt;/a&gt;, and) open SQL Server Management Studio, connect to your SQL Server Express
instance and switch to “SQL Server and Windows Authentication mode” on the &lt;em&gt;Server
Properties&lt;/em&gt; under &lt;em&gt;Security&lt;/em&gt;. Then you’ll need to go to to the Security
settings and either create a new account and grant it all rights on the &lt;strong&gt;aspnetdb&lt;/strong&gt; database
or just enable the ‘sa’ account and set its password.&amp;nbsp; 
&lt;li&gt;
Then you need to find the “SQL Server Configuration Manager” and enable TCP for your
SQLEXPRESS instance &lt;a href="http://msdn.microsoft.com/en-us/library/ms165718.aspx"&gt;like
this&lt;/a&gt;. The default port will be 1433. If you have a full SQL Server instance on
your dev machine and it’s configured for TCP the easiest is to suspend that for the
moment and allow the SQLEXPRESS instance to squat the port.&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;
Unpack the ZIP file appended below into a directory on your machine. At this point
it should be ok to override the existing DinnerNow directory, but I’d keep things
side-by-side for reference. If you copy side-by-side, grab the ./solution/DinnerNow
– Web/DinnerNow.WebUX/images/’ directory from your local installation and copy it
into the location where you unzipped the file here. I left out the images due to their
size. And just as with the normal DinnerNow installation you’ll find a solution file
named “&lt;strong&gt;DinnerNow&amp;nbsp; - Main.sln&lt;/strong&gt;” in the unpacked directory – open
that in Visual Studio 2008 (not 2010!) because you’ll have to make some changes and
edits. 
&lt;li&gt;
If you are lucky enough to have two Windows Azure compute accounts, you can skip this
step. Otherwise, you will have to restructure the application a bit:&amp;nbsp; 
&lt;ol&gt;
&lt;li&gt;
In the &lt;em&gt;“DinnerNow – WA” &lt;/em&gt;solution branch where the Windows Azure deployment
project reside you’ll have to consolidate the &lt;em&gt;DinnerNow.WindowsAzure&lt;/em&gt; project
and the &lt;em&gt;DinnerNow.WindowsAzureAppSrv &lt;/em&gt;projects into one by replicating the &lt;em&gt;DinnerNow.DBBridge&lt;/em&gt; reference
into the &lt;em&gt;DinnerNow.WindowsAzure&lt;/em&gt; project and abandoning/deleting the rest. 
&lt;li&gt;
In the “&lt;em&gt;DinnerNow – Web”&lt;/em&gt; solution branch you will have to modify the &lt;em&gt;DinnerNow.WebUX&lt;/em&gt; project
by merging the DinnerNow.ServiceHost project from the “&lt;em&gt;DinnerNow -ServicePortfolio2” &lt;/em&gt;branch
into it, including merging the config files. In the original DinnerNow the hosting
default is that the ServiceHost&amp;nbsp; project lives in the ./services subdirectory
of the WebUX app. You can also do it that way, but you’ll have to change the respective
client URIs to point to the right path.&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;
In the ./database directory is a file called &lt;em&gt;SQLAzureImport.sql. &lt;/em&gt;That’s the
exported and customized script for the DinnerNow restaurants and menus database. Create
a new database (1GB is enough) and load the DB with this script. You can do this with
the command line or with SQL Management Studio. &lt;a href="http://msdn.microsoft.com/en-us/library/ee621784.aspx"&gt;The
SQL Azure docs will tell you how&lt;/a&gt;. 
&lt;li&gt;
Now you’ll need to do a range of search/replace steps across the whole project. These
are mostly in *.config files - a few places are in the code, which I count as bugs,
but those are faithfully carried over from the original: 
&lt;ol&gt;
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlazure-instance&lt;/strong&gt; and replace them with your
unqualified SQL Azure &lt;em&gt;server name&lt;/em&gt; (might look like this: tn0a1b2c3d) 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlazure-dbname&lt;/strong&gt; and replace them with your
SQL Azure &lt;em&gt;database name&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlazure-acct&lt;/strong&gt; and replace them with your
SQL Azure &lt;em&gt;administrator username&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlazure-password&lt;/strong&gt; and replace them with your
SQL Azure &lt;em&gt;administrator password&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;appfabricservicebus-ns&lt;/strong&gt; and replace them with
your unqualified AppFabric &lt;em&gt;namespace name&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;appfabricservicebus-key&lt;/strong&gt; and replace them
with your AppFabric &lt;em&gt;Service Bus&lt;/em&gt; &lt;em&gt;issuer key&lt;/em&gt; 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;windowsazuresvcrole-acct&lt;/strong&gt; and replace them
with the name of your Windows Azure compute account. If you have just one, use that
(given you’ve done the rework in step 4), if you have two use the account-name where
you will host the service tier. 
&lt;li&gt;
Find all occurrences of &lt;strong&gt;sqlserver-password&lt;/strong&gt; and replace them with
your &lt;em&gt;local&lt;strong&gt; &lt;/strong&gt;&lt;/em&gt;SQL Server Express instance’s ‘sa’ account password. 
&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;
Do a full batch Rebuild of the whole project 
&lt;li&gt;
Go to the “DinnerNow –WA” solution and publish the project(s) to your Windows Azure
compute account(s). If you had to consolidate them you’ll have one package to deploy,
if you left things as they are you’ll have two packages to deploy. You can also run
these packages in the local DevFabric to test things out. 
&lt;li&gt;
The executables you need to run are going to be dropped into the .\bin directory by
the build. You need to run all 6 apps – but you could run them on 6 different machines
– the two workflow hosts each assume the local presence of the DinnerNowWF database: 
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;CloudTraceRecorder.exe&lt;/strong&gt; – this is the simple event listener app. You
can run this right away to observe the apps starting up inside of Azure as they write
events to the event listener. You can and should run this as you deploy. You can run
any number of instances of CloudTraceRecorder anywhere. 
&lt;li&gt;
&lt;strong&gt;PortBridge.exe&lt;/strong&gt; – this is the on-premise bridge-head for bridging
to your local SQL Server Express instance so that the cloud application can get at
its membership database that you host for it on your machine. After the search/replace
steps you will notice that you have modified connection strings that point to a SQL
Server role peeking out of your *AppSrv role. The secret ingredient is in the DinnerNow.DBBridge
role that’s listening for TCP connections on behalf of your on-premise SQL Server
and that connects them down to your local server with the logic in &lt;em&gt;Microsoft.Samples.ServiceBus.Connections&lt;/em&gt;.
This is the same code that’s in &lt;a href="http://vasters.com/clemensv/PermaLink,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx"&gt;PortBridge&lt;/a&gt;. 
&lt;li&gt;
&lt;strong&gt;DinnerNow.OrderProcessingHost.exe&lt;/strong&gt; is the (new) host application for
the workflow that handles the order process. 
&lt;li&gt;
&lt;strong&gt;DinnerNow.RestaurantProcessingHost.exe&lt;/strong&gt; is the (new) host application
for the workflow that handles the restaurant process. 
&lt;li&gt;
&lt;strong&gt;DinnerNowKiosk.exe&lt;/strong&gt; is the only slightly modified version of the DinnerNow
in-restaurant kiosk 
&lt;li&gt;
Not in .\bin but rather to be started/deployed from VS is the also just slightly modified
Windows Mobile app for the delivery app&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Please also mind that the DinnerNow Powershell support and the other test and diagnostics
capabilities haven’t been touched here, yet. 
&lt;/p&gt;
&lt;p&gt;
Oh, and … this is provided as-is … I’ll do my best to discuss some of the patterns
over the next several weeks, but I don’t have time to provide 1:1 support.
&lt;/p&gt;
&lt;p&gt;
Here’s the code:
&lt;/p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/DinnerNow-SVC18-PDC09.zip"&gt;DinnerNow-SVC18-PDC09.zip
(2.35 MB)&lt;/a&gt;&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=bf4c0637-7829-44e3-a2c4-0f2f135fb686" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,bf4c0637-7829-44e3-a2c4-0f2f135fb686.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
      <category>Talks</category>
      <category>AppFabric</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=3e35d8bd-b755-453f-8c63-1a57c570eb4c</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=3e35d8bd-b755-453f-8c63-1a57c570eb4c</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Building “hybrid” cloud applications where parts of an an app lives up in a cloud
infrastructure and other parts of the infrastructure live at a hosting site, or a
data center, or even in your house ought to be simple – especially in this day and
age of Web services. You create a Web service, make it accessible through your firewall
and NAT, and the the cloud-hosted app calls it. That’s as easy as it ought to be.
</p>
        <p>
Unfortunately it’s not always that easy. If the server sits behind an Internet connection
with dynamically assigned IP addresses, if the upstream ISP is blocking select ports,
if it’s not feasible to open up inbound firewall ports, or if you have no influence
over the infrastructure whatsoever, reaching an on-premise service from the cloud
(or anywhere else) is a difficult thing to do. For these scenarios (and others) our
team is building the <em><a href="http://msdn.microsoft.com/en-us/azure/netservices.aspx">Windows
Azure platform AppFabric</a> Service Bus</em> (friends call us just <em>Service Bus</em>). 
</p>
        <p>
Now – the Service Bus and the client bits in the <em>Microsoft.ServiceBus.dll </em>assembly
are great if you have services can can be readily hooked up into the Service Bus because
they’re built with WCF. For services that aren’t built with WCF, but are at least
using HTTP, I’ve <a href="http://vasters.com/clemensv/PermaLink,guid,83edb04a-5696-401c-a919-8c1f379d130c.aspx">previously
shown a way</a> to hook them into Service Bus and have also demoed an updated version
of that capability at Sun’s Java One. I’ll release an update for those bits tomorrow
after my talk at PDC09 – the version currently here on my blog (ironically) doesn’t
play well with SOAP and also doesn’t have rewrite capabilities for WSDL. The new version
does. 
</p>
        <p>
But what if your service isn’t a WCF service or doesn’t speak HTTP? What if it speaks
SMTP, SNMP, POP, IMAP, RDP, TDS, SSH, ETC? 
</p>
        <p>
          <strong>Introducing Port Bridge</strong>
        </p>
        <p>
“Port Bridge” – which is just a descriptive name for this code sample, not an attempt
at branding – is a point-to-point tunneling utility to help with these scenarios.
Port Bridge consists of two components, the “Port Bridge Service” and the “Port Bridge
Agent”. Here’s a picture:
</p>
        <p>
          <a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/865a80e15ca0_D9A4/image_2.png">
            <img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title="image" border="0" alt="image" src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/865a80e15ca0_D9A4/image_thumb.png" width="611" height="220" />
          </a>
        </p>
        <p>
The Agent’s job is to listen for and accept TCP or Named Pipe connections on a configurable
port or local pipe name. The Service’s job is to accept for incoming connections from
the Agent, establish a duplex channel with the Agent, and pump the data from the Agent
to the actual listening service – and vice versa. It’s actually quite simple. In the
picture above you see that the Service is configured to connect to a SQL Server listening
at the SQL Server default port 1433 and that the Agent – running on a different machine,
is listening on port 1433 as well, thus mapping the remote SQL Server onto the Agent
machine as if it ran there. You can (and I think of that as to be more common) map
the service on the Agent to any port you like – say higher up at 41433.
</p>
        <p>
In order to increase the responsiveness and throughput for protocols that are happy
to kill and reestablish connections such as HTTP does, “Port Bridge” is always multiplexing
concurrent traffic that’s flowing between two parties on the same logical socket.
When using Port Bridge to bridge to a remote HTTP proxy that the Service machine can
see, but the Agent machine can’t see (which turns out to be the at-home scenario that
this capability emerged from) there are very many and very short-lived connections
being tunneled through the channel. Creating a new Service Bus channel for each of
these connections is feasible – but not very efficient. Holding on to a connection
for an extended period of time and multiplexing traffic over it is also beneficial
in the Port Bridge case because it is using the Service Bus <em>Hybrid</em> connection
mode by default. With <em>Hybrid</em>, all connections are first established through
the Service Bus Relay and then our bits do a little “NAT dance” trying to figure out
whether there’s a way to connect both parties with a direct socket – if that works
the connection gets upgraded to the most direct connections in-flight. The probing,
handshake, and upgrade of the socket may take 2-20 seconds and there’s some degree
of luck involved to get that direct socket established on a very busy NAT – and thus
we want to maximize the use of that precious socket instead of throwing it away all
the time.
</p>
        <p>
          <strong>That seems familiar?!</strong>
        </p>
        <p>
You may notice that <a href="http://vasters.com/clemensv/PermaLink,guid,26dc5df1-8b8c-4f71-8765-8904e584505b.aspx">SocketShifter</a> (built
by our friends at <a href="http://www.aws.net/">AWS in the UK</a>) is quite similar
to Port Bridge. Even though the timing of the respective releases may not suggest
it, Port Bridge is indeed Socketshifter’s older brother. Because we couldn’t make
up our mind on whether to release Port Bridge for a while, I had AWS take a look at
the service contract shown below and explained a few principles that I’m also explaining
here and they had a first version of Socketshifter running within a few hours. There’s
nothing wrong with having two variants of the same thing. 
</p>
        <p>
          <strong>How does it work?</strong>
        </p>
        <p>
Since I’m publishing this as a sample, I obviously need to spend a little time on
the “how”, even I’ll limit that here and will explain that in more detail in a future
post. At the heart of the app, the contract that’s used between the Agent and the
Service is a simple duplex WCF contract:
</p>
        <pre class="code">    [<span style="COLOR: #2b91af">ServiceContract</span>(Namespace=<span style="COLOR: #a31515">"n:"</span>,
Name=<span style="COLOR: #a31515">"idx"</span>, CallbackContract=<span style="COLOR: blue">typeof</span>(<span style="COLOR: #2b91af">IDataExchange</span>),
SessionMode=<span style="COLOR: #2b91af">SessionMode</span>.Required)] <span style="COLOR: blue">public
interface </span><span style="COLOR: #2b91af">IDataExchange </span>{ [<span style="COLOR: #2b91af">OperationContract</span>(Action=<span style="COLOR: #a31515">"c"</span>,
IsOneWay = <span style="COLOR: blue">true</span>, IsInitiating=<span style="COLOR: blue">true</span>)] <span style="COLOR: blue">void </span>Connect(<span style="COLOR: blue">string </span>i);
[<span style="COLOR: #2b91af">OperationContract</span>(Action = <span style="COLOR: #a31515">"w"</span>,
IsOneWay = <span style="COLOR: blue">true</span>)] <span style="COLOR: blue">void </span>Write(<span style="COLOR: #2b91af">TransferBuffer </span>d);
[<span style="COLOR: #2b91af">OperationContract</span>(Action = <span style="COLOR: #a31515">"d"</span>,
IsOneWay = <span style="COLOR: blue">true</span>, IsTerminating = <span style="COLOR: blue">true</span>)] <span style="COLOR: blue">void </span>Disconnect();
}</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
There’s a way to establish a session, send data either way, and close the session.
The <em>TransferBuffer</em> type is really just a trick to avoid extra buffer copies
during serialization for efficiency reasons. But that’s it. The rest of Port Bridge
is a set of queue-buffered streams and pumps to make the data packets flow smoothly
and to accept inbound sockets/pipes and dispatch them out to the proxied services.
What’s noteworthy is that Port Bridge doesn’t use WCF streaming, but sends data in
chunks – which allows for much better flow control and enables multiplexing.
</p>
        <p>
Now you might say <em>You are using a WCF ServiceContract?</em> <em>Isn’t that
using SOAP and doesn’t that cause ginormous overhead?</em> No, it doesn’t. We’re using
the WCF binary encoder in session mode here. That’s about as efficient as you can
get it on the wire with serialized data. The per-frame SOAP overhead for net.tcp with
the binary encoder in session mode is in the order of 40-50 bytes per message because
of dictionary-based metadata compression. The binary encoder also isn’t doing any
base64 trickery but treats binary as binary – one byte is one byte. Port Bridge is
using a default frame size of 64K (which gets filled up in high-volume streaming cases
due to the built-in Nagling support) and so we’re looking at an overhead of far less
than 0.1%. That’s not shabby. 
</p>
        <p>
          <strong>How do I use it?</strong>
        </p>
        <p>
This is a code sample and thus you’ll have to build it using Visual Studio 2008. You’ll
find three code projects: <em>PortBridge</em> (the Service), <em>PortBridgeAgent</em> (the
Agent), and the <em>Microsoft.Samples.ServiceBus.Connections</em> assembly that contains
the bulk of the logic for Port Bridge. It’s mostly straightforward to embed the agent
side or the service side into other hosts and I’ll show that in a separate post. 
</p>
        <p>
          <strong>Service</strong>
        </p>
        <p>
The service’s exe file is “PortBridge.exe” and is both a console app and a Windows
Service. If the Windows Service isn’t registered, the app will always start as a console
app. If the Windows Service is registered (with the installer or with installutil.exe)
you can force console-mode with the –c command line option.
</p>
        <p>
The app.config file on the Service Side (PortBridge/app.config, PortBridge.exe.config
in the binaries folder) specifies what ports or named pipes you want to project into
Service Bus:
</p>
        <pre class="code">
          <span style="COLOR: blue"> &lt;</span>
          <span style="COLOR: #a31515">portBridge </span>
          <span style="COLOR: red">serviceBusNamespace</span>
          <span style="COLOR: blue">=</span>"<span style="COLOR: blue">mynamespace</span>" <span style="COLOR: red">serviceBusIssuerName</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">owner</span>" <span style="COLOR: red">serviceBusIssuerSecret</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">xxxxxxxx</span>" <span style="COLOR: red">localHostName</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">mybox</span>"<span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">hostMappings</span><span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">add </span><span style="COLOR: red">targetHost</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">3389</span>" <span style="COLOR: blue">/&gt;
&lt;/</span><span style="COLOR: #a31515">hostMappings</span><span style="COLOR: blue">&gt;
&lt;/</span><span style="COLOR: #a31515">portBridge</span><span style="COLOR: blue">&gt;</span></pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
The <em>serviceBusNamespace</em> attribute takes your Service Bus namespace name,
and the <em>serviceBusIssuerSecret</em> the respective secret. The <em>serviceBusIssuerName</em> should
remain “owner” unless you know why you want to change it. If you don’t have an <em>AppFabric </em>account
you might not understand what I’m writing about: <a href="https://netservices.azure.com">Go
make one</a>.  
</p>
        <p>
The <em>localHostName</em> attribute is optional and when set, it’s the name that’s
being used to map “localhost” into your Service Bus namespace. By default the name
that’s being used is the good old Windows computer-name.
</p>
        <p>
The <em>hostMappings </em>section contains a list of hosts and rules for what you
want to project out to Service Bus. Mind that all inbound connections to the endpoints
generated from the host mappings section are protected by the Access Control service
and require a token that grants access to your namespace – which is already very different
from opening up a port in your firewall. If you open up port 3389 (Remote Desktop)
through your firewall and NAT, everyone can walk up to that port and try their password-guessing
skills. If you open up port 3389 via Port Bridge, you first need to get through the
Access Control gate before you can even get at the remote port. 
</p>
        <p>
New host mappings are added with the <em>add</em> element. You can add any host that
the machine running the Port Bridge service can “see” via the network. The <em>allowedPorts </em>and <em>allowedPipes</em> attributes
define with TCP ports and/or which local named pipes are accessible. Examples:
</p>
        <ul>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">3389</span>" <span style="COLOR: blue">/&gt; </span>project
the local machine into Service Bus and only allow Remote Desktop (3389) 
</li>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">3389,1433</span>" <span style="COLOR: blue">/&gt; </span>project
the local machine into Service Bus and allow Remote Desktop (3389) and SQL Server
TDS (1433) 
</li>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">*</span>" <span style="COLOR: blue">/&gt; </span>project
the local machine into Service Bus and only allow any TCP port connection 
</li>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">localhost</span>" <span style="COLOR: red">allowedPipes</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">sql/query</span>" <span style="COLOR: blue">/&gt; </span>project
the local machine into Service Bus and allow no TCP connections but all named pipe
connections to \.\pipes\sql\query 
</li>
          <li>
            <span style="COLOR: blue">&lt;</span>
            <span style="COLOR: #a31515">add </span>
            <span style="COLOR: red">targetHost</span>
            <span style="COLOR: blue">=</span>"<span style="COLOR: blue">otherbox</span>" <span style="COLOR: red">allowedPorts</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">1433</span>" <span style="COLOR: blue">/&gt; </span>project
the machine “otherbox” into Service Bus and allow SQL Server TDS connections via TCP 
</li>
        </ul>
        <p>
          <strong>Agent</strong>
        </p>
        <p>
The agent’s exe file is “PortBridgeAgent.exe” and is also both a console app and a
Windows Service. 
</p>
        <p>
The app.config file on the Agent side (PortBridgeAgent/app.config, PortBridgeAgent.exe.config
in the binaries folder) specifies which ports or pipes you want to project into the
Agent machine and whether and how you want to firewall these ports. The firewall rules
here are not interacting with your local firewall. This is an additional layer of
protection.
</p>
        <pre class="code">
          <span style="COLOR: blue"> &lt;</span>
          <span style="COLOR: #a31515">portBridgeAgent </span>
          <span style="COLOR: red">serviceBusNamespace</span>
          <span style="COLOR: blue">=</span>"<span style="COLOR: blue">mysolution</span>" <span style="COLOR: red">serviceBusIssuerName</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">owner</span>" <span style="COLOR: red">serviceBusIssuerSecret</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">xxxxxxxx</span>"<span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">portMappings</span><span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">port </span><span style="COLOR: red">localTcpPort</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">13389</span>" <span style="COLOR: red">targetHost</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">mymachine</span>" <span style="COLOR: red">remoteTcpPort</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">3389</span>"<span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">firewallRules</span><span style="COLOR: blue">&gt;
&lt;</span><span style="COLOR: #a31515">rule </span><span style="COLOR: red">source</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">127.0.0.1</span>" <span style="COLOR: blue">/&gt;
&lt;</span><span style="COLOR: #a31515">rule </span><span style="COLOR: red">sourceRangeBegin</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">10.0.0.0</span>" <span style="COLOR: red">sourceRangeEnd</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">10.255.255.255</span>" <span style="COLOR: blue">/&gt;
&lt;/</span><span style="COLOR: #a31515">firewallRules</span><span style="COLOR: blue">&gt;
&lt;/</span><span style="COLOR: #a31515">port</span><span style="COLOR: blue">&gt;
&lt;/</span><span style="COLOR: #a31515">portMappings</span><span style="COLOR: blue">&gt;
&lt;/</span><span style="COLOR: #a31515">portBridgeAgent</span><span style="COLOR: blue">&gt;</span></pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
Again, the <em>serviceBusNamespace</em> attribute takes your Service Bus namespace
name, and the <em>serviceBusIssuerSecret</em> the respective secret. 
</p>
        <p>
The <em>portMappings</em> collection holds the individual ports or pipes you want
to bring onto the local machine. Shown above is a mapping of Remote Desktop (port
3389 on the machine with the computer name or <em>localHostName</em> ‘mymachine’)
to the local port 13389. Once Service and Agent are running, you can connect to the
agent machine on port 13389 using the Remote Desktop client – with PortBridge mapping
that to port 3389 on the remote box. 
</p>
        <p>
The <em>firewallRules</em> collection allows (un-)constraining the TCP clients that
may connect to the projected port. By default, only connections from the same machine
are permitted.
</p>
        <p>
For named pipes, the configuration is similar, even though there are no firewall rules
and named pipes are always constrained to local connectivity by a set of ACLs that
are applied to the pipe. Pipe names must be relative. Here’s how a named pipe projection
of a default SQL Server instance could look like:
</p>
        <p>
          <span style="COLOR: blue">     &lt;</span>
          <span style="COLOR: #a31515">port </span>
          <span style="COLOR: red">localPipe</span>
          <span style="COLOR: blue">=</span>"<span style="COLOR: blue">sql/remote</span>" <span style="COLOR: red">targetHost</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">mymachine</span>" <span style="COLOR: red">remotePipe</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">sql/query</span>"/<span style="COLOR: blue">&gt;</span></p>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
There’s more to write about this, but how about I let you take a look at the code
first. I’ve also included two setup projects that can easily install Agent and Service
as Windows Services. You obviously don’t have to use those. 
</p>
        <p>
          <em>[Updated archive (2010-06-10) fixing config issue:]</em>
        </p>
        <a href="http://vasters.com/clemensv/content/binary/PortBridge20100610.zip">PortBridge20100610.zip
(90.99 KB)</a>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3e35d8bd-b755-453f-8c63-1a57c570eb4c" />
      </body>
      <title>Port Bridge</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx</guid>
      <link>http://vasters.com/clemensv/2009/11/18/Port+Bridge.aspx</link>
      <pubDate>Wed, 18 Nov 2009 17:37:28 GMT</pubDate>
      <description>&lt;p&gt;
Building “hybrid” cloud applications where parts of an an app lives up in a cloud
infrastructure and other parts of the infrastructure live at a hosting site, or a
data center, or even in your house ought to be simple – especially in this day and
age of Web services. You create a Web service, make it accessible through your firewall
and NAT, and the the cloud-hosted app calls it. That’s as easy as it ought to be.
&lt;/p&gt;
&lt;p&gt;
Unfortunately it’s not always that easy. If the server sits behind an Internet connection
with dynamically assigned IP addresses, if the upstream ISP is blocking select ports,
if it’s not feasible to open up inbound firewall ports, or if you have no influence
over the infrastructure whatsoever, reaching an on-premise service from the cloud
(or anywhere else) is a difficult thing to do. For these scenarios (and others) our
team is building the &lt;em&gt;&lt;a href="http://msdn.microsoft.com/en-us/azure/netservices.aspx"&gt;Windows
Azure platform AppFabric&lt;/a&gt; Service Bus&lt;/em&gt; (friends call us just &lt;em&gt;Service Bus&lt;/em&gt;). 
&lt;/p&gt;
&lt;p&gt;
Now – the Service Bus and the client bits in the &lt;em&gt;Microsoft.ServiceBus.dll &lt;/em&gt;assembly
are great if you have services can can be readily hooked up into the Service Bus because
they’re built with WCF. For services that aren’t built with WCF, but are at least
using HTTP, I’ve &lt;a href="http://vasters.com/clemensv/PermaLink,guid,83edb04a-5696-401c-a919-8c1f379d130c.aspx"&gt;previously
shown a way&lt;/a&gt; to hook them into Service Bus and have also demoed an updated version
of that capability at Sun’s Java One. I’ll release an update for those bits tomorrow
after my talk at PDC09 – the version currently here on my blog (ironically) doesn’t
play well with SOAP and also doesn’t have rewrite capabilities for WSDL. The new version
does. 
&lt;/p&gt;
&lt;p&gt;
But what if your service isn’t a WCF service or doesn’t speak HTTP? What if it speaks
SMTP, SNMP, POP, IMAP, RDP, TDS, SSH, ETC? 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Introducing Port Bridge&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
“Port Bridge” – which is just a descriptive name for this code sample, not an attempt
at branding – is a point-to-point tunneling utility to help with these scenarios.
Port Bridge consists of two components, the “Port Bridge Service” and the “Port Bridge
Agent”. Here’s a picture:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/865a80e15ca0_D9A4/image_2.png"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=image border=0 alt=image src="http://vasters.com/clemensv/content/binary/WindowsLiveWriter/865a80e15ca0_D9A4/image_thumb.png" width=611 height=220&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The Agent’s job is to listen for and accept TCP or Named Pipe connections on a configurable
port or local pipe name. The Service’s job is to accept for incoming connections from
the Agent, establish a duplex channel with the Agent, and pump the data from the Agent
to the actual listening service – and vice versa. It’s actually quite simple. In the
picture above you see that the Service is configured to connect to a SQL Server listening
at the SQL Server default port 1433 and that the Agent – running on a different machine,
is listening on port 1433 as well, thus mapping the remote SQL Server onto the Agent
machine as if it ran there. You can (and I think of that as to be more common) map
the service on the Agent to any port you like – say higher up at 41433.
&lt;/p&gt;
&lt;p&gt;
In order to increase the responsiveness and throughput for protocols that are happy
to kill and reestablish connections such as HTTP does, “Port Bridge” is always multiplexing
concurrent traffic that’s flowing between two parties on the same logical socket.
When using Port Bridge to bridge to a remote HTTP proxy that the Service machine can
see, but the Agent machine can’t see (which turns out to be the at-home scenario that
this capability emerged from) there are very many and very short-lived connections
being tunneled through the channel. Creating a new Service Bus channel for each of
these connections is feasible – but not very efficient. Holding on to a connection
for an extended period of time and multiplexing traffic over it is also beneficial
in the Port Bridge case because it is using the Service Bus &lt;em&gt;Hybrid&lt;/em&gt; connection
mode by default. With &lt;em&gt;Hybrid&lt;/em&gt;, all connections are first established through
the Service Bus Relay and then our bits do a little “NAT dance” trying to figure out
whether there’s a way to connect both parties with a direct socket – if that works
the connection gets upgraded to the most direct connections in-flight. The probing,
handshake, and upgrade of the socket may take 2-20 seconds and there’s some degree
of luck involved to get that direct socket established on a very busy NAT – and thus
we want to maximize the use of that precious socket instead of throwing it away all
the time.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;That seems familiar?!&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
You may notice that &lt;a href="http://vasters.com/clemensv/PermaLink,guid,26dc5df1-8b8c-4f71-8765-8904e584505b.aspx"&gt;SocketShifter&lt;/a&gt; (built
by our friends at &lt;a href="http://www.aws.net/"&gt;AWS in the UK&lt;/a&gt;) is quite similar
to Port Bridge. Even though the timing of the respective releases may not suggest
it, Port Bridge is indeed Socketshifter’s older brother. Because we couldn’t make
up our mind on whether to release Port Bridge for a while, I had AWS take a look at
the service contract shown below and explained a few principles that I’m also explaining
here and they had a first version of Socketshifter running within a few hours. There’s
nothing wrong with having two variants of the same thing. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;How does it work?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Since I’m publishing this as a sample, I obviously need to spend a little time on
the “how”, even I’ll limit that here and will explain that in more detail in a future
post. At the heart of the app, the contract that’s used between the Agent and the
Service is a simple duplex WCF contract:
&lt;/p&gt;
&lt;pre class=code&gt;    [&lt;span style="COLOR: #2b91af"&gt;ServiceContract&lt;/span&gt;(Namespace=&lt;span style="COLOR: #a31515"&gt;"n:"&lt;/span&gt;,
Name=&lt;span style="COLOR: #a31515"&gt;"idx"&lt;/span&gt;, CallbackContract=&lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;IDataExchange&lt;/span&gt;),
SessionMode=&lt;span style="COLOR: #2b91af"&gt;SessionMode&lt;/span&gt;.Required)] &lt;span style="COLOR: blue"&gt;public
interface &lt;/span&gt;&lt;span style="COLOR: #2b91af"&gt;IDataExchange &lt;/span&gt;{ [&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;(Action=&lt;span style="COLOR: #a31515"&gt;"c"&lt;/span&gt;,
IsOneWay = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;, IsInitiating=&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)] &lt;span style="COLOR: blue"&gt;void &lt;/span&gt;Connect(&lt;span style="COLOR: blue"&gt;string &lt;/span&gt;i);
[&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;(Action = &lt;span style="COLOR: #a31515"&gt;"w"&lt;/span&gt;,
IsOneWay = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)] &lt;span style="COLOR: blue"&gt;void &lt;/span&gt;Write(&lt;span style="COLOR: #2b91af"&gt;TransferBuffer &lt;/span&gt;d);
[&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;(Action = &lt;span style="COLOR: #a31515"&gt;"d"&lt;/span&gt;,
IsOneWay = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;, IsTerminating = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)] &lt;span style="COLOR: blue"&gt;void &lt;/span&gt;Disconnect();
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
There’s a way to establish a session, send data either way, and close the session.
The &lt;em&gt;TransferBuffer&lt;/em&gt; type is really just a trick to avoid extra buffer copies
during serialization for efficiency reasons. But that’s it. The rest of Port Bridge
is a set of queue-buffered streams and pumps to make the data packets flow smoothly
and to accept inbound sockets/pipes and dispatch them out to the proxied services.
What’s noteworthy is that Port Bridge doesn’t use WCF streaming, but sends data in
chunks – which allows for much better flow control and enables multiplexing.
&lt;/p&gt;
&lt;p&gt;
Now you might say &lt;em&gt;You are using a WCF ServiceContract?&lt;/em&gt;&amp;nbsp;&lt;em&gt;Isn’t that
using SOAP and doesn’t that cause ginormous overhead?&lt;/em&gt; No, it doesn’t. We’re using
the WCF binary encoder in session mode here. That’s about as efficient as you can
get it on the wire with serialized data. The per-frame SOAP overhead for net.tcp with
the binary encoder in session mode is in the order of 40-50 bytes per message because
of dictionary-based metadata compression. The binary encoder also isn’t doing any
base64 trickery but treats binary as binary – one byte is one byte. Port Bridge is
using a default frame size of 64K (which gets filled up in high-volume streaming cases
due to the built-in Nagling support) and so we’re looking at an overhead of far less
than 0.1%. That’s not shabby. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;How do I use it?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
This is a code sample and thus you’ll have to build it using Visual Studio 2008. You’ll
find three code projects: &lt;em&gt;PortBridge&lt;/em&gt; (the Service), &lt;em&gt;PortBridgeAgent&lt;/em&gt; (the
Agent), and the &lt;em&gt;Microsoft.Samples.ServiceBus.Connections&lt;/em&gt; assembly that contains
the bulk of the logic for Port Bridge. It’s mostly straightforward to embed the agent
side or the service side into other hosts and I’ll show that in a separate post. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Service&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The service’s exe file is “PortBridge.exe” and is both a console app and a Windows
Service. If the Windows Service isn’t registered, the app will always start as a console
app. If the Windows Service is registered (with the installer or with installutil.exe)
you can force console-mode with the –c command line option.
&lt;/p&gt;
&lt;p&gt;
The app.config file on the Service Side (PortBridge/app.config, PortBridge.exe.config
in the binaries folder) specifies what ports or named pipes you want to project into
Service Bus:
&lt;/p&gt;
&lt;pre class=code&gt;&lt;span style="COLOR: blue"&gt; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portBridge &lt;/span&gt;&lt;span style="COLOR: red"&gt;serviceBusNamespace&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mynamespace&lt;/span&gt;" &lt;span style="COLOR: red"&gt;serviceBusIssuerName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;owner&lt;/span&gt;" &lt;span style="COLOR: red"&gt;serviceBusIssuerSecret&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;xxxxxxxx&lt;/span&gt;" &lt;span style="COLOR: red"&gt;localHostName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mybox&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;hostMappings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;3389&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;hostMappings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portBridge&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
The &lt;em&gt;serviceBusNamespace&lt;/em&gt; attribute takes your Service Bus namespace name,
and the &lt;em&gt;serviceBusIssuerSecret&lt;/em&gt; the respective secret. The &lt;em&gt;serviceBusIssuerName&lt;/em&gt; should
remain “owner” unless you know why you want to change it. If you don’t have an &lt;em&gt;AppFabric &lt;/em&gt;account
you might not understand what I’m writing about: &lt;a href="https://netservices.azure.com"&gt;Go
make one&lt;/a&gt;.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;localHostName&lt;/em&gt; attribute is optional and when set, it’s the name that’s
being used to map “localhost” into your Service Bus namespace. By default the name
that’s being used is the good old Windows computer-name.
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;hostMappings &lt;/em&gt;section contains a list of hosts and rules for what you
want to project out to Service Bus. Mind that all inbound connections to the endpoints
generated from the host mappings section are protected by the Access Control service
and require a token that grants access to your namespace – which is already very different
from opening up a port in your firewall. If you open up port 3389 (Remote Desktop)
through your firewall and NAT, everyone can walk up to that port and try their password-guessing
skills. If you open up port 3389 via Port Bridge, you first need to get through the
Access Control gate before you can even get at the remote port. 
&lt;/p&gt;
&lt;p&gt;
New host mappings are added with the &lt;em&gt;add&lt;/em&gt; element. You can add any host that
the machine running the Port Bridge service can “see” via the network. The &lt;em&gt;allowedPorts &lt;/em&gt;and &lt;em&gt;allowedPipes&lt;/em&gt; attributes
define with TCP ports and/or which local named pipes are accessible. Examples:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;3389&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the local machine into Service Bus and only allow Remote Desktop (3389) 
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;3389,1433&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the local machine into Service Bus and allow Remote Desktop (3389) and SQL Server
TDS (1433) 
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;*&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the local machine into Service Bus and only allow any TCP port connection 
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;localhost&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPipes&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;sql/query&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the local machine into Service Bus and allow no TCP connections but all named pipe
connections to \.\pipes\sql\query 
&lt;li&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add &lt;/span&gt;&lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;otherbox&lt;/span&gt;" &lt;span style="COLOR: red"&gt;allowedPorts&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;1433&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt; &lt;/span&gt;project
the machine “otherbox” into Service Bus and allow SQL Server TDS connections via TCP 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;Agent&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The agent’s exe file is “PortBridgeAgent.exe” and is also both a console app and a
Windows Service. 
&lt;/p&gt;
&lt;p&gt;
The app.config file on the Agent side (PortBridgeAgent/app.config, PortBridgeAgent.exe.config
in the binaries folder) specifies which ports or pipes you want to project into the
Agent machine and whether and how you want to firewall these ports. The firewall rules
here are not interacting with your local firewall. This is an additional layer of
protection.
&lt;/p&gt;
&lt;pre class=code&gt;&lt;span style="COLOR: blue"&gt; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portBridgeAgent &lt;/span&gt;&lt;span style="COLOR: red"&gt;serviceBusNamespace&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mysolution&lt;/span&gt;" &lt;span style="COLOR: red"&gt;serviceBusIssuerName&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;owner&lt;/span&gt;" &lt;span style="COLOR: red"&gt;serviceBusIssuerSecret&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;xxxxxxxx&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portMappings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;port &lt;/span&gt;&lt;span style="COLOR: red"&gt;localTcpPort&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;13389&lt;/span&gt;" &lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mymachine&lt;/span&gt;" &lt;span style="COLOR: red"&gt;remoteTcpPort&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;3389&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;firewallRules&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;rule &lt;/span&gt;&lt;span style="COLOR: red"&gt;source&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;127.0.0.1&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;rule &lt;/span&gt;&lt;span style="COLOR: red"&gt;sourceRangeBegin&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;10.0.0.0&lt;/span&gt;" &lt;span style="COLOR: red"&gt;sourceRangeEnd&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;10.255.255.255&lt;/span&gt;" &lt;span style="COLOR: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;firewallRules&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;port&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portMappings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;portBridgeAgent&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
Again, the &lt;em&gt;serviceBusNamespace&lt;/em&gt; attribute takes your Service Bus namespace
name, and the &lt;em&gt;serviceBusIssuerSecret&lt;/em&gt; the respective secret. 
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;portMappings&lt;/em&gt; collection holds the individual ports or pipes you want
to bring onto the local machine. Shown above is a mapping of Remote Desktop (port
3389 on the machine with the computer name or &lt;em&gt;localHostName&lt;/em&gt; ‘mymachine’)
to the local port 13389. Once Service and Agent are running, you can connect to the
agent machine on port 13389 using the Remote Desktop client – with PortBridge mapping
that to port 3389 on the remote box. 
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;firewallRules&lt;/em&gt; collection allows (un-)constraining the TCP clients that
may connect to the projected port. By default, only connections from the same machine
are permitted.
&lt;/p&gt;
&lt;p&gt;
For named pipes, the configuration is similar, even though there are no firewall rules
and named pipes are always constrained to local connectivity by a set of ACLs that
are applied to the pipe. Pipe names must be relative. Here’s how a named pipe projection
of a default SQL Server instance could look like:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;port &lt;/span&gt;&lt;span style="COLOR: red"&gt;localPipe&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;sql/remote&lt;/span&gt;" &lt;span style="COLOR: red"&gt;targetHost&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;mymachine&lt;/span&gt;" &lt;span style="COLOR: red"&gt;remotePipe&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;sql/query&lt;/span&gt;"/&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
There’s more to write about this, but how about I let you take a look at the code
first. I’ve also included two setup projects that can easily install Agent and Service
as Windows Services. You obviously don’t have to use those. 
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;[Updated archive (2010-06-10) fixing config issue:]&lt;/em&gt;
&lt;/p&gt;
&lt;a href="http://vasters.com/clemensv/content/binary/PortBridge20100610.zip"&gt;PortBridge20100610.zip
(90.99 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3e35d8bd-b755-453f-8c63-1a57c570eb4c" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,3e35d8bd-b755-453f-8c63-1a57c570eb4c.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
      <category>Technology/ISB</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=b703725d-3e6a-4dbb-a613-890c31505fe8</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,b703725d-3e6a-4dbb-a613-890c31505fe8.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,b703725d-3e6a-4dbb-a613-890c31505fe8.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=b703725d-3e6a-4dbb-a613-890c31505fe8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In Parts <a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx">3</a> and <a href="http://vasters.com/clemensv/PermaLink,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx">4</a> of
this series I’ve explained the REST protocol for the .NET Service Bus Queue capability.
If that looked a little too complicated for your taste and you’d rather clean with
a simple API surface, here’s the API that you’ll prefer. 
</p>
        <p>
We’ve got two simple classes in the SDK (in the Microsoft.ServiceBus assembly/namespace)
that do the job. The <em>QueueManagementClient</em> allows you to create, renew and
delete queues in/from the .NET Service Bus namespace:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span><span style="COLOR: #0000ff">class</span> QueueManagementClient </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> QueueClient
CreateQueue(TransportClientEndpointBehavior credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:                                          Uri queueUri, QueuePolicy queuePolicy);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span><span style="COLOR: #0000ff">void</span> DeleteQueue(TransportClientEndpointBehavior
credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:                                   Uri queueUri);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> QueueClient
GetQueue(TransportClientEndpointBehavior credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:                                       Uri queueUri);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> QueuePolicy
GetQueuePolicy(TransportClientEndpointBehavior credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:                                             Uri queueUri);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:    <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> DateTime
RenewQueue(TransportClientEndpointBehavior credential, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:                                      Uri queueUri, TimeSpan requestedExpiration);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13: }</pre>
        </pre>
        <p>
The most striking difference between this API (and the underlying SOAP protocol for
which we still owe you some docs) and the REST API/Protocol is that there’s only a
single URI to deal with. The WS-Transfer aligned protocol to manage the policy, the
“Queue Transfer” protocol used to dequeue messages, and the “Enqueue” protocol to
add messages to the queue are all overlaid over the exact same URI.
</p>
        <p>
The only somewhat ugly element here is the <em>TransportClientEndpointBehavior</em> that’s
our awkwardly named credentials container. That class was meant to evolve into something
else and then we changed our mind at some point, which is how the baby got stuck with
that name. We’ll give that a prettier moniker in one of the next CTPs and as part
of an overhaul of the .NET Access Control integration into Service Bus.
</p>
        <p>
The function of the methods themselves should be quite obvious. You can create a queue
by applying a <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">policy</a>,
you can delete a queue, attach to an existing queue, get the latest queue policy,
and renew (extend the lifetime) of a queue. For completeness, here’s CreateQueue in
context:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: Uri queueUri = ServiceBusEnvironment.CreateServiceUri("<span style="COLOR: #8b0000">sb</span>",
solutionName, "<span style="COLOR: #8b0000">/MyQueue/</span>"); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: QueuePolicy queuePolicy = <span style="COLOR: #0000ff">new</span> QueuePolicy(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: queuePolicy.ExpirationInstant = DateTime.UtcNow + TimeSpan.FromHours(1);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: QueueClient client = QueueManagementClient.CreateQueue(credential, queueUri, queuePolicy);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: queuePolicy = client.GetPolicy(); <span style="COLOR: #008000">//
get effective policy</span></pre>
        </pre>
        <p>
The <em>QueueClient</em> class allows interaction with a Queue. QueueClient instances
cannot be created directly, but must be created via the QueueManagementClient factory.
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">sealed</span><span style="COLOR: #0000ff">class</span> QueueClient </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> DeleteLockedMessage(Message
message); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> DeleteQueue(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:     <span style="COLOR: #0000ff">public</span> DateTime
GetExpiration(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6:     <span style="COLOR: #0000ff">public</span> QueuePolicy
GetPolicy(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:     <span style="COLOR: #0000ff">public</span> Message
PeekLock(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     <span style="COLOR: #0000ff">public</span> Message
PeekLock(TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:     <span style="COLOR: #0000ff">public</span> IEnumerable&lt;Message&gt;
PeekLockMultiple(<span style="COLOR: #0000ff">int</span> maxMessages); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:     <span style="COLOR: #0000ff">public</span> IEnumerable&lt;Message&gt;
PeekLockMultiple(<span style="COLOR: #0000ff">int</span> maxMessages, TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> Purge(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> ReleaseLock(Message
message); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:     <span style="COLOR: #0000ff">public</span> DateTime
Renew(TimeSpan requestedExpiration); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:     <span style="COLOR: #0000ff">public</span> Message
Retrieve(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:     <span style="COLOR: #0000ff">public</span> Message
Retrieve(TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16:     <span style="COLOR: #0000ff">public</span> IEnumerable&lt;Message&gt;
RetrieveMultiple(<span style="COLOR: #0000ff">int</span> maxMessages); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17:     <span style="COLOR: #0000ff">public</span> IEnumerable&lt;Message&gt;
RetrieveMultiple(<span style="COLOR: #0000ff">int</span> maxMessages, TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18:     <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">void</span> Send(Message
message, TimeSpan timeout); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 19:     <span style="COLOR: #0000ff">public</span> RouterSubscriptionClient
SubscribeToRouter(RouterClient routerClient, TimeSpan requestedTimeout); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 20: }</pre>
        </pre>
        <p>
As you can tell, the class is – well – a queue client. It’s using WCF’s <em><a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.aspx">Message</a></em> class
as its message abstraction and supports sending messages into the queue, reading messages
off the queue in a destructive fashion (Retrieve), and reading messages off the queue
using the Peek/Lock pattern which provides resilience against message loss if the
message were to be lost in transfer or the receiver fumbled the message. What you’ll
also notice is that there are RetrieveMultiple and PeekLockMultiple variants of the
retrieval functions which allow for getting more data with fewer network roundtrips. 
</p>
        <p>
Again, there should be no surprises using the API. Here’s how you send:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: queueClient.Send(Message.CreateMessage(MessageVersion.Default, "<span style="COLOR: #8b0000">Hello</span>",
input), TimeSpan.MaxValue);</pre>
        </pre>
        <p>
and here’s how you do a destructive read:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: Message message = queueClient.Retrieve();</pre>
        </pre>
        <p>
and here’s how you use the Peek/Lock pattern:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: Message message = queueClient.PeekLock();
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: <span style="COLOR: #0000ff">string</span> content
= message.GetBody&lt;<span style="COLOR: #0000ff">string</span>&gt;(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: queueClient.DeleteLockedMessage(message);
</pre>
        </pre>
        <p>
There are several examples in the SDK showing how to use the API for Queues. The OnewayQueueSender
and SoapHttpQueueSender samples are particularly interesting since they just use WCF
channels to enqueue, including all the bells and whistles you get from using a WCF
channel. Here’s how the OnewayQueueSender does it:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: ChannelFactory&lt;IOnewayChannel&gt; channelFactory = 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:      <span style="COLOR: #0000ff">new</span> ChannelFactory&lt;IOnewayChannel&gt;(<span style="COLOR: #0000ff">new</span> NetOnewayRelayBinding(), </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:                                         <span style="COLOR: #0000ff">new</span> EndpointAddress(queueUri)); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: channelFactory.Endpoint.Behaviors.Add(userNamePasswordServiceBusCredential);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: IOnewayChannel onewayChannel = channelFactory.CreateChannel();
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: <span style="COLOR: #0000ff">string</span> input
= Console.ReadLine(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: onewayChannel.Hello(<span style="COLOR: #0000ff">new</span> HelloMessage(input)); </pre>
        </pre>
        <p>
The logical next question is: So why is the Queue not hooked up to a WCF listener?
Answer: That’s what we’ve got “buffered Routers” for. The queue very explicitly provides
a ‘pull’ model and the WCF listener would abstract that away and turn it into ‘push’.
Routers provide ‘push’ natively <em>and</em> they can embed a Queue. More on Routers
in the next set of posts in this series. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b703725d-3e6a-4dbb-a613-890c31505fe8" />
      </body>
      <title>.NET Services March 2009 CTP - Service Bus Routers and Queues - Part 5: The Queue API for the rest of us</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,b703725d-3e6a-4dbb-a613-890c31505fe8.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/07/NET+Services+March+2009+CTP+Service+Bus+Routers+And+Queues+Part+5+The+Queue+API+For+The+Rest+Of+Us.aspx</link>
      <pubDate>Tue, 07 Apr 2009 06:38:26 GMT</pubDate>
      <description>&lt;p&gt;
In Parts &lt;a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx"&gt;3&lt;/a&gt; and &lt;a href="http://vasters.com/clemensv/PermaLink,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx"&gt;4&lt;/a&gt; of
this series I’ve explained the REST protocol for the .NET Service Bus Queue capability.
If that looked a little too complicated for your taste and you’d rather clean with
a simple API surface, here’s the API that you’ll prefer. 
&lt;/p&gt;
&lt;p&gt;
We’ve got two simple classes in the SDK (in the Microsoft.ServiceBus assembly/namespace)
that do the job. The &lt;em&gt;QueueManagementClient&lt;/em&gt; allows you to create, renew and
delete queues in/from the .NET Service Bus namespace:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; QueueManagementClient &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2: {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3:    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; QueueClient
CreateQueue(TransportClientEndpointBehavior credential, &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4:                                          Uri queueUri, QueuePolicy queuePolicy);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5:    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; DeleteQueue(TransportClientEndpointBehavior
credential, &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6:                                   Uri queueUri);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7:    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; QueueClient
GetQueue(TransportClientEndpointBehavior credential, &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  8:                                       Uri queueUri);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  9:    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; QueuePolicy
GetQueuePolicy(TransportClientEndpointBehavior credential, &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 10:                                             Uri queueUri);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 11:    &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; DateTime
RenewQueue(TransportClientEndpointBehavior credential, &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 12:                                      Uri queueUri, TimeSpan requestedExpiration);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 13: }&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The most striking difference between this API (and the underlying SOAP protocol for
which we still owe you some docs) and the REST API/Protocol is that there’s only a
single URI to deal with. The WS-Transfer aligned protocol to manage the policy, the
“Queue Transfer” protocol used to dequeue messages, and the “Enqueue” protocol to
add messages to the queue are all overlaid over the exact same URI.
&lt;/p&gt;
&lt;p&gt;
The only somewhat ugly element here is the &lt;em&gt;TransportClientEndpointBehavior&lt;/em&gt; that’s
our awkwardly named credentials container. That class was meant to evolve into something
else and then we changed our mind at some point, which is how the baby got stuck with
that name. We’ll give that a prettier moniker in one of the next CTPs and as part
of an overhaul of the .NET Access Control integration into Service Bus.
&lt;/p&gt;
&lt;p&gt;
The function of the methods themselves should be quite obvious. You can create a queue
by applying a &lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;policy&lt;/a&gt;,
you can delete a queue, attach to an existing queue, get the latest queue policy,
and renew (extend the lifetime) of a queue. For completeness, here’s CreateQueue in
context:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: Uri queueUri = ServiceBusEnvironment.CreateServiceUri("&lt;span style="COLOR: #8b0000"&gt;sb&lt;/span&gt;",
solutionName, "&lt;span style="COLOR: #8b0000"&gt;/MyQueue/&lt;/span&gt;"); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3: QueuePolicy queuePolicy = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; QueuePolicy(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4: queuePolicy.ExpirationInstant = DateTime.UtcNow + TimeSpan.FromHours(1);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6: QueueClient client = QueueManagementClient.CreateQueue(credential, queueUri, queuePolicy);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7: queuePolicy = client.GetPolicy(); &lt;span style="COLOR: #008000"&gt;//
get effective policy&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The &lt;em&gt;QueueClient&lt;/em&gt; class allows interaction with a Queue. QueueClient instances
cannot be created directly, but must be created via the QueueManagementClient factory.
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;class&lt;/span&gt; QueueClient &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2: {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; DeleteLockedMessage(Message
message); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; DeleteQueue(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; DateTime
GetExpiration(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; QueuePolicy
GetPolicy(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; Message
PeekLock(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  8:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; Message
PeekLock(TimeSpan timeout); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  9:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; IEnumerable&amp;lt;Message&amp;gt;
PeekLockMultiple(&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; maxMessages); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 10:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; IEnumerable&amp;lt;Message&amp;gt;
PeekLockMultiple(&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; maxMessages, TimeSpan timeout); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 11:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Purge(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 12:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; ReleaseLock(Message
message); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 13:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; DateTime
Renew(TimeSpan requestedExpiration); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 14:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; Message
Retrieve(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 15:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; Message
Retrieve(TimeSpan timeout); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 16:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; IEnumerable&amp;lt;Message&amp;gt;
RetrieveMultiple(&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; maxMessages); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 17:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; IEnumerable&amp;lt;Message&amp;gt;
RetrieveMultiple(&lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; maxMessages, TimeSpan timeout); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 18:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; Send(Message
message, TimeSpan timeout); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 19:     &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; RouterSubscriptionClient
SubscribeToRouter(RouterClient routerClient, TimeSpan requestedTimeout); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 20: }&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
As you can tell, the class is – well – a queue client. It’s using WCF’s &lt;em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message.aspx"&gt;Message&lt;/a&gt;&lt;/em&gt; class
as its message abstraction and supports sending messages into the queue, reading messages
off the queue in a destructive fashion (Retrieve), and reading messages off the queue
using the Peek/Lock pattern which provides resilience against message loss if the
message were to be lost in transfer or the receiver fumbled the message. What you’ll
also notice is that there are RetrieveMultiple and PeekLockMultiple variants of the
retrieval functions which allow for getting more data with fewer network roundtrips. 
&lt;/p&gt;
&lt;p&gt;
Again, there should be no surprises using the API. Here’s how you send:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: queueClient.Send(Message.CreateMessage(MessageVersion.Default, "&lt;span style="COLOR: #8b0000"&gt;Hello&lt;/span&gt;",
input), TimeSpan.MaxValue);&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
and here’s how you do a destructive read:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: Message message = queueClient.Retrieve();&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
and here’s how you use the Peek/Lock pattern:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: Message message = queueClient.PeekLock();
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2: &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; content
= message.GetBody&amp;lt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&amp;gt;(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3: queueClient.DeleteLockedMessage(message);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
There are several examples in the SDK showing how to use the API for Queues. The OnewayQueueSender
and SoapHttpQueueSender samples are particularly interesting since they just use WCF
channels to enqueue, including all the bells and whistles you get from using a WCF
channel. Here’s how the OnewayQueueSender does it:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: ChannelFactory&amp;lt;IOnewayChannel&amp;gt; channelFactory = 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2:      &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; ChannelFactory&amp;lt;IOnewayChannel&amp;gt;(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; NetOnewayRelayBinding(), &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3:                                         &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; EndpointAddress(queueUri)); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4: channelFactory.Endpoint.Behaviors.Add(userNamePasswordServiceBusCredential);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5: IOnewayChannel onewayChannel = channelFactory.CreateChannel();
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7: &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; input
= Console.ReadLine(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  8: onewayChannel.Hello(&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; HelloMessage(input)); &lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The logical next question is: So why is the Queue not hooked up to a WCF listener?
Answer: That’s what we’ve got “buffered Routers” for. The queue very explicitly provides
a ‘pull’ model and the WCF listener would abstract that away and turn it into ‘push’.
Routers provide ‘push’ natively &lt;em&gt;and&lt;/em&gt; they can embed a Queue. More on Routers
in the next set of posts in this series. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b703725d-3e6a-4dbb-a613-890c31505fe8" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,b703725d-3e6a-4dbb-a613-890c31505fe8.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=4aefc36e-4476-4543-9574-13727c8f615d</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=4aefc36e-4476-4543-9574-13727c8f615d</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
After I’ve gone through the dry facts of the REST Queue Protocol in <a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx">Part
3 of this series</a>, here’s some code to look at. The code snippets are ripped from
the HTTP Queue sample we’ve got in the .NET Services <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8d1d1d5e-1332-4186-b33f-26d053759e49&amp;displaylang=en">SDK</a> and
you can get the copy/paste ready code from there. 
</p>
        <p>
The most straightforward way to acquire the required hashed security token (<a href="http://vasters.com/clemensv/PermaLink,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx">see
my comments to Stefan Tilkov</a>) using HttpWebRequest looks like this:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #0000ff">static</span><span style="COLOR: #0000ff">string</span> HttpGetAuthenticationToken(<span style="COLOR: #0000ff">string</span> username, <span style="COLOR: #0000ff">string</span> password) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:     <span style="COLOR: #0000ff">string</span> tokenUri
= <span style="COLOR: #0000ff">string</span>.Format("<span style="COLOR: #8b0000">https://{0}/issuetoken.aspx?u={1}&amp;p={2}</span>", </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:                                     ServiceBusEnvironment.DefaultIdentityHostName, 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:                                     username, Uri.EscapeDataString(password));
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:     HttpWebRequest tokenRequest = (HttpWebRequest)WebRequest.Create(tokenUri);
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     <span style="COLOR: #0000ff">using</span> (var
tokenResponse = tokenRequest.GetResponse()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:         <span style="COLOR: #0000ff">using</span> (var
tokenResponseStream = tokenResponse.GetResponseStream()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:         {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:             <span style="COLOR: #0000ff">byte</span>[]
tokenBody = <span style="COLOR: #0000ff">new</span><span style="COLOR: #0000ff">byte</span>[500]; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:             <span style="COLOR: #0000ff">int</span> tokenBodyLength
= tokenResponseStream.Read(tokenBody, 0, 500); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:             <span style="COLOR: #0000ff">return</span> Encoding.UTF8.GetString(tokenBody,
0, tokenBodyLength); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:         }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16:     }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17: }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18: </pre>
        </pre>
        <p>
Once you’ve got the token, you need to pick a place in the Service Bus namespace.
We’ve got a built-in helper function in the SDK that sits on <em>ServiceBusEnvironment</em> and
which knows all the right incantations:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1:  Uri queueUri = ServiceBusEnvironment.CreateServiceUri(
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:                    Uri.UriSchemeHttps, 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:                    solutionName, 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:                    "<span style="COLOR: #8b0000">/MyHttpQueue/</span>"); </pre>
        </pre>
        <p>
Invoked in this way, the method yields the URI <strong>https://yourproject.<font color="#ff8040">servicebus.windows.net</font>/MyHttpQueue/</strong> so
there’s spectacularly little magic to it. The reason why we recommend that you use
the method in .NET applications is that we’ve broken everyone’s apps going from the
previous CTP to the current CTP due to the namespace restructuring and we’d like to
avoid doing that again as we improve the namespace story. I don’t foresee any further
change of the magnitude we had this time, however. 
</p>
        <p>
To create a new Queue, you first <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">create
a Queue policy</a> and then apply it to the Service Bus namespace name. We’ve got
a Queue Policy object in the SDK that I’ll use here to keep things short. I’m accepting
all the defaults that are spelled out in <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">Part
2 of the series</a>, but explicitly I’m setting the expiration to 1 hour. The Queue
Policy XSD schema in the the HTTP Queue sample’s <em>readme</em> document, by the
way. 
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: QueuePolicy queuePolicy = <span style="COLOR: #0000ff">new</span> QueuePolicy(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: queuePolicy.ExpirationInstant = DateTime.UtcNow + TimeSpan.FromHours(1);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: queueManageUri = HttpCreateQueue(token, queueUri, queuePolicy);</pre>
        </pre>
        <p>
The code for creating the Queue shouldn’t be very surprising. It’s a POST of an Atom
1.0 entry for which I’m using HttpWebRequest and the WCF 3.5 Syndication API. The
SDK sample is using a rather terse version of the ‘correct’ way of doing things. I’m
quoting the expanded variant from the Text140 sample that I showed at MIX’09:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #0000ff">public</span><span style="COLOR: #0000ff">static</span> QueuePolicy
HttpCreateQueue(<span style="COLOR: #0000ff">string</span> token, Uri queueUri, QueuePolicy
policy, </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:                                           <span style="COLOR: #0000ff">out</span> Uri
queueSelfUri, <span style="COLOR: #0000ff">out</span> Uri queueHeadUri) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4:     HttpWebRequest webRequest;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5:     HttpWebResponse webResponse;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7:     queueSelfUri = <span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     queueHeadUri = <span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:     <span style="COLOR: #008000">//
Create a new syndication item and add the queue policy as an extension</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     SyndicationItem syndicationItem = <span style="COLOR: #0000ff">new</span> SyndicationItem(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:     syndicationItem.ElementExtensions.Add(
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:         <span style="COLOR: #0000ff">new</span> SyndicationElementExtension("<span style="COLOR: #8b0000">QueuePolicy</span>", </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:                                         "<span style="COLOR: #8b0000">http://schemas.microsoft.com/ws/2007/08/connect</span>", </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:                                         policy));
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17:     <span style="COLOR: #008000">//
create a new POST request and set the Content-Type to represent an Atom 1.0 entry</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18:     webRequest = HttpWebRequest.Create(queueUri) <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 19:     webRequest.ConnectionGroupName = "<span style="COLOR: #8b0000">queueclient</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 20:     webRequest.KeepAlive = <span style="COLOR: #0000ff">false</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 21:     webRequest.Method = "<span style="COLOR: #8b0000">POST</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 22:     webRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 23:     webRequest.ContentType = "<span style="COLOR: #8b0000">application/atom+xml;type=entry;charset=utf-8</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 24: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 25:     <span style="COLOR: #008000">//
write the item to the request stream</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 26:     <span style="COLOR: #0000ff">using</span> (var
requestStream = webRequest.GetRequestStream()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 27:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 28:         <span style="COLOR: #0000ff">using</span> (var
textWriter = <span style="COLOR: #0000ff">new</span> XmlTextWriter(requestStream,
Encoding.UTF8)) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 29:         {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 30:             syndicationItem.GetAtom10Formatter().WriteTo(textWriter);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 31:             textWriter.Flush();
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 32:         }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 33:     }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 34: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 35:     <span style="COLOR: #008000">//
get the response</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 36:     <span style="COLOR: #0000ff">using</span> (webResponse
= webRequest.GetResponse() <span style="COLOR: #0000ff">as</span> HttpWebResponse) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 37:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 38:         <span style="COLOR: #0000ff">return</span> GetQueueInfoFromResponse(webResponse,
queueUri, <span style="COLOR: #0000ff">out</span> queueSelfUri, <span style="COLOR: #0000ff">out</span> queueHeadUri); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 39:     }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 40: }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 41: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 42: <span style="COLOR: #0000ff">static</span> QueuePolicy
GetQueueInfoFromResponse(HttpWebResponse webResponse, Uri queueUri, </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 43:                                                     <span style="COLOR: #0000ff">out</span> Uri
queueSelfUri, <span style="COLOR: #0000ff">out</span> Uri queueHeadUri) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 44: {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 45:     queueHeadUri = <span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 46:     queueSelfUri = <span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 47: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 48:     <span style="COLOR: #0000ff">if</span> (webResponse.ContentType.StartsWith("<span style="COLOR: #8b0000">application/atom+xml;type=entry</span>",
StringComparison.OrdinalIgnoreCase)) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 49:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 50:         Atom10ItemFormatter atomItemFormatter = <span style="COLOR: #0000ff">new</span> Atom10ItemFormatter(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 51:         <span style="COLOR: #0000ff">using</span> (var
responseReader = <span style="COLOR: #0000ff">new</span> XmlTextReader(webResponse.GetResponseStream())) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 52:         {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 53:             atomItemFormatter.ReadFrom(responseReader);
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 54:             <span style="COLOR: #008000">//
we found it. let's get the policy and the queue head URI</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 55:             <span style="COLOR: #0000ff">foreach</span> (SyndicationLink
queueSelfLink <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 56:                            from link <span style="COLOR: #0000ff">in</span> atomItemFormatter.Item.Links </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 57:                            where link.RelationshipType.Equals("<span style="COLOR: #8b0000">self</span>",
StringComparison.OrdinalIgnoreCase) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 58:                            select link)
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 59:             {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 60:                 queueSelfUri = queueSelfLink.Uri;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 61:                 <span style="COLOR: #0000ff">break</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 62:             }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 63: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 64:             <span style="COLOR: #0000ff">foreach</span> (SyndicationLink
queueHeadLink <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 65:                            from link <span style="COLOR: #0000ff">in</span> atomItemFormatter.Item.Links </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 66:                            where link.RelationshipType.Equals("<span style="COLOR: #8b0000">queuehead</span>",
StringComparison.OrdinalIgnoreCase) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 67:                            select link)
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 68:             {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 69:                 queueHeadUri = queueHeadLink.Uri;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 70:                 <span style="COLOR: #0000ff">break</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 71:             }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 72: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 73:             <span style="COLOR: #0000ff">return</span> atomItemFormatter.Item.ElementExtensions.ReadElementExtensions&lt;QueuePolicy&gt;( </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 74:                  "<span style="COLOR: #8b0000">QueuePolicy</span>", </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 75:                  "<span style="COLOR: #8b0000">http://schemas.microsoft.com/ws/2007/08/connect</span>").FirstOrDefault(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 76:         }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 77:     }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 78:     <span style="COLOR: #0000ff">else</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 79:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 80:         Atom10FeedFormatter atomFeedFormatter = <span style="COLOR: #0000ff">new</span> Atom10FeedFormatter(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 81:         <span style="COLOR: #0000ff">using</span> (var
responseReader = <span style="COLOR: #0000ff">new</span> XmlTextReader(webResponse.GetResponseStream())) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 82:         {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 83:             atomFeedFormatter.ReadFrom(responseReader);
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 84: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 85:             <span style="COLOR: #008000">//
look for an item whose alternate-link equals the desired queue URI. The alternate </span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 86:             <span style="COLOR: #008000">//
URI is the 'tail' endpoint by which the queue is mapped into the namespace. We are </span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 87:             <span style="COLOR: #008000">//
comparing Authority and Path since the scheme might be http or https and we want to
match</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 88:             <span style="COLOR: #008000">//
either.</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 89:             <span style="COLOR: #0000ff">foreach</span> (SyndicationItem
requestedItem <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 90:                          from item <span style="COLOR: #0000ff">in</span> atomFeedFormatter.Feed.Items </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 91:                          from link <span style="COLOR: #0000ff">in</span> item.Links </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 92:                          where 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 93:                            (link.RelationshipType.Equals("<span style="COLOR: #8b0000">alternate</span>",
StringComparison.OrdinalIgnoreCase) &amp;&amp; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 94:                             link.Uri.Authority.Equals(queueUri.Authority, StringComparison.OrdinalIgnoreCase) &amp;&amp;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 95:                             link.Uri.AbsolutePath.Equals(queueUri.AbsolutePath, StringComparison.OrdinalIgnoreCase)) ||
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 96:                            (link.RelationshipType.Equals("<span style="COLOR: #8b0000">self</span>",
StringComparison.OrdinalIgnoreCase) &amp;&amp; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 97:                             link.Uri.Equals(queueUri))
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 98:                          select item)
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 99:             {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">100:                 <span style="COLOR: #008000">//
we found it. let's get the policy and the queue head URI</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">101:                 <span style="COLOR: #0000ff">foreach</span> (SyndicationLink
queueSelfLink <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">102:                                from link <span style="COLOR: #0000ff">in</span> requestedItem.Links </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">103:                                where link.RelationshipType.Equals("<span style="COLOR: #8b0000">self</span>",
StringComparison.OrdinalIgnoreCase) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">104:                                select link)
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">105:                 {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">106:                     queueSelfUri = queueSelfLink.Uri;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">107:                     <span style="COLOR: #0000ff">break</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">108:                 }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">109: 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">110:                 <span style="COLOR: #0000ff">foreach</span> (SyndicationLink
queueHeadLink <span style="COLOR: #0000ff">in</span></pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">111:                                from link <span style="COLOR: #0000ff">in</span> requestedItem.Links </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">112:                                where link.RelationshipType.Equals("<span style="COLOR: #8b0000">queuehead</span>",
StringComparison.OrdinalIgnoreCase) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">113:                                select link)
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">114:                 {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">115:                     queueHeadUri = queueHeadLink.Uri;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">116:                     <span style="COLOR: #0000ff">break</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">117:                 }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">118: 
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">119:                 <span style="COLOR: #0000ff">return</span> requestedItem.ElementExtensions.ReadElementExtensions&lt;QueuePolicy&gt;( </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">120:                      "<span style="COLOR: #8b0000">QueuePolicy</span>", </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">121:                      "<span style="COLOR: #8b0000">http://schemas.microsoft.com/ws/2007/08/connect</span>").FirstOrDefault(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">122:             }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">123:         }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">124:     }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">125:     <span style="COLOR: #0000ff">return</span><span style="COLOR: #0000ff">null</span>; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">126: }</pre>
        </pre>
        <p>
The “magic” that isn’t straight up Atom Pub is in lines 10-15 above. I’m attaching
the policy object to the SyndicationItem abstraction that will be written out as an
Atom 1.0 entry. [I know that copy/paste is difficult using this format – I need to
clean up that expanded utility class and will post it in downloadable form within
the next few days]
</p>
        <p>
The method returns the effective policy that the Service Bus is using, and yields
the management URI for the queue where the Atom entry resides (self-link) as well
as the head of the queue as output arguments. The <em>queueUri</em> to which you applied
the entry has morphed into the Queue’s tail when the method returns successfully.
Having the Queue by its tail, submitting messages into it is very simple. Just do
a plain POST. Here we’re just writing a simple string from the local variable <em>input</em> as
the entity body and send it.
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: <span style="COLOR: #008000">//
send</span></pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: HttpWebRequest sendRequest = HttpWebRequest.Create(queueUri) <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: sendRequest.Method = "<span style="COLOR: #8b0000">POST</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: sendRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: sendRequest.ContentType = "<span style="COLOR: #8b0000">text/plain;charset=utf-8</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: <span style="COLOR: #0000ff">using</span> (var
sendStream = sendRequest.GetRequestStream()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8:     <span style="COLOR: #0000ff">using</span> (var
writer = <span style="COLOR: #0000ff">new</span> StreamWriter(sendStream, Encoding.UTF8)) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:         writer.Write(input);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:         writer.Flush();
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:     }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13: }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14: sendRequest.GetResponse().Close();</pre>
        </pre>
        <p>
For a simple destructive read, you use the ‘queue head’ URI and do a DELETE:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: HttpWebRequest dequeueRequest = 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:     HttpWebRequest.Create(queueHeadUri.AbsoluteUri+
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:                           "<span style="COLOR: #8b0000">?encoding=asreply&amp;maxmessages=1&amp;timeout=60</span>") <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: dequeueRequest.ConnectionGroupName = "<span style="COLOR: #8b0000">dequeue</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: dequeueRequest.Method = "<span style="COLOR: #8b0000">DELETE</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: dequeueRequest.ContentLength = 0;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: dequeueRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: <span style="COLOR: #0000ff">using</span> (HttpWebResponse
response = dequeueRequest.GetResponse() <span style="COLOR: #0000ff">as</span> HttpWebResponse) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9: {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:     <span style="COLOR: #0000ff">if</span> (response.StatusCode
== HttpStatusCode.OK) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:         <span style="COLOR: #0000ff">using</span> (var
responseBody = response.GetResponseStream()) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:         {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:             <span style="COLOR: #0000ff">using</span> (var
responseReader = <span style="COLOR: #0000ff">new</span> StreamReader(responseBody,
Encoding.UTF8)) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:             {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16:                 <span style="COLOR: #0000ff">string</span> data
= responseReader.ReadToEnd(); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17:                 Console.WriteLine(data);
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18:             }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 19:         }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 20:     }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 21: }</pre>
        </pre>
        <p>
For a peek/lock read where you first lock the message and then delete the lock when
you want to keep the message, you do a POST on the head and remember the <em>X-MS-Message-Lock</em> header
value:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: HttpWebRequest dequeueRequest = 
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2:      HttpWebRequest.Create(queueHeadUri.AbsoluteUri+
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3:                            "<span style="COLOR: #8b0000">?encoding=asreply&amp;maxmessages=1&amp;timeout=60</span>") <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: dequeueRequest.ConnectionGroupName = "<span style="COLOR: #8b0000">dequeue</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: dequeueRequest.Method = "<span style="COLOR: #8b0000">POST</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: dequeueRequest.ContentLength = 0;
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: dequeueRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: <span style="COLOR: #0000ff">using</span> (HttpWebResponse
response = dequeueRequest.GetResponse() <span style="COLOR: #0000ff">as</span> HttpWebResponse) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  9: {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 10:     <span style="COLOR: #0000ff">if</span> (response.StatusCode
== HttpStatusCode.OK) </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 11:     {
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 12:         lockUri = <span style="COLOR: #0000ff">new</span> Uri(response.Headers["<span style="COLOR: #8b0000">X-MS-Message-Lock</span>"]); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 13:         <span style="COLOR: #0000ff">using</span> (var
responseBody = response.GetResponseStream()) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 14:         {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 15:             <span style="COLOR: #0000ff">using</span> (var
responseReader = <span style="COLOR: #0000ff">new</span> StreamReader(responseBody,
Encoding.UTF8)) </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 16:             {
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 17:                 <span style="COLOR: #0000ff">string</span> data
= responseReader.ReadToEnd(); </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 18:                 Console.WriteLine(data);
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 19:             }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 20:         }
</pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 21:     }
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"> 22: }</pre>
        </pre>
        <p>
If you decide to keep the message (i.e. your app didn’t puke processing it), you DELETE
the lock, otherwise you do a PUT. The code is practically the same except for the
method so I’ll just quote DELETE:
</p>
        <pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  1: HttpWebRequest deleteLockedMessageRequest = HttpWebRequest.Create(lockUri) <span style="COLOR: #0000ff">as</span> HttpWebRequest; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  2: deleteLockedMessageRequest.ConnectionGroupName = "<span style="COLOR: #8b0000">lock</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  3: deleteLockedMessageRequest.Method = "<span style="COLOR: #8b0000">DELETE</span>"; </pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  4: deleteLockedMessageRequest.KeepAlive=<span style="COLOR: #0000ff">false</span>; </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  5: deleteLockedMessageRequest.ContentLength = 0;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  6: deleteLockedMessageRequest.Headers.Add("<span style="COLOR: #8b0000">X-MS-Identity-Token</span>",
token); </pre>
          <pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  7: deleteLockedMessageRequest.ContentLength = 0;
</pre>
          <pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px">  8: deleteLockedMessageRequest.GetResponse().Close();</pre>
        </pre>
        <p>
That’s it. Create, Enqueue, Destructive Read, Peek/Lock Read, and .. oh .. yes.. forgot
Delete the Queue. Take the snippet above and swap out the lockUri for the queueSelfUri.
Done.  
</p>
        <p>
Ah, yes, and please … don’t blame me for HTTP or HttpWebRequest or Clemens’ demo coding
style requiring too many lines of code. I could have applied a bit of code-compression
here, but I’m intentionally trying not to abstract away too much of the protocol here.
I’m generally with you, though. The guys putting together the <a href="http://msdn.microsoft.com/wcf/rest">WCF
REST Starter Kit</a> are working on making code like that shrink.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=4aefc36e-4476-4543-9574-13727c8f615d" />
      </body>
      <title>.NET Services March 2009 CTP - Service Bus Routers and Queues - Part 4: The REST Queue Protocol in Code Snippets</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/07/NET+Services+March+2009+CTP+Service+Bus+Routers+And+Queues+Part+4+The+REST+Queue+Protocol+In+Code+Snippets.aspx</link>
      <pubDate>Tue, 07 Apr 2009 05:40:58 GMT</pubDate>
      <description>&lt;p&gt;
After I’ve gone through the dry facts of the REST Queue Protocol in &lt;a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx"&gt;Part
3 of this series&lt;/a&gt;, here’s some code to look at. The code snippets are ripped from
the HTTP Queue sample we’ve got in the .NET Services &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8d1d1d5e-1332-4186-b33f-26d053759e49&amp;amp;displaylang=en"&gt;SDK&lt;/a&gt; and
you can get the copy/paste ready code from there. 
&lt;/p&gt;
&lt;p&gt;
The most straightforward way to acquire the required hashed security token (&lt;a href="http://vasters.com/clemensv/PermaLink,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx"&gt;see
my comments to Stefan Tilkov&lt;/a&gt;) using HttpWebRequest looks like this:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; HttpGetAuthenticationToken(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; username, &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; password) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2: {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3:     &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; tokenUri
= &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;.Format("&lt;span style="COLOR: #8b0000"&gt;https://{0}/issuetoken.aspx?u={1}&amp;amp;p={2}&lt;/span&gt;", &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4:                                     ServiceBusEnvironment.DefaultIdentityHostName, 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5:                                     username, Uri.EscapeDataString(password));
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7:     HttpWebRequest tokenRequest = (HttpWebRequest)WebRequest.Create(tokenUri);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  8:     &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
tokenResponse = tokenRequest.GetResponse()) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  9:     {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 10:         &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
tokenResponseStream = tokenResponse.GetResponseStream()) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 11:         {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 12:             &lt;span style="COLOR: #0000ff"&gt;byte&lt;/span&gt;[]
tokenBody = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;byte&lt;/span&gt;[500]; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 13:             &lt;span style="COLOR: #0000ff"&gt;int&lt;/span&gt; tokenBodyLength
= tokenResponseStream.Read(tokenBody, 0, 500); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 14:             &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; Encoding.UTF8.GetString(tokenBody,
0, tokenBodyLength); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 15:         }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 16:     }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 17: }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 18: &lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
Once you’ve got the token, you need to pick a place in the Service Bus namespace.
We’ve got a built-in helper function in the SDK that sits on &lt;em&gt;ServiceBusEnvironment&lt;/em&gt; and
which knows all the right incantations:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1:  Uri queueUri = ServiceBusEnvironment.CreateServiceUri(
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2:                    Uri.UriSchemeHttps, 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3:                    solutionName, 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4:                    "&lt;span style="COLOR: #8b0000"&gt;/MyHttpQueue/&lt;/span&gt;"); &lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
Invoked in this way, the method yields the URI &lt;strong&gt;https://yourproject.&lt;font color=#ff8040&gt;servicebus.windows.net&lt;/font&gt;/MyHttpQueue/&lt;/strong&gt; so
there’s spectacularly little magic to it. The reason why we recommend that you use
the method in .NET applications is that we’ve broken everyone’s apps going from the
previous CTP to the current CTP due to the namespace restructuring and we’d like to
avoid doing that again as we improve the namespace story. I don’t foresee any further
change of the magnitude we had this time, however. 
&lt;/p&gt;
&lt;p&gt;
To create a new Queue, you first &lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;create
a Queue policy&lt;/a&gt; and then apply it to the Service Bus namespace name. We’ve got
a Queue Policy object in the SDK that I’ll use here to keep things short. I’m accepting
all the defaults that are spelled out in &lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;Part
2 of the series&lt;/a&gt;, but explicitly I’m setting the expiration to 1 hour. The Queue
Policy XSD schema in the the HTTP Queue sample’s &lt;em&gt;readme&lt;/em&gt; document, by the
way. 
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: QueuePolicy queuePolicy = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; QueuePolicy(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2: queuePolicy.ExpirationInstant = DateTime.UtcNow + TimeSpan.FromHours(1);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3: queueManageUri = HttpCreateQueue(token, queueUri, queuePolicy);&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The code for creating the Queue shouldn’t be very surprising. It’s a POST of an Atom
1.0 entry for which I’m using HttpWebRequest and the WCF 3.5 Syndication API. The
SDK sample is using a rather terse version of the ‘correct’ way of doing things. I’m
quoting the expanded variant from the Text140 sample that I showed at MIX’09:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: &lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; QueuePolicy
HttpCreateQueue(&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; token, Uri queueUri, QueuePolicy
policy, &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2:                                           &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; Uri
queueSelfUri, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; Uri queueHeadUri) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3: {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4:     HttpWebRequest webRequest;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5:     HttpWebResponse webResponse;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7:     queueSelfUri = &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  8:     queueHeadUri = &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  9: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 10:     &lt;span style="COLOR: #008000"&gt;//
Create a new syndication item and add the queue policy as an extension&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 11:     SyndicationItem syndicationItem = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; SyndicationItem(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 12:     syndicationItem.ElementExtensions.Add(
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 13:         &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; SyndicationElementExtension("&lt;span style="COLOR: #8b0000"&gt;QueuePolicy&lt;/span&gt;", &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 14:                                         "&lt;span style="COLOR: #8b0000"&gt;http://schemas.microsoft.com/ws/2007/08/connect&lt;/span&gt;", &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 15:                                         policy));
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 16: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 17:     &lt;span style="COLOR: #008000"&gt;//
create a new POST request and set the Content-Type to represent an Atom 1.0 entry&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 18:     webRequest = HttpWebRequest.Create(queueUri) &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 19:     webRequest.ConnectionGroupName = "&lt;span style="COLOR: #8b0000"&gt;queueclient&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 20:     webRequest.KeepAlive = &lt;span style="COLOR: #0000ff"&gt;false&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 21:     webRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;POST&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 22:     webRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 23:     webRequest.ContentType = "&lt;span style="COLOR: #8b0000"&gt;application/atom+xml;type=entry;charset=utf-8&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 24: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 25:     &lt;span style="COLOR: #008000"&gt;//
write the item to the request stream&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 26:     &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
requestStream = webRequest.GetRequestStream()) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 27:     {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 28:         &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
textWriter = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlTextWriter(requestStream,
Encoding.UTF8)) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 29:         {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 30:             syndicationItem.GetAtom10Formatter().WriteTo(textWriter);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 31:             textWriter.Flush();
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 32:         }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 33:     }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 34: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 35:     &lt;span style="COLOR: #008000"&gt;//
get the response&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 36:     &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (webResponse
= webRequest.GetResponse() &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebResponse) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 37:     {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 38:         &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; GetQueueInfoFromResponse(webResponse,
queueUri, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; queueSelfUri, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; queueHeadUri); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 39:     }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 40: }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 41: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 42: &lt;span style="COLOR: #0000ff"&gt;static&lt;/span&gt; QueuePolicy
GetQueueInfoFromResponse(HttpWebResponse webResponse, Uri queueUri, &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 43:                                                     &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; Uri
queueSelfUri, &lt;span style="COLOR: #0000ff"&gt;out&lt;/span&gt; Uri queueHeadUri) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 44: {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 45:     queueHeadUri = &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 46:     queueSelfUri = &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 47: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 48:     &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (webResponse.ContentType.StartsWith("&lt;span style="COLOR: #8b0000"&gt;application/atom+xml;type=entry&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase)) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 49:     {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 50:         Atom10ItemFormatter atomItemFormatter = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Atom10ItemFormatter(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 51:         &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
responseReader = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlTextReader(webResponse.GetResponseStream())) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 52:         {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 53:             atomItemFormatter.ReadFrom(responseReader);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 54:             &lt;span style="COLOR: #008000"&gt;//
we found it. let's get the policy and the queue head URI&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 55:             &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationLink
queueSelfLink &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 56:                            from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; atomItemFormatter.Item.Links &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 57:                            where link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;self&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 58:                            select link)
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 59:             {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 60:                 queueSelfUri = queueSelfLink.Uri;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 61:                 &lt;span style="COLOR: #0000ff"&gt;break&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 62:             }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 63: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 64:             &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationLink
queueHeadLink &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 65:                            from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; atomItemFormatter.Item.Links &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 66:                            where link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;queuehead&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 67:                            select link)
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 68:             {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 69:                 queueHeadUri = queueHeadLink.Uri;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 70:                 &lt;span style="COLOR: #0000ff"&gt;break&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 71:             }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 72: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 73:             &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; atomItemFormatter.Item.ElementExtensions.ReadElementExtensions&amp;lt;QueuePolicy&amp;gt;( &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 74:                  "&lt;span style="COLOR: #8b0000"&gt;QueuePolicy&lt;/span&gt;", &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 75:                  "&lt;span style="COLOR: #8b0000"&gt;http://schemas.microsoft.com/ws/2007/08/connect&lt;/span&gt;").FirstOrDefault(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 76:         }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 77:     }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 78:     &lt;span style="COLOR: #0000ff"&gt;else&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 79:     {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 80:         Atom10FeedFormatter atomFeedFormatter = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Atom10FeedFormatter(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 81:         &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
responseReader = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; XmlTextReader(webResponse.GetResponseStream())) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 82:         {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 83:             atomFeedFormatter.ReadFrom(responseReader);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 84: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 85:             &lt;span style="COLOR: #008000"&gt;//
look for an item whose alternate-link equals the desired queue URI. The alternate &lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 86:             &lt;span style="COLOR: #008000"&gt;//
URI is the 'tail' endpoint by which the queue is mapped into the namespace. We are &lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 87:             &lt;span style="COLOR: #008000"&gt;//
comparing Authority and Path since the scheme might be http or https and we want to
match&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 88:             &lt;span style="COLOR: #008000"&gt;//
either.&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 89:             &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationItem
requestedItem &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 90:                          from item &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; atomFeedFormatter.Feed.Items &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 91:                          from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; item.Links &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 92:                          where 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 93:                            (link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;alternate&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &amp;amp;&amp;amp; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 94:                             link.Uri.Authority.Equals(queueUri.Authority, StringComparison.OrdinalIgnoreCase) &amp;amp;&amp;amp;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 95:                             link.Uri.AbsolutePath.Equals(queueUri.AbsolutePath, StringComparison.OrdinalIgnoreCase)) ||
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 96:                            (link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;self&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &amp;amp;&amp;amp; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 97:                             link.Uri.Equals(queueUri))
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 98:                          select item)
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 99:             {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;100:                 &lt;span style="COLOR: #008000"&gt;//
we found it. let's get the policy and the queue head URI&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;101:                 &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationLink
queueSelfLink &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;102:                                from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; requestedItem.Links &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;103:                                where link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;self&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;104:                                select link)
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;105:                 {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;106:                     queueSelfUri = queueSelfLink.Uri;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;107:                     &lt;span style="COLOR: #0000ff"&gt;break&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;108:                 }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;109: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;110:                 &lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt; (SyndicationLink
queueHeadLink &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;111:                                from link &lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt; requestedItem.Links &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;112:                                where link.RelationshipType.Equals("&lt;span style="COLOR: #8b0000"&gt;queuehead&lt;/span&gt;",
StringComparison.OrdinalIgnoreCase) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;113:                                select link)
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;114:                 {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;115:                     queueHeadUri = queueHeadLink.Uri;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;116:                     &lt;span style="COLOR: #0000ff"&gt;break&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;117:                 }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;118: 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;119:                 &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; requestedItem.ElementExtensions.ReadElementExtensions&amp;lt;QueuePolicy&amp;gt;( &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;120:                      "&lt;span style="COLOR: #8b0000"&gt;QueuePolicy&lt;/span&gt;", &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;121:                      "&lt;span style="COLOR: #8b0000"&gt;http://schemas.microsoft.com/ws/2007/08/connect&lt;/span&gt;").FirstOrDefault(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;122:             }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;123:         }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;124:     }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;125:     &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;126: }&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
The “magic” that isn’t straight up Atom Pub is in lines 10-15 above. I’m attaching
the policy object to the SyndicationItem abstraction that will be written out as an
Atom 1.0 entry. [I know that copy/paste is difficult using this format – I need to
clean up that expanded utility class and will post it in downloadable form within
the next few days]
&lt;/p&gt;
&lt;p&gt;
The method returns the effective policy that the Service Bus is using, and yields
the management URI for the queue where the Atom entry resides (self-link) as well
as the head of the queue as output arguments. The &lt;em&gt;queueUri&lt;/em&gt; to which you applied
the entry has morphed into the Queue’s tail when the method returns successfully.
Having the Queue by its tail, submitting messages into it is very simple. Just do
a plain POST. Here we’re just writing a simple string from the local variable &lt;em&gt;input&lt;/em&gt; as
the entity body and send it.
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: &lt;span style="COLOR: #008000"&gt;//
send&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2: HttpWebRequest sendRequest = HttpWebRequest.Create(queueUri) &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3: sendRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;POST&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4: sendRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5: sendRequest.ContentType = "&lt;span style="COLOR: #8b0000"&gt;text/plain;charset=utf-8&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6: &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
sendStream = sendRequest.GetRequestStream()) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7: {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  8:     &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
writer = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; StreamWriter(sendStream, Encoding.UTF8)) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  9:     {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 10:         writer.Write(input);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 11:         writer.Flush();
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 12:     }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 13: }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 14: sendRequest.GetResponse().Close();&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
For a simple destructive read, you use the ‘queue head’ URI and do a DELETE:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: HttpWebRequest dequeueRequest = 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2:     HttpWebRequest.Create(queueHeadUri.AbsoluteUri+
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3:                           "&lt;span style="COLOR: #8b0000"&gt;?encoding=asreply&amp;amp;maxmessages=1&amp;amp;timeout=60&lt;/span&gt;") &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4: dequeueRequest.ConnectionGroupName = "&lt;span style="COLOR: #8b0000"&gt;dequeue&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5: dequeueRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;DELETE&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6: dequeueRequest.ContentLength = 0;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7: dequeueRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  8: &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (HttpWebResponse
response = dequeueRequest.GetResponse() &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebResponse) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  9: {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 10:     &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (response.StatusCode
== HttpStatusCode.OK) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 11:     {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 12:         &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
responseBody = response.GetResponseStream()) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 13:         {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 14:             &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
responseReader = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; StreamReader(responseBody,
Encoding.UTF8)) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 15:             {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 16:                 &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; data
= responseReader.ReadToEnd(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 17:                 Console.WriteLine(data);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 18:             }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 19:         }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 20:     }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 21: }&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
For a peek/lock read where you first lock the message and then delete the lock when
you want to keep the message, you do a POST on the head and remember the &lt;em&gt;X-MS-Message-Lock&lt;/em&gt; header
value:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: HttpWebRequest dequeueRequest = 
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2:      HttpWebRequest.Create(queueHeadUri.AbsoluteUri+
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3:                            "&lt;span style="COLOR: #8b0000"&gt;?encoding=asreply&amp;amp;maxmessages=1&amp;amp;timeout=60&lt;/span&gt;") &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4: dequeueRequest.ConnectionGroupName = "&lt;span style="COLOR: #8b0000"&gt;dequeue&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5: dequeueRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;POST&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6: dequeueRequest.ContentLength = 0;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7: dequeueRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  8: &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (HttpWebResponse
response = dequeueRequest.GetResponse() &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebResponse) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  9: {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 10:     &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (response.StatusCode
== HttpStatusCode.OK) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 11:     {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 12:         lockUri = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; Uri(response.Headers["&lt;span style="COLOR: #8b0000"&gt;X-MS-Message-Lock&lt;/span&gt;"]); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 13:         &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
responseBody = response.GetResponseStream()) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 14:         {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 15:             &lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt; (var
responseReader = &lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt; StreamReader(responseBody,
Encoding.UTF8)) &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 16:             {
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 17:                 &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; data
= responseReader.ReadToEnd(); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 18:                 Console.WriteLine(data);
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 19:             }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 20:         }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 21:     }
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt; 22: }&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
If you decide to keep the message (i.e. your app didn’t puke processing it), you DELETE
the lock, otherwise you do a PUT. The code is practically the same except for the
method so I’ll just quote DELETE:
&lt;/p&gt;
&lt;pre&gt;&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  1: HttpWebRequest deleteLockedMessageRequest = HttpWebRequest.Create(lockUri) &lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt; HttpWebRequest; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  2: deleteLockedMessageRequest.ConnectionGroupName = "&lt;span style="COLOR: #8b0000"&gt;lock&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  3: deleteLockedMessageRequest.Method = "&lt;span style="COLOR: #8b0000"&gt;DELETE&lt;/span&gt;"; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  4: deleteLockedMessageRequest.KeepAlive=&lt;span style="COLOR: #0000ff"&gt;false&lt;/span&gt;; &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  5: deleteLockedMessageRequest.ContentLength = 0;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  6: deleteLockedMessageRequest.Headers.Add("&lt;span style="COLOR: #8b0000"&gt;X-MS-Identity-Token&lt;/span&gt;",
token); &lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #fbfbfb; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  7: deleteLockedMessageRequest.ContentLength = 0;
&lt;/pre&gt;
&lt;pre style="BACKGROUND-COLOR: #ffffff; MARGIN: 0em; WIDTH: 100%; FONT-FAMILY: consolas,'Courier New',courier,monospace; FONT-SIZE: 12px"&gt;  8: deleteLockedMessageRequest.GetResponse().Close();&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;
That’s it. Create, Enqueue, Destructive Read, Peek/Lock Read, and .. oh .. yes.. forgot
Delete the Queue. Take the snippet above and swap out the lockUri for the queueSelfUri.
Done.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Ah, yes, and please … don’t blame me for HTTP or HttpWebRequest or Clemens’ demo coding
style requiring too many lines of code. I could have applied a bit of code-compression
here, but I’m intentionally trying not to abstract away too much of the protocol here.
I’m generally with you, though. The guys putting together the &lt;a href="http://msdn.microsoft.com/wcf/rest"&gt;WCF
REST Starter Kit&lt;/a&gt; are working on making code like that shrink.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=4aefc36e-4476-4543-9574-13727c8f615d" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,4aefc36e-4476-4543-9574-13727c8f615d.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=19e938fc-e6ec-42df-96d9-e2f6a31f7399</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=19e938fc-e6ec-42df-96d9-e2f6a31f7399</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.innoq.com/blog/st/2009/04/net_services_rest_queue_protoc.html">Stefan
Tilkov has several interesting remarks</a> regarding our <a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx">.NET
Service Bus REST Queue Protocol</a> that are worth addressing.
</p>
        <p>
          <font color="#0080c0">
            <em>      Putting a password in the
URI to get an identity token seems to expose information unnecessarily</em>
          </font>
        </p>
        <p>
That’s an area where we know that we’re going to change the protocol. We’ve already
labeled that protocol as temporary in the documentation for the PDC CTP and we didn’t
get all the pieces in the .NET Access Control service together, yet. Since it’s a
HTTPS call, the data doesn’t get exposed on the wire, though. 
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">Queue
creation seems fine, even though I feel a little uneasy about wrapping this in an
Atom entry </font>
          </em>
        </p>
        <p>
Using Atom 1.0 and the Atom Publishing Protocol as the framework for managing the
namespace is very intentional - for several reasons. First of all, it’s a standardized
protocol for managing generic lists and the elements in those lists. With that we
have a stable and accepted protocol framework and there’s plenty of tooling and framework
support around it. That’s worth something. All we need to do is to add some simple
extensions – the policies – on top of that stack. Beats having to define, version,
and maintain a whole protocol.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">On
the other hand, Atom seems reasonable considering you get an Atom feed from the queue’s
“parent” resource </font>
          </em>
        </p>
        <p>
That’s what I mean. All sorts of tools know how to navigate and display Atom.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">Very
nice to see the use of link/rel to get to the detailed Queue URIs; it would be even
better if the rel values themselves were URIs in an MS namespace </font>
          </em>
        </p>
        <p>
          <br />
I don’t see much potential for collision here and I would find it odd to have something
as simple “self” and “alternate” and then add some unsightly QName for my rel expressions.
Simple is good.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">Using
“alternate” for the tail seems strange </font>
          </em>
        </p>
        <p>
“self” refers to the location where the Atom &lt;entry&gt; resides. “alternate” is
what the entry points to. Since the Queue gets mapped into the namespace by “sticking
its tail out”, the choice of the alternate link is the simplest possible mapping I
could think of.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">“The
queue’s tail endpoint accepts requests with any HTTP Content-Type and any HTTP method
except GET, HEAD, and OPTIONS.” The tail does not accept GET. Why not? Can’t think
of a reason. Also, I don’t get why any method is allowed. It seems to me a POST/PUT
combination or an idempotent POST variant would be the way to go. </font>
          </em>
        </p>
        <p>
The way to look at this is that the Queue’s tail is acting on behalf of the receiver/resource
that’ll eventually pick up and process the messages. POST, PUT, DELETE, and BOOYAH
are all operations that cleanly map to processing operations and can often be delivered
asynchronously with a 202 receipt reply. GET and HEAD don’t make much sense when executed
in an asynchronous fashion without getting a reply that’s backed by a response for
the receiver. OPTIONS is simply reserved for future use. 
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">“DELETE
performing a destructive read” – huh? What happens if I don’t get back a response?
How can I retry (as I can’t tell whether I get the same or a different message)? Maybe
it’s intended to be used only if you don’t care about losing messages. </font>
          </em>
        </p>
        <p>
DELETE is indeed the dequeue operation variant that you’d use if you are ok with occasional
message loss and want to trade transfer reliability for fewer roundtrips. 
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">The
POST lock/delete approach, on the other hand, is very nice. Maybe it should be made
idempotent, again e.g. using POE </font>
          </em>
        </p>
        <p>
POST lock/delete is the dequeue variant where you are doing the trade the other way
around. More reliability bought with an extra roundtrip. In my view, idempotent access
to individual messages isn’t much of a practical priority for a competing consumer
queue. You’ll get a message or a set of messages to look at under a lock and if you
walk away from the message(s), those messages pop back into the queue for someone
else to look at. There are obviously scenarios where you want to look at a message
sequence in other ways than an ordered queue where you can only get at messages as
they appear on the head of the sequence – direct message access and per-message idempotent
access matter in those scenarios and we’re looking to give you a capability of that
sort in a different kind of messaging primitive.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">“The
Delete request is sent without any entity body and MUST have a Content-Length header
that is set to zero (0)”; although my immediate reaction was to question whether DELETE
ever carries a body, the HTTP spec indeed doesn’t say anything about this </font>
          </em>
        </p>
        <p>
One of the great things about working here is that there are all sorts of interesting
people around. I’ve discussed the use of DELETE and whether you can provide an entity
body in either direction with <a href="http://en.wikipedia.org/wiki/Henrik_Frystyk_Nielsen">Henrik
Frystyk Nielsen</a>, who works as an architect on the WCF team and is one of the co-authors
of HTTP 1.1. Henrik’s stance is that all operations allow entity-bodies unless it’s
explicitly forbidden in the spec. I don’t have a better authority to talk to.
</p>
        <p>
          <font color="#0080c0">
            <em>      </em>
          </font>
          <em>
            <font color="#0080c0">“The
DELETE and POST operation have a set of options that are expressed as query parameters
appended to the queue’s head URI” - the wording is worse than the actual approach.</font>
          </em>
        </p>
        <p>
I’m sorry that my writing is so clumsy ;-)
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=19e938fc-e6ec-42df-96d9-e2f6a31f7399" />
      </body>
      <title>The .NET Service Bus REST protocol for Queues - Some comments, some answers</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/07/The+NET+Service+Bus+REST+Protocol+For+Queues+Some+Comments+Some+Answers.aspx</link>
      <pubDate>Tue, 07 Apr 2009 04:14:16 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.innoq.com/blog/st/2009/04/net_services_rest_queue_protoc.html"&gt;Stefan
Tilkov has several interesting remarks&lt;/a&gt; regarding our &lt;a href="http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx"&gt;.NET
Service Bus REST Queue Protocol&lt;/a&gt; that are worth addressing.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Putting a password in the URI
to get an identity token seems to expose information unnecessarily&lt;/em&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
That’s an area where we know that we’re going to change the protocol. We’ve already
labeled that protocol as temporary in the documentation for the PDC CTP and we didn’t
get all the pieces in the .NET Access Control service together, yet. Since it’s a
HTTPS call, the data doesn’t get exposed on the wire, though. 
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;Queue
creation seems fine, even though I feel a little uneasy about wrapping this in an
Atom entry &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
Using Atom 1.0 and the Atom Publishing Protocol as the framework for managing the
namespace is very intentional - for several reasons. First of all, it’s a standardized
protocol for managing generic lists and the elements in those lists. With that we
have a stable and accepted protocol framework and there’s plenty of tooling and framework
support around it. That’s worth something. All we need to do is to add some simple
extensions – the policies – on top of that stack. Beats having to define, version,
and maintain a whole protocol.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;On
the other hand, Atom seems reasonable considering you get an Atom feed from the queue’s
“parent” resource &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
That’s what I mean. All sorts of tools know how to navigate and display Atom.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;Very
nice to see the use of link/rel to get to the detailed Queue URIs; it would be even
better if the rel values themselves were URIs in an MS namespace &lt;/font&gt;&lt;/em&gt; 
&lt;p&gt;
&lt;br&gt;
I don’t see much potential for collision here and I would find it odd to have something
as simple “self” and “alternate” and then add some unsightly QName for my rel expressions.
Simple is good.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;Using
“alternate” for the tail seems strange &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
“self” refers to the location where the Atom &amp;lt;entry&amp;gt; resides. “alternate” is
what the entry points to. Since the Queue gets mapped into the namespace by “sticking
its tail out”, the choice of the alternate link is the simplest possible mapping I
could think of.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;“The
queue’s tail endpoint accepts requests with any HTTP Content-Type and any HTTP method
except GET, HEAD, and OPTIONS.” The tail does not accept GET. Why not? Can’t think
of a reason. Also, I don’t get why any method is allowed. It seems to me a POST/PUT
combination or an idempotent POST variant would be the way to go. &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
The way to look at this is that the Queue’s tail is acting on behalf of the receiver/resource
that’ll eventually pick up and process the messages. POST, PUT, DELETE, and BOOYAH
are all operations that cleanly map to processing operations and can often be delivered
asynchronously with a 202 receipt reply. GET and HEAD don’t make much sense when executed
in an asynchronous fashion without getting a reply that’s backed by a response for
the receiver. OPTIONS is simply reserved for future use. 
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;“DELETE
performing a destructive read” – huh? What happens if I don’t get back a response?
How can I retry (as I can’t tell whether I get the same or a different message)? Maybe
it’s intended to be used only if you don’t care about losing messages. &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
DELETE is indeed the dequeue operation variant that you’d use if you are ok with occasional
message loss and want to trade transfer reliability for fewer roundtrips. 
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;The
POST lock/delete approach, on the other hand, is very nice. Maybe it should be made
idempotent, again e.g. using POE &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
POST lock/delete is the dequeue variant where you are doing the trade the other way
around. More reliability bought with an extra roundtrip. In my view, idempotent access
to individual messages isn’t much of a practical priority for a competing consumer
queue. You’ll get a message or a set of messages to look at under a lock and if you
walk away from the message(s), those messages pop back into the queue for someone
else to look at. There are obviously scenarios where you want to look at a message
sequence in other ways than an ordered queue where you can only get at messages as
they appear on the head of the sequence – direct message access and per-message idempotent
access matter in those scenarios and we’re looking to give you a capability of that
sort in a different kind of messaging primitive.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;“The
Delete request is sent without any entity body and MUST have a Content-Length header
that is set to zero (0)”; although my immediate reaction was to question whether DELETE
ever carries a body, the HTTP spec indeed doesn’t say anything about this &lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
One of the great things about working here is that there are all sorts of interesting
people around. I’ve discussed the use of DELETE and whether you can provide an entity
body in either direction with &lt;a href="http://en.wikipedia.org/wiki/Henrik_Frystyk_Nielsen"&gt;Henrik
Frystyk Nielsen&lt;/a&gt;, who works as an architect on the WCF team and is one of the co-authors
of HTTP 1.1. Henrik’s stance is that all operations allow entity-bodies unless it’s
explicitly forbidden in the spec. I don’t have a better authority to talk to.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0080c0&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/em&gt;&lt;/font&gt;&lt;em&gt;&lt;font color=#0080c0&gt;“The
DELETE and POST operation have a set of options that are expressed as query parameters
appended to the queue’s head URI” - the wording is worse than the actual approach.&lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
I’m sorry that my writing is so clumsy ;-)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=19e938fc-e6ec-42df-96d9-e2f6a31f7399" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,19e938fc-e6ec-42df-96d9-e2f6a31f7399.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=6bd1cf32-05e0-455d-84d7-9147c66815be</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,6bd1cf32-05e0-455d-84d7-9147c66815be.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,6bd1cf32-05e0-455d-84d7-9147c66815be.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=6bd1cf32-05e0-455d-84d7-9147c66815be</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Short answer: You can’t. 
</p>
        <p>
There is a range of breaking protocol changes between the December bits and the March
bits. Your app won’t work until you upgrade (uninstall/install) to the March 2009
CTP <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4eff38b3-fca0-4940-a014-461631152e5d&amp;displaylang=en">client
bits</a> and/or <a href="http://www.microsoft.com/downloads/details.aspx?familyid=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;displaylang=en">SDK</a>.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6bd1cf32-05e0-455d-84d7-9147c66815be" />
      </body>
      <title>How do I use the .NET Services "December 2008" CTP SDK with the "March 2009" CTP Services?</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,6bd1cf32-05e0-455d-84d7-9147c66815be.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/03/How+Do+I+Use+The+NET+Services+December+2008+CTP+SDK+With+The+March+2009+CTP+Services.aspx</link>
      <pubDate>Fri, 03 Apr 2009 00:36:18 GMT</pubDate>
      <description>&lt;p&gt;
Short answer: You can’t. 
&lt;/p&gt;
&lt;p&gt;
There is a range of breaking protocol changes between the December bits and the March
bits. Your app won’t work until you upgrade (uninstall/install) to the March 2009
CTP &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4eff38b3-fca0-4940-a014-461631152e5d&amp;amp;displaylang=en"&gt;client
bits&lt;/a&gt; and/or &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;amp;displaylang=en"&gt;SDK&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6bd1cf32-05e0-455d-84d7-9147c66815be" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,6bd1cf32-05e0-455d-84d7-9147c66815be.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=413c6128-a6a6-4894-9cc9-701ffb674ab0</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=413c6128-a6a6-4894-9cc9-701ffb674ab0</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
[If this text looks vaguely familiar you’ve read the HttpQueueSample Readme doc from
the SDK. Good job!]
</p>
        <p>
Here is the Service Bus Queue REST protocol. I apologize if this is a bit dry, but
I want to give you the bare protocol facts first and will follow-up with code samples
later. Look at the HTTP Queue <a href="http://www.microsoft.com/downloads/details.aspx?familyid=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;displaylang=en">SDK
sample</a> if you can’t wait for code ;-)
</p>
        <p>
You can find the HTTP Queue sample in the SDK install path under <em>.\Samples\ServiceBus\ExploringFeatures\Queues\HttpMessages\</em></p>
        <p>
The beauty of REST is that there’s a uniform interface. It’s all just GET, POST, PUT,
DELETE, a set of resources, and a rigorous application of the RFC2616 / HTTP 1.1 rules.
That doesn’t make the description particularly entertaining, but it does yield a pretty
consistent interaction model:
</p>
        <h5>Authorization
</h5>
        <p>
All Queue operations require the client to be appropriately authorized. The client
must therefore acquire an lightweight identity token from the Microsoft .NET Access
Control Service using the .NET Services solution name and the solution password and
include the acquired token with each request. The tokens are added to requests using
the <strong>X-MS-Identity-Token</strong> HTTP header. The value for this header is
a short-lived token which can be used for a period of up to 8 hours and must be acquired
from the .NET Access Control Service. We strongly encourage you to guard the acquired
tokens in the same fashion as you would guard a credential and <strong>you should
not</strong> openly expose them unprotected on the network or web-pages or embedded
in a Flash or Silverlight application. 
</p>
        <p>
        </p>
        <p>
The request for acquiring the token is an HTTPS <strong>GET</strong> on the URI <em><strong>https://accesscontrol.windows.net/issuetoken.aspx?u={solutionName}&amp;p={solutionPassword}</strong></em> whereby
you replace the arguments for solution name and the solution password with your .NET
Services solution credentials. If a token is successfully issued to you the request
returns with a 200 (OK) status code and contains a <em><strong>text/plain</strong></em> entity
body with a short, base64 encoded token hash as a single line of text, which you for
the value of the X-MS-Identity-Token header. 
</p>
        <h5>Creating a Queue
</h5>
        <p>
A Queue is created on the Service Bus in four simple steps. I’ve discussed most of
this in the post on <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">Queue
Policies</a>: 
</p>
        <ol>
          <li>
            <p>
Select a name in the Service Bus naming hierarchy where the Queue should be located,
i.e. <strong>https://</strong><em><strong>mysolution</strong></em><strong>.servicebus.windows.net/myapp/q1</strong></p>
          </li>
          <li>
            <p>
              <a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx">Create
a Queue policy</a> and define the desired properties of the Queue. 
</p>
          </li>
          <li>
            <p>
Embed the Queue policy into an ATOM 1.0 <em><strong>&lt;atom:entry&gt;</strong></em> as
an extension and <strong>POST</strong> the entry to the designated Queue URI with
the content-type <em><strong>application/atom+xml;type=entry</strong>.</em><em></em>The
request must carry an X-MS-Identity-Token header and the respective identity must
have 'Manage' permission on for scope covering the Queue URI.
</p>
          </li>
          <li>
            <p>
If the queue was successfully created, the POST request returns with a <strong>201</strong> 'created'
status code along with a <strong>Location</strong> header. The response entity body
contains the effective Queue policy as applied to the name by the Service Bus. 
<br /><br />
The location header contains the queue's management URI that you need to retain in
your application state to have access to the queue's metadata and management functions.
If the queue could not be created successfully, the request may yield the following
status codes: 
</p>
            <ul>
              <li>
                <p>
                  <strong>400</strong> - Bad Request. The policy was malformed or invalid.
</p>
              </li>
              <li>
                <p>
                  <strong>403</strong> - Forbidden. The client did not provide a X-MS-Identity-Token
header, the provided token is no longer valid for use, or the provided identity is
not authorized to create a Queue at this location.
</p>
              </li>
              <li>
                <p>
                  <strong>409</strong> - Conflict.  There is already a Queue with an incompatible
policy at the given location or the location is occupied by a Router or a Service
Bus listener.
</p>
              </li>
              <li>
                <p>
                  <strong>415</strong> - Unsupported Media Type. The request did not carry the required
content-type header.
</p>
              </li>
              <li>
                <p>
                  <strong>500</strong> - Internal Server Error. The processing failed to to a condition
internal to the Service Bus service.
</p>
              </li>
            </ul>
          </li>
        </ol>
        <h5>REST Anatomy of a Queue
</h5>
        <p>
Each Queue has five distinct types of resources: <strong>Policy</strong>, <strong>Tail</strong>, <strong>Head</strong>, <strong>Locks</strong>,
and <strong>Control</strong>. The concrete URIs are discoverable using the Service
Registry's Atom Publishing protocol. you should not make any assumptions about the
particular format of the URIs spelled out below since the particular format might
change.
</p>
        <p>
The Atom 1.0 entry shown below is also enclosed in the response entity body of the
create request (POST) explained above. A Queue's representation in the registry feed
as seen when doing a <strong>GET</strong> (discovery-) request on the queue's parent
URI is commonly as follows:
</p>
        <pre>&lt;feed xmlns="http://www.w3.org/2005/Atom"&gt;
  ...
  &lt;entry&gt;
    &lt;id&gt;{id}&lt;/id&gt;
    &lt;title type="text"&gt;MyHttpQueue&lt;/title&gt;
    &lt;updated&gt;{date}&lt;/updated&gt;
    &lt;link rel="alternate" href="https://solution.servicebus.windows.net/myapp/q1" /&gt;
    &lt;link rel="self" href="https://solution.servicebus.windows.net/myapp/q1!(queue)" /&gt;
    &lt;link rel="queuehead" href="https://solution.servicebus.windows.net/myapp/q1!(queue/head)" /&gt;
    &lt;link rel="queuecontrol" href="https://solution.servicebus.windows.net/myapp/q1!(queue/control)" /&gt;
    &lt;QueuePolicy xmlns="http://schemas.microsoft.com/ws/2007/08/connect"&gt;
      &lt;Discoverability&gt;Public&lt;/Discoverability&gt;
      &lt;ExpirationInstant&gt;{expiration}&lt;/ExpirationInstant&gt;
    &lt;/QueuePolicy&gt;
  &lt;/entry&gt;
&lt;/feed&gt;</pre>
        <h5>
        </h5>
        <h5>Managing The Queue
</h5>
        <p>
          <em>&lt;link rel="self" href="https://solution.servicebus.windows.net/myapp/q1!(queue)"
/&gt; 
<br /></em>
          <br />
The "<strong>self</strong>" link in the entry above is the queue's management URI
that allows you to interact with the queue's policy. 
</p>
        <ul>
          <li>
            <p>
To renew a queue and extend its expiration you <strong>PUT</strong> an updated Atom
1.0 entry with the effective policy and an updated <em>ExpirationInstant</em> value
to the "self" URI.  The "self" URI is the same URI as the one returned in the <strong>Location</strong> header
returned by the create POST explained above. The request will yield a <strong>200</strong> status
code if the renewal is successful. It will yield a<strong> 404</strong> if the queue
no longer exists.
</p>
          </li>
          <li>
            <p>
To delete a queue you issue a<strong> DELETE </strong>request on  the queue's
management URI. The Delete request is sent without any entity body and MUST have a
Content-Length header that is set to zero (0). Not setting this header will yield
a <strong>411</strong> status code. The request yields a <strong>204</strong> response
if the queue was deleted successfully.
</p>
          </li>
        </ul>
        <h5>Enqueue
</h5>
        <p>
          <em>&lt;link rel="alternate" href="https://solution.servicebus.windows.net/myapp/q1"
/&gt;</em>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
The "<strong>alternate</strong>" link refers to the tail of the queue. The Queue's <em>tail</em> resource
is where senders submit messages into the Queue. The queue's tail URI is identical
to the URI where the queue was initially created. The queue's tail endpoint accepts
requests with any HTTP Content-Type and any HTTP method except GET, HEAD, and OPTIONS.
</p>
        <p>
The endpoint should be considered a 'delegate' of the message recipient and not the
resource that the respective operations have an immediate effect on. That means that
the HTTP method applied to the Queue tail doesn’t have any particular semantic. If
a message has been successfully accepted into the queue, the request returns a <strong>202</strong> status
code. Otherwise it will return a <strong>500</strong></p>
        <h5>Dequeue and Peek/Lock
</h5>
        <p>
          <em>&lt;link rel="queuehead" href="https://solution.servicebus.windows.net/myapp/q1!(queue/head)"
/&gt;<br /></em>
        </p>
        <p>
The "<strong>queuehead</strong>" link refers to the head of the Queue. The Queue's <em>head</em> resource
is where receivers retrieve messages from the queue. It is modeled as a resource whose
current representation corresponds to the message(s) that reside at the head of the
queue and which is/are next in line to be retrieved by consumers. Permitted operations
on the head are: 
</p>
        <ul>
          <li>
            <strong>DELETE</strong>:  Delete performs a destructive read on the queue whereby
the message(s) at the head of the queue are permanently deleted and returned as the
entity body of the response to the request. The content type and formatting of the
response depends on a set of query parameters that are discussed below. The DELETE
request's response status code is <strong>200</strong> if at least one message could
be retrieved and deleted from the queue and the message content is enclosed in the
response's entity body. The response status code is <strong>204<em></em></strong>if
no message could be retrieved/deleted. 
</li>
          <li>
            <strong>POST:</strong> Post creates a lock on the message(s) at the head of the queue
and returns the locked messages. Locked messages are temporarily removed from the
head of the queue for a period of 1 minute during which time the receiver can decide
whether to return the message to the head of the queue or whether to permanently delete
it. The POST request's response status code is <strong>200</strong> if at least one
message could be retrieved and locked on the queue and the message content is enclosed
in the response's entity body. The response status code is <strong>204<em></em></strong>if
no message could be retrieved/locked.</li>
        </ul>
        <h5>Releasing and Deleting Peek/Lock Message Locks 
</h5>
        <p>
Any retrieved, peek/locked message (POST on “queuehead”) contains an HTTP header <strong>X-MS-Message-Lock </strong>whose
value is a URI. The following operations can be performed on this URI:
</p>
        <ul>
          <li>
            <strong>DELETE: </strong>The message has been accepted/processed by the receiver and
the lock shall be deleted. The deletion of the lock discards the message permanently
from the queue. The Delete request is sent without any entity body and MUST have a
Content-Length header that is set to zero (0). Not setting this header will yield
a <strong>411</strong> status code. The request yields a <strong>204</strong> response
if the lock was deleted successfully. 
</li>
          <li>
            <strong>PUT:</strong>  The message has been not been accepted/processed by the
receiver and the message shall be put back at the head of the queue. This operation
transitions the lock from the locked state into the unlocked state which releases
the message back into the queue. The lock itself is discarded afterwards. The Put
request is sent without any entity body and MUST have a Content-Length header that
is set to zero (0). Not setting this header will yield a <strong>411</strong> status
code. The request yields a <strong>204</strong> response if the lock was released
successfully.</li>
        </ul>
        <h5>Options for Dequeue and Peek/Lock
</h5>
        <p>
The <strong>DELETE</strong> and <strong>POST</strong> operation have a set of options
that are expressed as query parameters appended to the queue's head URI. The options
are the same for both operations:
</p>
        <ul>
          <li>
            <p>
              <strong>timeout=</strong>
              <em>
                <strong>value</strong> - </em>The value is a numerical
value (expressed in seconds) that indicates how long the client is willing to wait
for the polling request to complete. The value should not exceed 60 seconds and a
value of 30 seconds is a safer choice with intermediate proxies in place. If the timeout
expires and no message is available, the request completes with a<strong> 204 </strong>response
code. <strong></strong>The default value is zero (0), which means that the request
returns immediately.<br /></p>
          </li>
          <li>
            <p>
              <strong>maxmessages=<em>value</em></strong>
              <em> - </em>Indicates how many messages
the client is willing to accept in a single response. The default is 1. The service
will return at most 10 messages at a time and a value greater than zero <em>requires</em> encoding=multipart
(see below)<br /></p>
          </li>
          <li>
            <p>
              <strong>encoding=<em>value</em></strong>
              <em> - </em>There are three supported encoding
modes for the REST retrieval model 
</p>
            <ul>
              <li>
                <p>
                  <strong>asreply</strong> - The request stored in the Queue is mapped onto the response
to the DELETE/POST request returning the message from the queue. This option requires
maxmessages=1 or omission of the maxmessages option.
</p>
              </li>
              <li>
                <p>
                  <strong>single</strong> - The request stored in the queue is returned as a complete
HTTP request frame on the response to the DELETE/POST request using Content-Type <strong><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.1">application/http</a></strong>.
This option requires maxmessages=1 or omission of the maxmessages option.
</p>
              </li>
              <li>
                <p>
                  <strong>multipart</strong> - The request(s) stored in the queue are returned as a
complete HTTP request frames on the response to the DELETE/POST request using Content-Type <strong><a href="http://www.ietf.org/rfc/rfc2046.txt">multipart/mixed</a></strong> with
MIME parts of Content-Type <strong><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.1">application/http</a></strong>. 
</p>
              </li>
            </ul>
          </li>
        </ul>
        <h5>Queue Content Control
</h5>
        <p>
          <em>&lt;link rel="queuecontrol" href="https://solution.servicebus.windows.net/myapp/q1!(queue/control)"
/&gt;</em>
        </p>
        <p>
The "<strong>queuecontrol</strong>" link refers to the <em>control</em> resource provides
information about the status of the queue and allows for purging all of the queue's
contents. The control resource is present in the current CTP, but you cannot perform
any operations on it. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=413c6128-a6a6-4894-9cc9-701ffb674ab0" />
      </body>
      <title>.NET Services March 2009 CTP - Service Bus Routers And Queues - Part 3: The REST Queue Protocol</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/02/NET+Services+March+2009+CTP+Service+Bus+Routers+And+Queues+Part+3+The+REST+Queue+Protocol.aspx</link>
      <pubDate>Thu, 02 Apr 2009 22:08:13 GMT</pubDate>
      <description>&lt;p&gt;
[If this text looks vaguely familiar you’ve read the HttpQueueSample Readme doc from
the SDK. Good job!]
&lt;/p&gt;
&lt;p&gt;
Here is the Service Bus Queue REST protocol. I apologize if this is a bit dry, but
I want to give you the bare protocol facts first and will follow-up with code samples
later. Look at the HTTP Queue &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=8D1D1D5E-1332-4186-B33F-26D053759E49&amp;amp;displaylang=en"&gt;SDK
sample&lt;/a&gt; if you can’t wait for code ;-)
&lt;/p&gt;
&lt;p&gt;
You can find the HTTP Queue sample in the SDK install path under &lt;em&gt;.\Samples\ServiceBus\ExploringFeatures\Queues\HttpMessages\&lt;/em&gt; 
&lt;/p&gt;
&lt;p&gt;
The beauty of REST is that there’s a uniform interface. It’s all just GET, POST, PUT,
DELETE, a set of resources, and a rigorous application of the RFC2616 / HTTP 1.1 rules.
That doesn’t make the description particularly entertaining, but it does yield a pretty
consistent interaction model:
&lt;/p&gt;
&lt;h5&gt;Authorization
&lt;/h5&gt;
&lt;p&gt;
All Queue operations require the client to be appropriately authorized. The client
must therefore acquire an lightweight identity token from the Microsoft .NET Access
Control Service using the .NET Services solution name and the solution password and
include the acquired token with each request. The tokens are added to requests using
the &lt;strong&gt;X-MS-Identity-Token&lt;/strong&gt; HTTP header. The value for this header is
a short-lived token which can be used for a period of up to 8 hours and must be acquired
from the .NET Access Control Service. We strongly encourage you to guard the acquired
tokens in the same fashion as you would guard a credential and &lt;strong&gt;you should
not&lt;/strong&gt; openly expose them unprotected on the network or web-pages or embedded
in a Flash or Silverlight application. 
&lt;p&gt;
&lt;p&gt;
The request for acquiring the token is an HTTPS &lt;strong&gt;GET&lt;/strong&gt; on the URI &lt;em&gt;&lt;strong&gt;https://accesscontrol.windows.net/issuetoken.aspx?u={solutionName}&amp;amp;p={solutionPassword}&lt;/strong&gt;&lt;/em&gt; whereby
you replace the arguments for solution name and the solution password with your .NET
Services solution credentials. If a token is successfully issued to you the request
returns with a 200 (OK) status code and contains a &lt;em&gt;&lt;strong&gt;text/plain&lt;/strong&gt;&lt;/em&gt; entity
body with a short, base64 encoded token hash as a single line of text, which you for
the value of the X-MS-Identity-Token header. 
&lt;h5&gt;Creating a Queue
&lt;/h5&gt;
&lt;p&gt;
A Queue is created on the Service Bus in four simple steps. I’ve discussed most of
this in the post on &lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;Queue
Policies&lt;/a&gt;: 
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;
Select a name in the Service Bus naming hierarchy where the Queue should be located,
i.e. &lt;strong&gt;https://&lt;/strong&gt;&lt;em&gt;&lt;strong&gt;mysolution&lt;/strong&gt;&lt;/em&gt;&lt;strong&gt;.servicebus.windows.net/myapp/q1&lt;/strong&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx"&gt;Create
a Queue policy&lt;/a&gt; and define the desired properties of the Queue. 
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
Embed the Queue policy into an ATOM 1.0 &lt;em&gt;&lt;strong&gt;&amp;lt;atom:entry&amp;gt;&lt;/strong&gt;&lt;/em&gt; as
an extension and &lt;strong&gt;POST&lt;/strong&gt; the entry to the designated Queue URI with
the content-type &lt;em&gt;&lt;strong&gt;application/atom+xml;type=entry&lt;/strong&gt;.&lt;/em&gt; &lt;em&gt;&lt;/em&gt;The
request must carry an X-MS-Identity-Token header and the respective identity must
have 'Manage' permission on for scope covering the Queue URI.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
If the queue was successfully created, the POST request returns with a &lt;strong&gt;201&lt;/strong&gt; 'created'
status code along with a &lt;strong&gt;Location&lt;/strong&gt; header. The response entity body
contains the effective Queue policy as applied to the name by the Service Bus. 
&lt;br&gt;
&lt;br&gt;
The location header contains the queue's management URI that you need to retain in
your application state to have access to the queue's metadata and management functions.
If the queue could not be created successfully, the request may yield the following
status codes: 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;400&lt;/strong&gt; - Bad Request. The policy was malformed or invalid.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;403&lt;/strong&gt; - Forbidden. The client did not provide a X-MS-Identity-Token
header, the provided token is no longer valid for use, or the provided identity is
not authorized to create a Queue at this location.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;409&lt;/strong&gt; - Conflict.&amp;nbsp; There is already a Queue with an incompatible
policy at the given location or the location is occupied by a Router or a Service
Bus listener.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;415&lt;/strong&gt; - Unsupported Media Type. The request did not carry the required
content-type header.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;500&lt;/strong&gt; - Internal Server Error. The processing failed to to a condition
internal to the Service Bus service.
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h5&gt;REST Anatomy of a Queue
&lt;/h5&gt;
&lt;p&gt;
Each Queue has five distinct types of resources: &lt;strong&gt;Policy&lt;/strong&gt;, &lt;strong&gt;Tail&lt;/strong&gt;, &lt;strong&gt;Head&lt;/strong&gt;, &lt;strong&gt;Locks&lt;/strong&gt;,
and &lt;strong&gt;Control&lt;/strong&gt;. The concrete URIs are discoverable using the Service
Registry's Atom Publishing protocol. you should not make any assumptions about the
particular format of the URIs spelled out below since the particular format might
change.
&lt;/p&gt;
&lt;p&gt;
The Atom 1.0 entry shown below is also enclosed in the response entity body of the
create request (POST) explained above. A Queue's representation in the registry feed
as seen when doing a &lt;strong&gt;GET&lt;/strong&gt; (discovery-) request on the queue's parent
URI is commonly as follows:
&lt;/p&gt;
&lt;pre&gt;&amp;lt;feed xmlns="http://www.w3.org/2005/Atom"&amp;gt;
  ...
  &amp;lt;entry&amp;gt;
    &amp;lt;id&amp;gt;{id}&amp;lt;/id&amp;gt;
    &amp;lt;title type="text"&amp;gt;MyHttpQueue&amp;lt;/title&amp;gt;
    &amp;lt;updated&amp;gt;{date}&amp;lt;/updated&amp;gt;
    &amp;lt;link rel="alternate" href="https://solution.servicebus.windows.net/myapp/q1" /&amp;gt;
    &amp;lt;link rel="self" href="https://solution.servicebus.windows.net/myapp/q1!(queue)" /&amp;gt;
    &amp;lt;link rel="queuehead" href="https://solution.servicebus.windows.net/myapp/q1!(queue/head)" /&amp;gt;
    &amp;lt;link rel="queuecontrol" href="https://solution.servicebus.windows.net/myapp/q1!(queue/control)" /&amp;gt;
    &amp;lt;QueuePolicy xmlns="http://schemas.microsoft.com/ws/2007/08/connect"&amp;gt;
      &amp;lt;Discoverability&amp;gt;Public&amp;lt;/Discoverability&amp;gt;
      &amp;lt;ExpirationInstant&amp;gt;{expiration}&amp;lt;/ExpirationInstant&amp;gt;
    &amp;lt;/QueuePolicy&amp;gt;
  &amp;lt;/entry&amp;gt;
&amp;lt;/feed&amp;gt;&lt;/pre&gt;
&lt;h5&gt;
&lt;/h5&gt;
&lt;h5&gt;Managing The Queue
&lt;/h5&gt;
&lt;p&gt;
&lt;em&gt;&amp;lt;link rel="self" href="https://solution.servicebus.windows.net/myapp/q1!(queue)"
/&amp;gt; 
&lt;br&gt;
&lt;/em&gt;
&lt;br&gt;
The "&lt;strong&gt;self&lt;/strong&gt;" link in the entry above is the queue's management URI
that allows you to interact with the queue's policy. 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
To renew a queue and extend its expiration you &lt;strong&gt;PUT&lt;/strong&gt; an updated Atom
1.0 entry with the effective policy and an updated &lt;em&gt;ExpirationInstant&lt;/em&gt; value
to the "self" URI.&amp;nbsp; The "self" URI is the same URI as the one returned in the &lt;strong&gt;Location&lt;/strong&gt; header
returned by the create POST explained above. The request will yield a &lt;strong&gt;200&lt;/strong&gt; status
code if the renewal is successful. It will yield a&lt;strong&gt; 404&lt;/strong&gt; if the queue
no longer exists.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
To delete a queue you issue a&lt;strong&gt; DELETE &lt;/strong&gt;request on&amp;nbsp; the queue's
management URI. The Delete request is sent without any entity body and MUST have a
Content-Length header that is set to zero (0). Not setting this header will yield
a &lt;strong&gt;411&lt;/strong&gt; status code. The request yields a &lt;strong&gt;204&lt;/strong&gt; response
if the queue was deleted successfully.
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Enqueue
&lt;/h5&gt;
&lt;p&gt;
&lt;em&gt;&amp;lt;link rel="alternate" href="https://solution.servicebus.windows.net/myapp/q1"
/&amp;gt;&lt;/em&gt; 
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
The "&lt;strong&gt;alternate&lt;/strong&gt;" link refers to the tail of the queue. The Queue's &lt;em&gt;tail&lt;/em&gt; resource
is where senders submit messages into the Queue. The queue's tail URI is identical
to the URI where the queue was initially created. The queue's tail endpoint accepts
requests with any HTTP Content-Type and any HTTP method except GET, HEAD, and OPTIONS.
&lt;/p&gt;
&lt;p&gt;
The endpoint should be considered a 'delegate' of the message recipient and not the
resource that the respective operations have an immediate effect on. That means that
the HTTP method applied to the Queue tail doesn’t have any particular semantic. If
a message has been successfully accepted into the queue, the request returns a &lt;strong&gt;202&lt;/strong&gt; status
code. Otherwise it will return a &lt;strong&gt;500&lt;/strong&gt; 
&lt;/p&gt;
&lt;h5&gt;Dequeue and Peek/Lock
&lt;/h5&gt;
&lt;p&gt;
&lt;em&gt;&amp;lt;link rel="queuehead" href="https://solution.servicebus.windows.net/myapp/q1!(queue/head)"
/&amp;gt;&lt;br&gt;
&lt;/em&gt; 
&lt;p&gt;
The "&lt;strong&gt;queuehead&lt;/strong&gt;" link refers to the head of the Queue. The Queue's &lt;em&gt;head&lt;/em&gt; resource
is where receivers retrieve messages from the queue. It is modeled as a resource whose
current representation corresponds to the message(s) that reside at the head of the
queue and which is/are next in line to be retrieved by consumers. Permitted operations
on the head are: 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DELETE&lt;/strong&gt;:&amp;nbsp; Delete performs a destructive read on the queue whereby
the message(s) at the head of the queue are permanently deleted and returned as the
entity body of the response to the request. The content type and formatting of the
response depends on a set of query parameters that are discussed below. The DELETE
request's response status code is &lt;strong&gt;200&lt;/strong&gt; if at least one message could
be retrieved and deleted from the queue and the message content is enclosed in the
response's entity body. The response status code is &lt;strong&gt;204&lt;em&gt; &lt;/em&gt;&lt;/strong&gt;if
no message could be retrieved/deleted. 
&lt;li&gt;
&lt;strong&gt;POST:&lt;/strong&gt; Post creates a lock on the message(s) at the head of the queue
and returns the locked messages. Locked messages are temporarily removed from the
head of the queue for a period of 1 minute during which time the receiver can decide
whether to return the message to the head of the queue or whether to permanently delete
it. The POST request's response status code is &lt;strong&gt;200&lt;/strong&gt; if at least one
message could be retrieved and locked on the queue and the message content is enclosed
in the response's entity body. The response status code is &lt;strong&gt;204&lt;em&gt; &lt;/em&gt;&lt;/strong&gt;if
no message could be retrieved/locked.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Releasing and Deleting Peek/Lock Message Locks 
&lt;/h5&gt;
&lt;p&gt;
Any retrieved, peek/locked message (POST on “queuehead”) contains an HTTP header &lt;strong&gt;X-MS-Message-Lock &lt;/strong&gt;whose
value is a URI. The following operations can be performed on this URI:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DELETE: &lt;/strong&gt;The message has been accepted/processed by the receiver and
the lock shall be deleted. The deletion of the lock discards the message permanently
from the queue. The Delete request is sent without any entity body and MUST have a
Content-Length header that is set to zero (0). Not setting this header will yield
a &lt;strong&gt;411&lt;/strong&gt; status code. The request yields a &lt;strong&gt;204&lt;/strong&gt; response
if the lock was deleted successfully. 
&lt;li&gt;
&lt;strong&gt;PUT:&lt;/strong&gt;&amp;nbsp; The message has been not been accepted/processed by the
receiver and the message shall be put back at the head of the queue. This operation
transitions the lock from the locked state into the unlocked state which releases
the message back into the queue. The lock itself is discarded afterwards. The Put
request is sent without any entity body and MUST have a Content-Length header that
is set to zero (0). Not setting this header will yield a &lt;strong&gt;411&lt;/strong&gt; status
code. The request yields a &lt;strong&gt;204&lt;/strong&gt; response if the lock was released
successfully.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Options for Dequeue and Peek/Lock
&lt;/h5&gt;
&lt;p&gt;
The &lt;strong&gt;DELETE&lt;/strong&gt; and &lt;strong&gt;POST&lt;/strong&gt; operation have a set of options
that are expressed as query parameters appended to the queue's head URI. The options
are the same for both operations:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;timeout=&lt;/strong&gt;&lt;em&gt;&lt;strong&gt;value&lt;/strong&gt; - &lt;/em&gt;The value is a numerical
value (expressed in seconds) that indicates how long the client is willing to wait
for the polling request to complete. The value should not exceed 60 seconds and a
value of 30 seconds is a safer choice with intermediate proxies in place. If the timeout
expires and no message is available, the request completes with a&lt;strong&gt; 204 &lt;/strong&gt;response
code. &lt;strong&gt;&lt;/strong&gt;The default value is zero (0), which means that the request
returns immediately.&lt;br&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;maxmessages=&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt;&lt;em&gt; - &lt;/em&gt;Indicates how many messages
the client is willing to accept in a single response. The default is 1. The service
will return at most 10 messages at a time and a value greater than zero &lt;em&gt;requires&lt;/em&gt; encoding=multipart
(see below)&lt;br&gt;
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;encoding=&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt;&lt;em&gt; - &lt;/em&gt;There are three supported encoding
modes for the REST retrieval model 
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;asreply&lt;/strong&gt; - The request stored in the Queue is mapped onto the response
to the DELETE/POST request returning the message from the queue. This option requires
maxmessages=1 or omission of the maxmessages option.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;single&lt;/strong&gt; - The request stored in the queue is returned as a complete
HTTP request frame on the response to the DELETE/POST request using Content-Type &lt;strong&gt;&lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.1"&gt;application/http&lt;/a&gt;&lt;/strong&gt;.
This option requires maxmessages=1 or omission of the maxmessages option.
&lt;/p&gt;
&lt;li&gt;
&lt;p&gt;
&lt;strong&gt;multipart&lt;/strong&gt; - The request(s) stored in the queue are returned as a
complete HTTP request frames on the response to the DELETE/POST request using Content-Type &lt;strong&gt;&lt;a href="http://www.ietf.org/rfc/rfc2046.txt"&gt;multipart/mixed&lt;/a&gt;&lt;/strong&gt; with
MIME parts of Content-Type &lt;strong&gt;&lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.1"&gt;application/http&lt;/a&gt;&lt;/strong&gt;. 
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Queue Content Control
&lt;/h5&gt;
&lt;p&gt;
&lt;em&gt;&amp;lt;link rel="queuecontrol" href="https://solution.servicebus.windows.net/myapp/q1!(queue/control)"
/&amp;gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
The "&lt;strong&gt;queuecontrol&lt;/strong&gt;" link refers to the &lt;em&gt;control&lt;/em&gt; resource provides
information about the status of the queue and allows for purging all of the queue's
contents. The control resource is present in the current CTP, but you cannot perform
any operations on it. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=413c6128-a6a6-4894-9cc9-701ffb674ab0" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,413c6128-a6a6-4894-9cc9-701ffb674ab0.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=0f64f592-7239-42fc-aed2-f0993701c5f6</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=0f64f592-7239-42fc-aed2-f0993701c5f6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx">In
the previous post in this series</a> I’ve discussed some of the foundational principles
of the new Queue and Router features of the .NET Services Bus and the role that policies
play in turning names in the namespace into messaging primitives. In this post I’ll
start drilling into the capabilities of the Queue feature and will discuss what’s
in the queue policy. 
</p>
        <p>
The capabilities of the Queue are best explored by looking at the Queue policy. Policies
can be expressed in two ways: You can either you use the .NET Services SDK’s <strong>Microsoft.ServiceBus.QueuePolicy</strong> class
with a .NET application or you can just whip up a bit of XML. The structure and the
serialized representation of that class is exactly equivalent to an XML queue policy
you’d wire up “by hand” and thus I’ll discuss the policy in terms of its XML elements:
</p>
        <p>
The queue policy has the element name “<strong>QueuePolicy</strong>” within the XML
namespace “<em><strong>http://schemas.microsoft.com/ws/2007/08/connect</strong>”. </em>That’s
the namespace we use for most protocols and data structures in the .NET Service Bus
at this development stage and you should expect that we’re migrating to the “final”
V1 namespaces in one of the next CTPs.  If you use the .NET class you’ll just
have to recompile to snap to new namespaces once they come around.
</p>
        <p>
Below is a list of the policy’s elements and the permitted values. All elements are
optional and can appear at most once. The default value applies when an element is
omitted. It’s perfectly ok to send an empty <em>QueuePolicy</em> and accept the default
values to keep things simple. I’d recommend to always set the <em>ExpirationInstant</em> value,
however. 
</p>
        <p>
One required forward reference: Don’t get confused or distracted trying to figure
out from here what it means “to provide an authorization token”. The docs explain
this and I’ll also address this in the next blog post when I dive into the protocol. 
</p>
        <ul>
          <li>
            <strong>Authorization</strong> – The authorization setting indicates whether sender
and/or consumers must provide a security token when interacting with the queue. You
can explicitly permit the .NET Service Bus to allow anonymous consumers and/or anonymous
senders on a Queue. If a token is required, a sender must present a token with “Send”
permission that is issued by the .NET Access Control service and the consumer must
present a token with “Listen” permission that is issued by the .NET Access Control
service. The respective rules are set up in the .NET Access Control service on your
project’s “Service Bus” scope. Mind that all anonymous traffic is attributed to the
“manager” of a Queue, i.e. to whoever sets the policy; all traffic is metered and
accounted for. The permitted values for this element are: 
<ul><li><strong>Required</strong> – (default) Senders and Consumers must provide an authorization
token to send/retrieve messages. 
</li><li><strong>RequiredToSend</strong> – Senders must provide an authorization token with
a “Send” claim to send messages, consumers don’t. 
</li><li><strong>RequiredToReceive</strong> – Consumers must provide an authorization token
with a “Listen” claim to receiver messages, senders don’t. 
</li><li><strong>NotRequired</strong> – Neither senders nor consumers must provide a token,
i.e. the queue is set up for anonymous traffic.<br /></li></ul></li>
          <li>
            <strong>Discoverability</strong> – The discoverability setting defines under which
conditions the Queue and its policy are visible in the Service Registry Atom feed
and any forthcoming discoverability mechanisms. When you are browsing the Service
Registry feed from within a browser, the only setting that will make the Queue visible
is <em>Public</em> since the browser isn’t able to attach an authorization token without
some scripting assistance.  
<ul><li><strong>Managers</strong> - (default) The Queue and its policy are only discoverable
if you provide an authorization token with the request and the token carries a “Manage”
claim. 
</li><li><strong>ManagersListeners</strong> – The Queue and its policy are only discoverable
if you provide and authorization token with the request and the token carries a “Manage”
and/or “Listen” claim. 
</li><li><strong>ManagersListenersSenders</strong> – The Queue and its policy are only discoverable
if you provide and authorization token with the request and the token carries a “Manage”
and/or “Listen” and/or “Send” claim. 
</li><li><strong>Public</strong> – The Queue and its policy are discoverable without any authorization
requirement, i.e. the general public.<br /></li></ul></li>
          <li>
            <strong>ExpirationInstant</strong> – This is an XML dateTime value indicating the
TTL (time-to-live) for the Queue. You can make Queues long-lived or short-lived. A
Queue’s lifetime may be extended by changing this policy value and reapplying the
policy. Once a Queue expires it is removed from the system along with all the messages
that reside in it. The system may limit the Queue lifetime in the effective policy
that you get back from the create/update request, but we’ll typically allow at least
24 hours without renewal. This value has a default of 24 hours, a maximum of 21 days
and a minimum of 30 seconds. The value must represent a future dateTime and must be
expressed in UTC. 
<br /></li>
          <li>
            <strong>MaxMessageSize</strong> – This is a numeric value defining the maximum size
of any individual message that can be accepted into the Queue. The maximum message
size is expressed in bytes and includes all infrastructure-imposed and encoding-related
overhead. The actual overhead varies significantly based on whether messages are sent
as SOAP 1.1, SOAP 1.2, or plain HTTP frames using text or binary encoding and whether
a security token is required. A very defensive assumption is to reserve 10-12KB for
protocol overhead in complex cases with WS* Security; the minimal allocation for protocol
overhead should be around 4KB. The <strong>default</strong> and <strong>maximum</strong> values
for the maximum message size is <strong>60KB</strong> (60*1024 bytes). The minimum
value is <strong>8KB</strong>. We suggest that the <strong>payload size</strong> for
an individual message does <strong>not exceed</strong><strong>48KB</strong>, even
though you can try to push it a bit. The expectation is that these values will trend
up but I don’t see them more than doubling due to throughput, timeliness and scale
considerations. If your data is larger you should consider how you can chunk it up. 
<br /></li>
          <li>
            <strong>TransportProtection</strong> – The transport protection setting defines whether
senders and consumers <strong>must</strong> use HTTPS to interact with the Queue.
This is the default setting. You would modify this to accommodate clients – typically
on devices - that don’t do HTTPS all that well. Permitted values:  
<ul><li><strong>AllPaths</strong> - (default) Any interaction with the queue requires HTTPS. 
</li><li><strong>None</strong> – Any interaction may be performed using either HTTP or HTTPS.<br /></li></ul></li>
          <li>
            <strong>EnqueueTimeout</strong> – The enqueue timeout is an XML duration value that
specifies how long an enqueue operation will hang if the queue is at capacity (full).
The default value is 10 seconds, the minimum is 0 seconds, and the maximum is 60 seconds.
If the timeout expires and the message could not be added to the queue during that
time, the queue will act according to the <strong>Overflow</strong> policy setting. 
<br /></li>
          <li>
            <strong>MaxConcurrentReaders</strong> - <font color="#ff8000">[this setting not supported/enforced
in the March 2009 CTP]</font> The <em>maximum concurrent readers</em> value defines
how many concurrent readers are permitted on the queue. If this numeric value is smaller
than the default value of 2^31 (max int), the queue protocol will switch into ‘session
mode’ that grants a limited number of read-locks on the queue. The minimum value is
1. 
<br /></li>
          <li>
            <strong>MaxDequeueRetries</strong> - <font color="#ff8000">[this setting not supported/enforced
in the March 2009 CTP]</font> The <em>maximum dequeue retries</em> value defines how
often a message may be peek/locked and put back into the queue until it is considered
poisonous, i.e. after how many retries it should be expected the the consumer will
not be able to ever consume the message successfully, because it is malformed or the
consumer experiences an error condition that requires some form of manual intervention
(including a bug fix). If the message is found to be poisonous it will be sent once
and without any retries to the endpoint specified in the policy’s <strong>PoisonMessageDrop</strong> value. 
<br /></li>
          <li>
            <strong>MaxMessageAge</strong> – The <em>maximum message age</em> is an XML duration
value indicating after what time any enqueued message is considered ‘stale” and will
be automatically dropped and removed from the queue. The default value is 10 minutes
(600 seconds), the minimum value is 0 seconds (which effectively means that all incoming
messages get dropped), the maximum value is 7 days. 
<br /></li>
          <li>
            <strong>MaxQueueCapacity</strong> – This numeric value indicates the maximum size
of the Queue in bytes. This is a system-calculated value that cannot be set on the
.NET class and should not be set by clients creating policies from scratch. The default
and <strong>maximum capacity</strong> of any queue is currently capped at <strong>2MB</strong>.
This is a limitation specific to the March 2009 CTP , it’s been painful to impose
this constraint, and it’s absolutely expected that this limit will be expanded significantly.
2MB still allow for a several hundred notification messages of a 2-4KB. If you need
to store more data you can absolutely create several queues and partition data across
them either explicitly or using Routers with a load-balancing message distribution
policy (more on that in a subsequent post). 
<br /></li>
          <li>
            <strong>MaxQueueLength</strong> – This numeric value indicates the maximum queue length.
The maximum and default value is 2^31, the minimum value is 1. <font color="#ff8000">We’re
not enforcing the exact queue length in the March 2009 CTP</font>, but your code should
assume that we do. The queue length value is the basis for the calculation of the <strong>MaxQueueCapacity</strong>,
with MaxQueueCapacity = min(MaxQueueLength * MaxMessageSize, 2MB) enforcing the hard
2MB limit that is currently in effect. You don’t need to touch this value unless you’d
really want a Queue that’s even more size-constrained. 
<br /></li>
          <li>
            <strong>Overflow</strong> – The overflow policy setting becomes relevant when the
queue is at capacity and the <strong>EnqueueTimeout</strong> has expired. It tells
the Queue what to do with the message that just came in and that can’t be put into
the queue because it’s full. Permitted values:  
<ul><li><strong>RejectIncomingMessage</strong> - (default) The message will be rejected and
an error status code or SOAP fault will be sent to the sender. 
</li><li><strong>DiscardIncomingMessage</strong> – The sender will get an indication that the
message has been accepted, but the message will be dropped on the floor. 
</li><li><strong>DiscardExistingMessage</strong> – The Queue will remove and discard messages
from the head of the Queue until the new, incoming message fits in the Queue.<br /></li></ul></li>
          <li>
            <strong>PoisonMessageDrop</strong> – <font color="#ff8000">[this setting not supported
in the March 2009 CTP]</font> This value is a WS-Addressing 1.0 EndpointReference
referring to an endpoint that any poison messages will be sent to once the <strong>MaxDequeueRetries</strong> limit
has been exceeded. The EndpointReference may point to any SOAP or plain HTTP endpoint
that can accept ‘any’ message. 
</li>
        </ul>
        <p>
Phew! Lots of options. The good thing is that most apps should be ok with the defaults. 
</p>
        <p>
I know that the 2MB capacity limit is somewhat disappointing and I’m certainly not
happy with it. There’s a particular behavior (with bug number) that may occur under
very rare circumstances in the underlying replication system, which caused us to play
it very safe instead of risking data loss. I don’t think the limit is a showstopper
for apps that send notifications and events around – it is a showstopper for apps
that want to exchange larger payloads and we’re working to relax that limit and make
Queues much, much larger as soon as we can. You can obviously always spool larger
data into SDS or one of the Azure storage systems and then send a reference to that
data as a message, but it’d be strange for a messaging system to make that a required
pattern for data of all sizes. If we’re talking hundreds of megabytes it makes sense,
though.
</p>
        <p>
With the due apology out of the way, let’s look at how a policy may be applied to
a namespace name – or in other words, how a queue is created in the simplest case
(this must be done via HTTPS). The model here is that the client <em>proposes</em> a
policy and Service Bus is at liberty to adjust the policy. 
</p>
        <p>
If you are intimately familiar with Atom, you’ll notice that the &lt;QueuePolicy&gt;
is an extension and isn’t carried as &lt;content&gt;. That’s by intent. &lt;content&gt;
is for people, extensions are for apps. We’ll start using &lt;content&gt; in a later
milestone, so consider that being <em>reserved</em>.
</p>
        <p>
          <font face="Courier New">
            <strong>HTTP/1.1 POST /myapp/q1<br />
Host: clemensv.servicebus.windows.net<br />
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==<br />
Content-Type: application/atom+xml;type=entry;charset=utf-8<br />
Content-Length: nnn<br /><br />
&lt;entry xmlns=”<em>http://www.w3.org/2005/Atom</em>”&gt;<br />
   &lt;QueuePolicy xmlns=”</strong>
            <strong>
              <em>http://schemas.microsoft.com/ws/2007/08/connect”&gt;<br />
      &lt;ExpirationInstant&gt;2009-04-03T12:00:00&lt;/ExpirationInstant&gt;<br />
   &lt;/QueuePolicy&gt; </em>
              <br />
&lt;/entry&gt;</strong>
          </font>
        </p>
        <p>
If the queue can be created, the response is a 200 and you get the policy back along
with any adjustments that the service may make. This is called the “effective” policy,
i.e. that’s what the server is using. You also learn about where you can modify the
policy, since – <a href="http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx">as
I explained before</a> – the endpoint where you POST the policy to is morphing into
the Queue’s tail.
</p>
        <p>
          <font face="Courier New">
            <strong>HTTP/1.1 200 OK<br />
Location: https://project-name.servicebus.windows.net/myapp/q1!(queue)<br />
Content-Type: application/atom+xml;type=entry;charset=utf-8<br />
Content-Length: nnn<br /><br />
&lt;entry xmlns=”<em>http://www.w3.org/2005/Atom</em>”&gt;<br />
   &lt;link rel=”self” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue)”
/&gt;<br />
   &lt;link rel=”alternate” href=”https://project-name.servicebus.windows.net/myapp/q1”
/&gt; 
<br />
   &lt;link rel=”queuehead” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue/head)”
/&gt; 
<br />
   &lt;QueuePolicy xmlns=”</strong>
          </font>
          <font face="Courier New">
            <strong>
              <em>http://schemas.microsoft.com/ws/2007/08/connect”
&gt;<br /></em>         &lt;ExpirationInstant&gt;2009-04-03T12:00:00&lt;/ExpirationInstant&gt;<br />
         &lt;MaxQueueCapacity&gt;2097152&lt;/MaxQueueCapacity&gt;<br />
   &lt;/QueuePolicy&gt;<br />
&lt;/entry&gt;</strong>
          </font>
        </p>
        <p>
If you want to renew the Queue (extend the expiration), take the effective policy,
adjust ExpirationInstant and do a PUT to the “self” location. 
</p>
        <p>
          <strong>
            <font face="Courier New">HTTP/1.1 PUT /myapp/q1<font color="#ff0000">!(queue)</font><br />
Host: project-name.servicebus.windows.net<br />
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==<br />
Content-Type: application/atom+xml;type=entry;charset=utf-8<br />
Content-Length: nnn<br /><br /></font>
          </strong>
          <strong>
            <font face="Courier New">&lt;entry xmlns=”<em>http://www.w3.org/2005/Atom</em>”&gt;<br />
   &lt;link rel=”self” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue)”
/&gt;<br />
   &lt;link rel=”alternate” href=”https://project-name.servicebus.windows.net/myapp/q1”
/&gt; 
<br />
   &lt;link rel=”queuehead” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue/head)”
/&gt; 
<br />
   &lt;QueuePolicy xmlns=”</font>
          </strong>
          <strong>
            <font face="Courier New">
              <em>http://schemas.microsoft.com/ws/2007/08/connect”
&gt;<br /></em>         &lt;ExpirationInstant&gt;<font color="#ff0000">2009-04-04T12:00:00</font>&lt;/ExpirationInstant&gt;<br />
         &lt;MaxQueueCapacity&gt;2097152&lt;/MaxQueueCapacity&gt;<br />
   &lt;/QueuePolicy&gt;<br />
&lt;/entry&gt;</font>
          </strong>
        </p>
        <p>
[<strong><font color="#008080">Bug note:</font></strong> The PUT will return the new
effective policy just like the POST response shown above, but the returned Atom &lt;links&gt;
aren’t correctly formed. Keep the ones returned from the POST]
</p>
        <p>
If you want to delete the queue, just nuke the policy:
</p>
        <p>
          <strong>
            <font face="Courier New">HTTP/1.1 DELETE /myapp/q1<font color="#ff0000">!(queue)</font><br />
Host: project-name.servicebus.windows.net<br />
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==<br />
Content-Length: 0</font>
          </strong>
        </p>
        <p>
So that’s the policy story for Queues. In the next posts I’ll discuss the REST Queue
protocol and the SOAP Queue protocol for how you send message to the queue and get
messages out. REST I’ll explain in protocol terms, the SOAP model in .NET programming
model terms. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=0f64f592-7239-42fc-aed2-f0993701c5f6" />
      </body>
      <title>.NET Services March 2009 CTP - Service Bus Routers And Queues - Part 2: Queue Policies</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/02/NET+Services+March+2009+CTP+Service+Bus+Routers+And+Queues+Part+2+Queue+Policies.aspx</link>
      <pubDate>Thu, 02 Apr 2009 20:10:25 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx"&gt;In
the previous post in this series&lt;/a&gt; I’ve discussed some of the foundational principles
of the new Queue and Router features of the .NET Services Bus and the role that policies
play in turning names in the namespace into messaging primitives. In this post I’ll
start drilling into the capabilities of the Queue feature and will discuss what’s
in the queue policy. 
&lt;/p&gt;
&lt;p&gt;
The capabilities of the Queue are best explored by looking at the Queue policy. Policies
can be expressed in two ways: You can either you use the .NET Services SDK’s &lt;strong&gt;Microsoft.ServiceBus.QueuePolicy&lt;/strong&gt; class
with a .NET application or you can just whip up a bit of XML. The structure and the
serialized representation of that class is exactly equivalent to an XML queue policy
you’d wire up “by hand” and thus I’ll discuss the policy in terms of its XML elements:
&lt;/p&gt;
&lt;p&gt;
The queue policy has the element name “&lt;strong&gt;QueuePolicy&lt;/strong&gt;” within the XML
namespace “&lt;em&gt;&lt;strong&gt;http://schemas.microsoft.com/ws/2007/08/connect&lt;/strong&gt;”. &lt;/em&gt;That’s
the namespace we use for most protocols and data structures in the .NET Service Bus
at this development stage and you should expect that we’re migrating to the “final”
V1 namespaces in one of the next CTPs.&amp;nbsp; If you use the .NET class you’ll just
have to recompile to snap to new namespaces once they come around.
&lt;/p&gt;
&lt;p&gt;
Below is a list of the policy’s elements and the permitted values. All elements are
optional and can appear at most once. The default value applies when an element is
omitted. It’s perfectly ok to send an empty &lt;em&gt;QueuePolicy&lt;/em&gt; and accept the default
values to keep things simple. I’d recommend to always set the &lt;em&gt;ExpirationInstant&lt;/em&gt; value,
however. 
&lt;/p&gt;
&lt;p&gt;
One required forward reference: Don’t get confused or distracted trying to figure
out from here what it means “to provide an authorization token”. The docs explain
this and I’ll also address this in the next blog post when I dive into the protocol. 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authorization&lt;/strong&gt; – The authorization setting indicates whether sender
and/or consumers must provide a security token when interacting with the queue. You
can explicitly permit the .NET Service Bus to allow anonymous consumers and/or anonymous
senders on a Queue. If a token is required, a sender must present a token with “Send”
permission that is issued by the .NET Access Control service and the consumer must
present a token with “Listen” permission that is issued by the .NET Access Control
service. The respective rules are set up in the .NET Access Control service on your
project’s “Service Bus” scope. Mind that all anonymous traffic is attributed to the
“manager” of a Queue, i.e. to whoever sets the policy; all traffic is metered and
accounted for. The permitted values for this element are: 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Required&lt;/strong&gt; – (default) Senders and Consumers must provide an authorization
token to send/retrieve messages. 
&lt;li&gt;
&lt;strong&gt;RequiredToSend&lt;/strong&gt; – Senders must provide an authorization token with
a “Send” claim to send messages, consumers don’t. 
&lt;li&gt;
&lt;strong&gt;RequiredToReceive&lt;/strong&gt; – Consumers must provide an authorization token
with a “Listen” claim to receiver messages, senders don’t. 
&lt;li&gt;
&lt;strong&gt;NotRequired&lt;/strong&gt; – Neither senders nor consumers must provide a token,
i.e. the queue is set up for anonymous traffic.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
&lt;strong&gt;Discoverability&lt;/strong&gt; – The discoverability setting defines under which
conditions the Queue and its policy are visible in the Service Registry Atom feed
and any forthcoming discoverability mechanisms. When you are browsing the Service
Registry feed from within a browser, the only setting that will make the Queue visible
is &lt;em&gt;Public&lt;/em&gt; since the browser isn’t able to attach an authorization token without
some scripting assistance.&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Managers&lt;/strong&gt; - (default) The Queue and its policy are only discoverable
if you provide an authorization token with the request and the token carries a “Manage”
claim. 
&lt;li&gt;
&lt;strong&gt;ManagersListeners&lt;/strong&gt; – The Queue and its policy are only discoverable
if you provide and authorization token with the request and the token carries a “Manage”
and/or “Listen” claim. 
&lt;li&gt;
&lt;strong&gt;ManagersListenersSenders&lt;/strong&gt; – The Queue and its policy are only discoverable
if you provide and authorization token with the request and the token carries a “Manage”
and/or “Listen” and/or “Send” claim. 
&lt;li&gt;
&lt;strong&gt;Public&lt;/strong&gt; – The Queue and its policy are discoverable without any authorization
requirement, i.e. the general public.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
&lt;strong&gt;ExpirationInstant&lt;/strong&gt; – This is an XML dateTime value indicating the
TTL (time-to-live) for the Queue. You can make Queues long-lived or short-lived. A
Queue’s lifetime may be extended by changing this policy value and reapplying the
policy. Once a Queue expires it is removed from the system along with all the messages
that reside in it. The system may limit the Queue lifetime in the effective policy
that you get back from the create/update request, but we’ll typically allow at least
24 hours without renewal. This value has a default of 24 hours, a maximum of 21 days
and a minimum of 30 seconds. The value must represent a future dateTime and must be
expressed in UTC. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxMessageSize&lt;/strong&gt; – This is a numeric value defining the maximum size
of any individual message that can be accepted into the Queue. The maximum message
size is expressed in bytes and includes all infrastructure-imposed and encoding-related
overhead. The actual overhead varies significantly based on whether messages are sent
as SOAP 1.1, SOAP 1.2, or plain HTTP frames using text or binary encoding and whether
a security token is required. A very defensive assumption is to reserve 10-12KB for
protocol overhead in complex cases with WS* Security; the minimal allocation for protocol
overhead should be around 4KB. The &lt;strong&gt;default&lt;/strong&gt; and &lt;strong&gt;maximum&lt;/strong&gt; values
for the maximum message size is &lt;strong&gt;60KB&lt;/strong&gt; (60*1024 bytes). The minimum
value is &lt;strong&gt;8KB&lt;/strong&gt;. We suggest that the &lt;strong&gt;payload size&lt;/strong&gt; for
an individual message does &lt;strong&gt;not exceed&lt;/strong&gt; &lt;strong&gt;48KB&lt;/strong&gt;, even
though you can try to push it a bit. The expectation is that these values will trend
up but I don’t see them more than doubling due to throughput, timeliness and scale
considerations. If your data is larger you should consider how you can chunk it up. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;TransportProtection&lt;/strong&gt; – The transport protection setting defines whether
senders and consumers &lt;strong&gt;must&lt;/strong&gt; use HTTPS to interact with the Queue.
This is the default setting. You would modify this to accommodate clients – typically
on devices - that don’t do HTTPS all that well. Permitted values:&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AllPaths&lt;/strong&gt; - (default) Any interaction with the queue requires HTTPS. 
&lt;li&gt;
&lt;strong&gt;None&lt;/strong&gt; – Any interaction may be performed using either HTTP or HTTPS.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
&lt;strong&gt;EnqueueTimeout&lt;/strong&gt; – The enqueue timeout is an XML duration value that
specifies how long an enqueue operation will hang if the queue is at capacity (full).
The default value is 10 seconds, the minimum is 0 seconds, and the maximum is 60 seconds.
If the timeout expires and the message could not be added to the queue during that
time, the queue will act according to the &lt;strong&gt;Overflow&lt;/strong&gt; policy setting. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxConcurrentReaders&lt;/strong&gt; - &lt;font color=#ff8000&gt;[this setting not supported/enforced
in the March 2009 CTP]&lt;/font&gt; The &lt;em&gt;maximum concurrent readers&lt;/em&gt; value defines
how many concurrent readers are permitted on the queue. If this numeric value is smaller
than the default value of 2^31 (max int), the queue protocol will switch into ‘session
mode’ that grants a limited number of read-locks on the queue. The minimum value is
1. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxDequeueRetries&lt;/strong&gt; - &lt;font color=#ff8000&gt;[this setting not supported/enforced
in the March 2009 CTP]&lt;/font&gt; The &lt;em&gt;maximum dequeue retries&lt;/em&gt; value defines how
often a message may be peek/locked and put back into the queue until it is considered
poisonous, i.e. after how many retries it should be expected the the consumer will
not be able to ever consume the message successfully, because it is malformed or the
consumer experiences an error condition that requires some form of manual intervention
(including a bug fix). If the message is found to be poisonous it will be sent once
and without any retries to the endpoint specified in the policy’s &lt;strong&gt;PoisonMessageDrop&lt;/strong&gt; value. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxMessageAge&lt;/strong&gt; – The &lt;em&gt;maximum message age&lt;/em&gt; is an XML duration
value indicating after what time any enqueued message is considered ‘stale” and will
be automatically dropped and removed from the queue. The default value is 10 minutes
(600 seconds), the minimum value is 0 seconds (which effectively means that all incoming
messages get dropped), the maximum value is 7 days. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxQueueCapacity&lt;/strong&gt; – This numeric value indicates the maximum size
of the Queue in bytes. This is a system-calculated value that cannot be set on the
.NET class and should not be set by clients creating policies from scratch. The default
and &lt;strong&gt;maximum capacity&lt;/strong&gt; of any queue is currently capped at &lt;strong&gt;2MB&lt;/strong&gt;.
This is a limitation specific to the March 2009 CTP , it’s been painful to impose
this constraint, and it’s absolutely expected that this limit will be expanded significantly.
2MB still allow for a several hundred notification messages of a 2-4KB. If you need
to store more data you can absolutely create several queues and partition data across
them either explicitly or using Routers with a load-balancing message distribution
policy (more on that in a subsequent post). 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;MaxQueueLength&lt;/strong&gt; – This numeric value indicates the maximum queue length.
The maximum and default value is 2^31, the minimum value is 1. &lt;font color=#ff8000&gt;We’re
not enforcing the exact queue length in the March 2009 CTP&lt;/font&gt;, but your code should
assume that we do. The queue length value is the basis for the calculation of the &lt;strong&gt;MaxQueueCapacity&lt;/strong&gt;,
with MaxQueueCapacity = min(MaxQueueLength * MaxMessageSize, 2MB) enforcing the hard
2MB limit that is currently in effect. You don’t need to touch this value unless you’d
really want a Queue that’s even more size-constrained. 
&lt;br&gt;
&lt;li&gt;
&lt;strong&gt;Overflow&lt;/strong&gt; – The overflow policy setting becomes relevant when the
queue is at capacity and the &lt;strong&gt;EnqueueTimeout&lt;/strong&gt; has expired. It tells
the Queue what to do with the message that just came in and that can’t be put into
the queue because it’s full. Permitted values:&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RejectIncomingMessage&lt;/strong&gt; - (default) The message will be rejected and
an error status code or SOAP fault will be sent to the sender. 
&lt;li&gt;
&lt;strong&gt;DiscardIncomingMessage&lt;/strong&gt; – The sender will get an indication that the
message has been accepted, but the message will be dropped on the floor. 
&lt;li&gt;
&lt;strong&gt;DiscardExistingMessage&lt;/strong&gt; – The Queue will remove and discard messages
from the head of the Queue until the new, incoming message fits in the Queue.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
&lt;strong&gt;PoisonMessageDrop&lt;/strong&gt; – &lt;font color=#ff8000&gt;[this setting not supported
in the March 2009 CTP]&lt;/font&gt; This value is a WS-Addressing 1.0 EndpointReference
referring to an endpoint that any poison messages will be sent to once the &lt;strong&gt;MaxDequeueRetries&lt;/strong&gt; limit
has been exceeded. The EndpointReference may point to any SOAP or plain HTTP endpoint
that can accept ‘any’ message. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Phew! Lots of options. The good thing is that most apps should be ok with the defaults. 
&lt;/p&gt;
&lt;p&gt;
I know that the 2MB capacity limit is somewhat disappointing and I’m certainly not
happy with it. There’s a particular behavior (with bug number) that may occur under
very rare circumstances in the underlying replication system, which caused us to play
it very safe instead of risking data loss. I don’t think the limit is a showstopper
for apps that send notifications and events around – it is a showstopper for apps
that want to exchange larger payloads and we’re working to relax that limit and make
Queues much, much larger as soon as we can. You can obviously always spool larger
data into SDS or one of the Azure storage systems and then send a reference to that
data as a message, but it’d be strange for a messaging system to make that a required
pattern for data of all sizes. If we’re talking hundreds of megabytes it makes sense,
though.
&lt;/p&gt;
&lt;p&gt;
With the due apology out of the way, let’s look at how a policy may be applied to
a namespace name – or in other words, how a queue is created in the simplest case
(this must be done via HTTPS). The model here is that the client &lt;em&gt;proposes&lt;/em&gt; a
policy and Service Bus is at liberty to adjust the policy. 
&lt;/p&gt;
&lt;p&gt;
If you are intimately familiar with Atom, you’ll notice that the &amp;lt;QueuePolicy&amp;gt;
is an extension and isn’t carried as &amp;lt;content&amp;gt;. That’s by intent. &amp;lt;content&amp;gt;
is for people, extensions are for apps. We’ll start using &amp;lt;content&amp;gt; in a later
milestone, so consider that being &lt;em&gt;reserved&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;strong&gt;HTTP/1.1 POST /myapp/q1&lt;br&gt;
Host: clemensv.servicebus.windows.net&lt;br&gt;
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==&lt;br&gt;
Content-Type: application/atom+xml;type=entry;charset=utf-8&lt;br&gt;
Content-Length: nnn&lt;br&gt;
&lt;br&gt;
&amp;lt;entry xmlns=”&lt;em&gt;http://www.w3.org/2005/Atom&lt;/em&gt;”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;QueuePolicy xmlns=”&lt;/strong&gt;&lt;strong&gt;&lt;em&gt;http://schemas.microsoft.com/ws/2007/08/connect”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ExpirationInstant&amp;gt;2009-04-03T12:00:00&amp;lt;/ExpirationInstant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/QueuePolicy&amp;gt; &lt;/em&gt;
&lt;br&gt;
&amp;lt;/entry&amp;gt;&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
If the queue can be created, the response is a 200 and you get the policy back along
with any adjustments that the service may make. This is called the “effective” policy,
i.e. that’s what the server is using. You also learn about where you can modify the
policy, since – &lt;a href="http://vasters.com/clemensv/PermaLink,guid,8e30d2eb-6e2d-4dc5-8aba-5aa410e450de.aspx"&gt;as
I explained before&lt;/a&gt; – the endpoint where you POST the policy to is morphing into
the Queue’s tail.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;strong&gt;HTTP/1.1 200 OK&lt;br&gt;
Location: https://project-name.servicebus.windows.net/myapp/q1!(queue)&lt;br&gt;
Content-Type: application/atom+xml;type=entry;charset=utf-8&lt;br&gt;
Content-Length: nnn&lt;br&gt;
&lt;br&gt;
&amp;lt;entry xmlns=”&lt;em&gt;http://www.w3.org/2005/Atom&lt;/em&gt;”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”self” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue)”
/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”alternate” href=”https://project-name.servicebus.windows.net/myapp/q1”
/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”queuehead” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue/head)”
/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;QueuePolicy xmlns=”&lt;/strong&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;strong&gt;&lt;em&gt;http://schemas.microsoft.com/ws/2007/08/connect”
&amp;gt;&lt;br&gt;
&lt;/em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ExpirationInstant&amp;gt;2009-04-03T12:00:00&amp;lt;/ExpirationInstant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MaxQueueCapacity&amp;gt;2097152&amp;lt;/MaxQueueCapacity&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/QueuePolicy&amp;gt;&lt;br&gt;
&amp;lt;/entry&amp;gt;&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
If you want to renew the Queue (extend the expiration), take the effective policy,
adjust ExpirationInstant and do a PUT to the “self” location. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font face="Courier New"&gt;HTTP/1.1 PUT /myapp/q1&lt;font color=#ff0000&gt;!(queue)&lt;/font&gt;
&lt;br&gt;
Host: project-name.servicebus.windows.net&lt;br&gt;
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==&lt;br&gt;
Content-Type: application/atom+xml;type=entry;charset=utf-8&lt;br&gt;
Content-Length: nnn&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;/strong&gt;&lt;strong&gt;&lt;font face="Courier New"&gt;&amp;lt;entry xmlns=”&lt;em&gt;http://www.w3.org/2005/Atom&lt;/em&gt;”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”self” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue)”
/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”alternate” href=”https://project-name.servicebus.windows.net/myapp/q1”
/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;link rel=”queuehead” href=”https://project-name.servicebus.windows.net/myapp/q1!(queue/head)”
/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;QueuePolicy xmlns=”&lt;/font&gt;&lt;/strong&gt;&lt;strong&gt;&lt;font face="Courier New"&gt;&lt;em&gt;http://schemas.microsoft.com/ws/2007/08/connect”
&amp;gt;&lt;br&gt;
&lt;/em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ExpirationInstant&amp;gt;&lt;font color=#ff0000&gt;2009-04-04T12:00:00&lt;/font&gt;&amp;lt;/ExpirationInstant&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MaxQueueCapacity&amp;gt;2097152&amp;lt;/MaxQueueCapacity&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/QueuePolicy&amp;gt;&lt;br&gt;
&amp;lt;/entry&amp;gt;&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
[&lt;strong&gt;&lt;font color=#008080&gt;Bug note:&lt;/font&gt;&lt;/strong&gt; The PUT will return the new
effective policy just like the POST response shown above, but the returned Atom &amp;lt;links&amp;gt;
aren’t correctly formed. Keep the ones returned from the POST]
&lt;/p&gt;
&lt;p&gt;
If you want to delete the queue, just nuke the policy:
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font face="Courier New"&gt;HTTP/1.1 DELETE /myapp/q1&lt;font color=#ff0000&gt;!(queue)&lt;/font&gt;
&lt;br&gt;
Host: project-name.servicebus.windows.net&lt;br&gt;
X-MS-Identity-Token: A6hbJklu18hsnHRql61k1==&lt;br&gt;
Content-Length: 0&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
So that’s the policy story for Queues. In the next posts I’ll discuss the REST Queue
protocol and the SOAP Queue protocol for how you send message to the queue and get
messages out. REST I’ll explain in protocol terms, the SOAP model in .NET programming
model terms. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=0f64f592-7239-42fc-aed2-f0993701c5f6" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,0f64f592-7239-42fc-aed2-f0993701c5f6.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=634b72d9-e200-45de-82db-2ae4c8ef947e</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,634b72d9-e200-45de-82db-2ae4c8ef947e.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,634b72d9-e200-45de-82db-2ae4c8ef947e.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=634b72d9-e200-45de-82db-2ae4c8ef947e</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>… <a href="http://de.wikipedia.org/wiki/Auf_der_Mauer,_auf_der_Lauer">seht Euch
mal die Wa an, wie die Wa ta kann. Auf der Mauer auf der Lauer sitzt ‘ne kleine Wa!</a>.</em>
        </p>
        <p>
It’s a German children’s song. The song starts out with “… sitzt ‘ne kleine Wanze”
(bedbug) and with each verse you leave off a letter: Wanz, Wan, Wa, W, – silence. 
</p>
        <p>
I’ll do the same here, but not with a bedbug:
</p>
        <p>
Let’s sing:
</p>
        <p>
          <font face="Courier New">&lt;soap:Envelope xmlns:soap=”” xmlns:wsaddr=”” xmlns:wsrm=””
xmlns:wsu=”” xmlns:app=””&gt;<br />
   &lt;soap:Header&gt;<br />
         &lt;addr:Action&gt;http://tempuri.org/1.0/Status.set&lt;/addr:Action&gt;<br />
         &lt;wsrm:Sequence&gt;<br />
              &lt;wsrm:Identifier&gt;urn:session-id&lt;/wsrm:Identifier&gt;<br />
              &lt;wsrm:MessageNumber&gt;5&lt;/wsrm:MessageNumber&gt;<br />
          &lt;/wsrm:Sequence&gt;<br />
          &lt;wsse:Security xmlns:wsse=”…”&gt;<br />
              
&lt;wsse:BinarySecurityToken ValueType="</font>
          <font face="Courier New">http://tempuri.org#CustomToken</font>
          <font face="Courier New">" 
<br />
                                        
EncodingType="...#Base64Binary" wsu:Id=" MyID "&gt;<br />
                         
FHUIORv...<br />
               
&lt;/wsse:BinarySecurityToken&gt;<br />
              
&lt;ds:Signature&gt;<br />
                 
&lt;ds:SignedInfo&gt; 
<br />
                     
&lt;ds:CanonicalizationMethod Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;</font>
          <br />
          <font face="Courier New">                     
&lt;ds:SignatureMethod Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig#md5"/</font>
          <font face="Courier New">&gt;  
<br />
                     
&lt;ds:Reference URI="#MsgBody"&gt;<br />
                           
&lt;ds:DigestMethod  Algorithm="</font>
          <font face="Courier New">http://www.w3.org/2000/09/xmldsig#md5"/&gt;</font>
          <font face="Courier New"> <br />
                           
&lt;ds:DigestValue&gt;LyLsF0Pi4wPU...&lt;/ds:DigestValue&gt;<br />
                     
&lt;/ds:Reference&gt;<br />
                
&lt;/ds:SignedInfo&gt;   
<br />
                
&lt;ds:SignatureValue&gt;DJbchm5gK...&lt;/ds:SignatureValue&gt; 
<br />
                
&lt;ds:KeyInfo&gt;  
<br />
                 
&lt;wsse:SecurityTokenReference&gt;  
<br />
                   
&lt;wsse:Reference URI="#MyID"/&gt; 
<br />
                  
&lt;/wsse:SecurityTokenReference&gt; 
<br />
              
&lt;/ds:KeyInfo&gt; 
<br />
             &lt;/ds:Signature&gt;<br />
         &lt;/wsse:Security&gt;<br />
         &lt;app:ResponseFormat&gt;Xml&lt;/app:ResponseFormat&gt;<br />
         &lt;app:Key wsu:Id=”AppKey”&gt;27729912882….&lt;/app:Key&gt; 
<br />
    &lt;soap:Header&gt;<br />
    &lt;soap:Body wsu:Id=”MyId”&gt;<br />
          &lt;app:status&gt;Hello, I’m
good&lt;/app:status&gt;<br />
     &lt;/soap:Body&gt;<br />
&lt;/soap:Envelope&gt; </font>
        </p>
        <p>
Not a very pretty song, I’ll admit. Let’s drop a some stuff. Let’s assume that we
don’t need to tell the other party that we’re looking to give it an MD5 signature,
but let’s say that’s implied and so were the canonicalization algorithm. Let’s also
assume that the other side already knows the security token and the key. Since we
only have a single signature digest here and yield a single signature we can just
collapse to the signature value. Heck, you may not even know about what that all means.
Verse 2:
</p>
        <p>
          <font face="Courier New">&lt;soap:Envelope xmlns:soap=”” xmlns:wsaddr=”” xmlns:wsrm=””
xmlns:wsu=”” xmlns:app=””&gt;<br />
   &lt;soap:Header&gt;<br />
         &lt;addr:Action&gt;http://tempuri.org/1.0/Status.set&lt;/addr:Action&gt;<br />
         &lt;wsrm:Sequence&gt;<br />
              &lt;wsrm:Identifier&gt;urn:session-id&lt;/wsrm:Identifier&gt;<br />
              &lt;wsrm:MessageNumber&gt;5&lt;/wsrm:MessageNumber&gt;<br />
          &lt;/wsrm:Sequence&gt;<br />
          &lt;wsse:Security xmlns:wsse=”…”&gt;<br />
              
&lt;ds:Signature&gt;<br />
                 
&lt;ds:SignatureValue&gt;DJbchm5gK...&lt;/ds:SignatureValue&gt; 
<br />
             &lt;/ds:Signature&gt;<br />
         &lt;/wsse:Security&gt;<br />
         &lt;app:ResponseFormat&gt;Xml&lt;/app:ResponseFormat&gt;<br />
         &lt;app:Key wsu:Id=”AppKey”&gt;27729912882….&lt;/app:Key&gt; 
<br />
    &lt;soap:Header&gt;<br />
    &lt;soap:Body wsu:Id=”MyId”&gt;<br />
          &lt;app:status&gt;Hello, I’m
good&lt;/app:status&gt;<br />
     &lt;/soap:Body&gt;<br />
&lt;/soap:Envelope&gt; </font>
        </p>
        <p>
Better. Now let’s strip all these extra XML namespace decorations since there aren’t
any name collisions as far as I can see. We’ll also collapse the rest of the security
elements into one element since there’s no need for three levels of nesting with a
single signature. Verse 3:
</p>
        <p>
          <font face="Courier New">&lt;Envelope&gt;<br />
   &lt;Header&gt;<br />
         &lt;Action&gt;http://tempuri.org/1.0/Status.set&lt;/Action&gt;<br />
         &lt;Sequence&gt;<br />
              &lt;Identifier&gt;urn:session-id&lt;/Identifier&gt;<br />
              &lt;MessageNumber&gt;5&lt;/MessageNumber&gt;<br />
          &lt;/Sequence&gt;<br />
          &lt;SignatureValue&gt;DJbchm5gK...&lt;/SignatureValue&gt;<br />
          &lt;ResponseFormat&gt;Xml&lt;/ResponseFormat&gt;<br />
          &lt;Key&gt;27729912882….&lt;/Key&gt; 
<br />
    &lt;Header&gt;<br />
    &lt;Body&gt;<br />
       &lt;status&gt;Hello, I’m good&lt;/status&gt;<br />
     &lt;/Body&gt;<br />
&lt;/Envelope&gt; </font>
        </p>
        <p>
Much better. The whole angle-bracket stuff and the nesting seems semi-gratuitous and
repetitive here, too. Let’s make that a bit simpler. Verse 4:
</p>
        <p>
          <font face="Courier New">         Action=http://tempuri.org/1.0/Status.set<br />
         Sequence-Identifier=urn:session-id<br />
         Sequence-MessageNumber=5<br />
         SignatureValue=DJbchm5gK...<br />
         ResponseFormat=Xml<br />
         Key=27729912882…. 
<br />
         status=Hello, I’m good</font>
        </p>
        <p>
Much, much better. Now let’s get rid of that weird URI up there and split up the action
and the version info, make some of these keys are little more terse and turn that
into a format that’s easily transmittable over HTTP. By what we have here application/www-form-urlencoded
would probably be best. Verse 5:
</p>
        <p>
          <font face="Courier New">         method=Status.set<br />
         &amp;v=1.0<br />
         &amp;session_key=929872172..<br />
         &amp;call_id=5<br />
         &amp;sig=DJbchm5gK...<br />
         &amp;format=Xml<br />
         &amp;api_key=27729912882…. 
<br />
         &amp;status=Hello,%20I’m%20good</font>
        </p>
        <p>
Oops. <a href="http://wiki.developers.facebook.com/index.php/Status.set">Facebook</a>’s
Status.set API. How did that happen? I thought that was REST?
</p>
        <p>
Now play the song backwards. The “new thing” is largely analogous to where we started
before the WS* Web Services stack and its CORBA/DCE/DCOM predecessors came around
and there are, believe it or not, good reasons for having of that additional “overhead”.
A common way to frame message content and the related control data, a common way to
express complex data structures and distinguish between data domains, a common way
to deal with addressing in multi-hop or store-and-forward messaging scenarios, an
agreed notion of sessions and message sequencing, a solid mechanism for protecting
the integrity of messages and parts of messages. This isn’t all just stupid.
</p>
        <p>
It’s well worth discussing whether messages need to be expressed as XML 1.0 text on
the wire at all times. I don’t think they need to and there are alternatives that
aren’t as heavy. JSON is fine and encodings like the .NET Binary Encoding or Fast
Infoset are viable alternatives as well. It’s also well worth discussing whether WS-Security
and the myriad of related standards that were clearly built by security geniuses for
security geniuses really need to be that complicated or whether we could all live
with a handful of simple profiles and just cut out 80% of the options and knobs and
parameters in that land. 
</p>
        <p>
I find it very sad that the discussion isn’t happening. Instead, people use the “REST”
moniker as the escape hatch to conveniently ignore any existing open standard for
tunnel-through-HTTP messaging and completely avoid the discussion. 
</p>
        <p>
It’s not only sad, it’s actually a bit frustrating. As one of the people responsible
for the protocol surface of the .NET Service Bus, I am absolutely not at liberty to
ignore what exists in the standards space. And this isn’t a mandate handed down to
me, but something I do because I believe it’s the right thing to live with the constraints
of the standards frameworks that exist. 
</p>
        <p>
When we’re sitting down and talk about a REST API, were designing a set of resources
– which may result in splitting a thing like a queue into two resources, head and
tail - and then we put RFC2616 on the table and try to be very precise in picking
the appropriate predefined HTTP method for a given semantic and how the HTTP 2xx,
3xx, 4xx, 5xx status codes map to success and error conditions. We’re also trying
to avoid inventing new ways to express things for which standards exists. There’s
a standard for how to express and manage lists with ATOM and APP and hence we use
that as a foundation. We use the designed extension points to add data to those lists
whenever necessary.
</p>
        <p>
When we’re designing a <strike>RPC</strike> SOAP API, we’re intentionally trying to
avoid inventing new protocol surface and will try to leverage as much from the existing
and standardized stack as we possibly can – at a minimum we’ll stick with established
patterns such as the Create/GetInfo/Renew/Delete patterns for endpoint factories with
renewal (which is used in several standards). I’ll add that we are – ironically -
a bit backlogged on the protocol documentation for our SOAP endpoints and have more
info on the REST endpoint in the latest SDK, but we’ll make that up in the near future.
</p>
        <p>
So - can I build “REST” (mind the quotes) protocols that are as reduced as Facebook,
Twitter, Flickr, etc? Absolutely. There wouldn’t be much new work. It’s just a matter
of how we put messages on and pluck message off the wire. It’s really mostly a matter
of formatting and we have a lot of the necessary building blocks in the shipping WCF
bits today. I would just omit a bunch of decoration as things go out and make a bunch
of assumptions on things that come in.
</p>
        <p>
I just have a sense that I’d be hung upside down from a tree by the press and the
blogging, twittering, facebooking community if I, as someone at Microsoft, wouldn’t
follow the existing open and agreed standards or at least use protocols that we’ve
published under the <a href="http://www.microsoft.com/interop/osp/default.mspx">OSP</a> and
instead just started to do my own interpretative dance - even if that looked strikingly
similar to what the folks down in the Valley are doing. At the very least, someone
would call it a rip-off.
</p>
        <p>
What do you think? What should I/we do? 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=634b72d9-e200-45de-82db-2ae4c8ef947e" />
      </body>
      <title>[Intermission] Auf der Mauer, auf der Lauer sitzt 'ne kleine Wa! - or: When REST isn't REST - or: Why and How I Care About Standards-Compliance</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,634b72d9-e200-45de-82db-2ae4c8ef947e.aspx</guid>
      <link>http://vasters.com/clemensv/2009/04/01/Intermission+Auf+Der+Mauer+Auf+Der+Lauer+Sitzt+Ne+Kleine+Wa+Or+When+REST+Isnt+REST+Or+Why+And+How+I+Care+About+StandardsCompliance.aspx</link>
      <pubDate>Wed, 01 Apr 2009 17:40:41 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;… &lt;a href="http://de.wikipedia.org/wiki/Auf_der_Mauer,_auf_der_Lauer"&gt;seht Euch
mal die Wa an, wie die Wa ta kann. Auf der Mauer auf der Lauer sitzt ‘ne kleine Wa!&lt;/a&gt;.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
It’s a German children’s song. The song starts out with “… sitzt ‘ne kleine Wanze”
(bedbug) and with each verse you leave off a letter: Wanz, Wan, Wa, W, – silence. 
&lt;/p&gt;
&lt;p&gt;
I’ll do the same here, but not with a bedbug:
&lt;/p&gt;
&lt;p&gt;
Let’s sing:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;soap:Envelope xmlns:soap=”” xmlns:wsaddr=”” xmlns:wsrm=””
xmlns:wsu=”” xmlns:app=””&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;soap:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;addr:Action&amp;gt;http://tempuri.org/1.0/Status.set&amp;lt;/addr:Action&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:Identifier&amp;gt;urn:session-id&amp;lt;/wsrm:Identifier&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:MessageNumber&amp;gt;5&amp;lt;/wsrm:MessageNumber&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsse:Security xmlns:wsse=”…”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;wsse:BinarySecurityToken ValueType="&lt;/font&gt;&lt;font face="Courier New"&gt;http://tempuri.org#CustomToken&lt;/font&gt;&lt;font face="Courier New"&gt;" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
EncodingType="...#Base64Binary" wsu:Id=" MyID "&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
FHUIORv...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/wsse:BinarySecurityToken&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:Signature&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:SignedInfo&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:CanonicalizationMethod Algorithm="&lt;/font&gt;&lt;font face="Courier New"&gt;http://www.w3.org/2001/10/xml-exc-c14n#"/&amp;gt;&lt;/font&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:SignatureMethod Algorithm="&lt;/font&gt;&lt;font face="Courier New"&gt;http://www.w3.org/2000/09/xmldsig#md5"/&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;gt;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:Reference URI="#MsgBody"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:DigestMethod&amp;nbsp; Algorithm="&lt;/font&gt;&lt;font face="Courier New"&gt;http://www.w3.org/2000/09/xmldsig#md5"/&amp;gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:DigestValue&amp;gt;LyLsF0Pi4wPU...&amp;lt;/ds:DigestValue&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/ds:Reference&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/ds:SignedInfo&amp;gt;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:SignatureValue&amp;gt;DJbchm5gK...&amp;lt;/ds:SignatureValue&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:KeyInfo&amp;gt;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;wsse:SecurityTokenReference&amp;gt;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;wsse:Reference URI="#MyID"/&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/wsse:SecurityTokenReference&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/ds:KeyInfo&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ds:Signature&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsse:Security&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:ResponseFormat&amp;gt;Xml&amp;lt;/app:ResponseFormat&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:Key wsu:Id=”AppKey”&amp;gt;27729912882….&amp;lt;/app:Key&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;soap:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;soap:Body wsu:Id=”MyId”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:status&amp;gt;Hello, I’m
good&amp;lt;/app:status&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/soap:Body&amp;gt;&lt;br&gt;
&amp;lt;/soap:Envelope&amp;gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Not a very pretty song, I’ll admit. Let’s drop a some stuff. Let’s assume that we
don’t need to tell the other party that we’re looking to give it an MD5 signature,
but let’s say that’s implied and so were the canonicalization algorithm. Let’s also
assume that the other side already knows the security token and the key. Since we
only have a single signature digest here and yield a single signature we can just
collapse to the signature value. Heck, you may not even know about what that all means.
Verse 2:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;soap:Envelope xmlns:soap=”” xmlns:wsaddr=”” xmlns:wsrm=””
xmlns:wsu=”” xmlns:app=””&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;soap:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;addr:Action&amp;gt;http://tempuri.org/1.0/Status.set&amp;lt;/addr:Action&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:Identifier&amp;gt;urn:session-id&amp;lt;/wsrm:Identifier&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsrm:MessageNumber&amp;gt;5&amp;lt;/wsrm:MessageNumber&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsrm:Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;wsse:Security xmlns:wsse=”…”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:Signature&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;ds:SignatureValue&amp;gt;DJbchm5gK...&amp;lt;/ds:SignatureValue&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ds:Signature&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/wsse:Security&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:ResponseFormat&amp;gt;Xml&amp;lt;/app:ResponseFormat&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:Key wsu:Id=”AppKey”&amp;gt;27729912882….&amp;lt;/app:Key&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;soap:Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;soap:Body wsu:Id=”MyId”&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;app:status&amp;gt;Hello, I’m
good&amp;lt;/app:status&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/soap:Body&amp;gt;&lt;br&gt;
&amp;lt;/soap:Envelope&amp;gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Better. Now let’s strip all these extra XML namespace decorations since there aren’t
any name collisions as far as I can see. We’ll also collapse the rest of the security
elements into one element since there’s no need for three levels of nesting with a
single signature. Verse 3:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;lt;Envelope&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Action&amp;gt;http://tempuri.org/1.0/Status.set&amp;lt;/Action&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Identifier&amp;gt;urn:session-id&amp;lt;/Identifier&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;MessageNumber&amp;gt;5&amp;lt;/MessageNumber&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Sequence&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SignatureValue&amp;gt;DJbchm5gK...&amp;lt;/SignatureValue&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ResponseFormat&amp;gt;Xml&amp;lt;/ResponseFormat&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Key&amp;gt;27729912882….&amp;lt;/Key&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Header&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Body&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;status&amp;gt;Hello, I’m good&amp;lt;/status&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Body&amp;gt;&lt;br&gt;
&amp;lt;/Envelope&amp;gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Much better. The whole angle-bracket stuff and the nesting seems semi-gratuitous and
repetitive here, too. Let’s make that a bit simpler. Verse 4:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Action=http://tempuri.org/1.0/Status.set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sequence-Identifier=urn:session-id&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sequence-MessageNumber=5&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SignatureValue=DJbchm5gK...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResponseFormat=Xml&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Key=27729912882…. 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status=Hello, I’m good&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Much, much better. Now let’s get rid of that weird URI up there and split up the action
and the version info, make some of these keys are little more terse and turn that
into a format that’s easily transmittable over HTTP. By what we have here application/www-form-urlencoded
would probably be best. Verse 5:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; method=Status.set&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;v=1.0&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;session_key=929872172..&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;call_id=5&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;sig=DJbchm5gK...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;format=Xml&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;api_key=27729912882…. 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;status=Hello,%20I’m%20good&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Oops. &lt;a href="http://wiki.developers.facebook.com/index.php/Status.set"&gt;Facebook&lt;/a&gt;’s
Status.set API. How did that happen? I thought that was REST?
&lt;/p&gt;
&lt;p&gt;
Now play the song backwards. The “new thing” is largely analogous to where we started
before the WS* Web Services stack and its CORBA/DCE/DCOM predecessors came around
and there are, believe it or not, good reasons for having of that additional “overhead”.
A common way to frame message content and the related control data, a common way to
express complex data structures and distinguish between data domains, a common way
to deal with addressing in multi-hop or store-and-forward messaging scenarios, an
agreed notion of sessions and message sequencing, a solid mechanism for protecting
the integrity of messages and parts of messages. This isn’t all just stupid.
&lt;/p&gt;
&lt;p&gt;
It’s well worth discussing whether messages need to be expressed as XML 1.0 text on
the wire at all times. I don’t think they need to and there are alternatives that
aren’t as heavy. JSON is fine and encodings like the .NET Binary Encoding or Fast
Infoset are viable alternatives as well. It’s also well worth discussing whether WS-Security
and the myriad of related standards that were clearly built by security geniuses for
security geniuses really need to be that complicated or whether we could all live
with a handful of simple profiles and just cut out 80% of the options and knobs and
parameters in that land. 
&lt;/p&gt;
&lt;p&gt;
I find it very sad that the discussion isn’t happening. Instead, people use the “REST”
moniker as the escape hatch to conveniently ignore any existing open standard for
tunnel-through-HTTP messaging and completely avoid the discussion. 
&lt;/p&gt;
&lt;p&gt;
It’s not only sad, it’s actually a bit frustrating. As one of the people responsible
for the protocol surface of the .NET Service Bus, I am absolutely not at liberty to
ignore what exists in the standards space. And this isn’t a mandate handed down to
me, but something I do because I believe it’s the right thing to live with the constraints
of the standards frameworks that exist. 
&lt;/p&gt;
&lt;p&gt;
When we’re sitting down and talk about a REST API, were designing a set of resources
– which may result in splitting a thing like a queue into two resources, head and
tail - and then we put RFC2616 on the table and try to be very precise in picking
the appropriate predefined HTTP method for a given semantic and how the HTTP 2xx,
3xx, 4xx, 5xx status codes map to success and error conditions. We’re also trying
to avoid inventing new ways to express things for which standards exists. There’s
a standard for how to express and manage lists with ATOM and APP and hence we use
that as a foundation. We use the designed extension points to add data to those lists
whenever necessary.
&lt;/p&gt;
&lt;p&gt;
When we’re designing a &lt;strike&gt;RPC&lt;/strike&gt; SOAP API, we’re intentionally trying to
avoid inventing new protocol surface and will try to leverage as much from the existing
and standardized stack as we possibly can – at a minimum we’ll stick with established
patterns such as the Create/GetInfo/Renew/Delete patterns for endpoint factories with
renewal (which is used in several standards). I’ll add that we are – ironically -
a bit backlogged on the protocol documentation for our SOAP endpoints and have more
info on the REST endpoint in the latest SDK, but we’ll make that up in the near future.
&lt;/p&gt;
&lt;p&gt;
So - can I build “REST” (mind the quotes) protocols that are as reduced as Facebook,
Twitter, Flickr, etc? Absolutely. There wouldn’t be much new work. It’s just a matter
of how we put messages on and pluck message off the wire. It’s really mostly a matter
of formatting and we have a lot of the necessary building blocks in the shipping WCF
bits today. I would just omit a bunch of decoration as things go out and make a bunch
of assumptions on things that come in.
&lt;/p&gt;
&lt;p&gt;
I just have a sense that I’d be hung upside down from a tree by the press and the
blogging, twittering, facebooking community if I, as someone at Microsoft, wouldn’t
follow the existing open and agreed standards or at least use protocols that we’ve
published under the &lt;a href="http://www.microsoft.com/interop/osp/default.mspx"&gt;OSP&lt;/a&gt; and
instead just started to do my own interpretative dance - even if that looked strikingly
similar to what the folks down in the Valley are doing. At the very least, someone
would call it a rip-off.
&lt;/p&gt;
&lt;p&gt;
What do you think? What should I/we do? 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=634b72d9-e200-45de-82db-2ae4c8ef947e" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,634b72d9-e200-45de-82db-2ae4c8ef947e.aspx</comments>
      <category>.NET Services</category>
      <category>Architecture</category>
      <category>Azure</category>
      <category>Technology</category>
      <category>Technology/ISB</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>[Update 2010-08-25: Wade Wegner </strong>
          <a href="http://blog.wadewegner.com/2010/05/host-wcf-services-in-iis-with-service-bus-endpoints/">
            <strong>now
shows a solution on his blog</strong>
          </a>
          <strong>]</strong>
        </p>
        <p>
We’ve been getting some questions along the lines of “I am hosting a service as xyz.svc
in IIS and have changed the config to use on of the <a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#Service_Bus_Bindings">Service
Bus bindings</a>, but the service never gets called?”
</p>
        <p>
That’s right. It doesn’t. The reason for that is that we don’t yet have WAS/IIS integration
for any of the <a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#Service_Bus_Bindings">Service
Bus bindings</a> in the November 2008 CTP. Enabling the WCF WAS activation scenario
that puts the <a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#NetTcpRelayBinding">NetTcpRelayBinding</a> and
friends on par with their WCF siblings is on our work backlog for the next major milestone. 
</p>
        <p>
It’s worth considering for a moment what that integration requires. Fundamentally,
all of the Relay bindings replace the local TCP or HTTP listener with a listener that
sits up in the cloud and services then connect up to that listener to create an inbound
route for received messages. That’s similar to how local services interact with WCF’s
shared TCP listener or HTTP.SYS, but there are quite a few important differences.
First, all Relay listeners need to acquire and present an <a href="http://msdn.microsoft.com/en-us/library/dd129876.aspx">Access
Control</a> token when they start listening on the Service Bus. In contrast, the local
listener facilities are ACL’d using the local or domain account system and use the
Windows process identity to decide on whether a process may or may not listen on a
particular port and/or namespace. Second, since the actual listener is off-machine,
we need to spin up the connection as the IIS/WAS host spins up and need to make sure
that the connection is kept alive and aggressively reconnects when dropped for any
reason. That’s something you don’t really have to worry much about when the listener
sits right there on the same machine as your own service and the connection is a named
pipe. Third, the local listeners listen on a particular host address and port; the
Relay listeners listen on a leaf of a namespace tree and that namespace may be shared
amongst many listeners living on a multitude of different machines in different locations. 
Fourth,   ... well you get the picture. 
</p>
        <p>
Bottom line: Not having support for WAS activation and <em>xyz.svc</em> service endpoints
is by no means an oversight. It’s on the list.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43" />
      </body>
      <title>The Service Bus Bindings and WAS/IIS</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43.aspx</guid>
      <link>http://vasters.com/clemensv/2008/11/05/The+Service+Bus+Bindings+And+WASIIS.aspx</link>
      <pubDate>Wed, 05 Nov 2008 23:16:43 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;[Update 2010-08-25: Wade Wegner&amp;nbsp;&lt;/strong&gt;&lt;a href="http://blog.wadewegner.com/2010/05/host-wcf-services-in-iis-with-service-bus-endpoints/"&gt;&lt;strong&gt;now
shows a solution on his blog&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;]&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
We’ve been getting some questions along the lines of “I am hosting a service as xyz.svc
in IIS and have changed the config to use on of the &lt;a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#Service_Bus_Bindings"&gt;Service
Bus bindings&lt;/a&gt;, but the service never gets called?”
&lt;/p&gt;
&lt;p&gt;
That’s right. It doesn’t. The reason for that is that we don’t yet have WAS/IIS integration
for any of the &lt;a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#Service_Bus_Bindings"&gt;Service
Bus bindings&lt;/a&gt; in the November 2008 CTP. Enabling the WCF WAS activation scenario
that puts the &lt;a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx#NetTcpRelayBinding"&gt;NetTcpRelayBinding&lt;/a&gt; and
friends on par with their WCF siblings is on our work backlog for the next major milestone. 
&lt;/p&gt;
&lt;p&gt;
It’s worth considering for a moment what that integration requires. Fundamentally,
all of the Relay bindings replace the local TCP or HTTP listener with a listener that
sits up in the cloud and services then connect up to that listener to create an inbound
route for received messages. That’s similar to how local services interact with WCF’s
shared TCP listener or HTTP.SYS, but there are quite a few important differences.
First, all Relay listeners need to acquire and present an &lt;a href="http://msdn.microsoft.com/en-us/library/dd129876.aspx"&gt;Access
Control&lt;/a&gt; token when they start listening on the Service Bus. In contrast, the local
listener facilities are ACL’d using the local or domain account system and use the
Windows process identity to decide on whether a process may or may not listen on a
particular port and/or namespace. Second, since the actual listener is off-machine,
we need to spin up the connection as the IIS/WAS host spins up and need to make sure
that the connection is kept alive and aggressively reconnects when dropped for any
reason. That’s something you don’t really have to worry much about when the listener
sits right there on the same machine as your own service and the connection is a named
pipe. Third, the local listeners listen on a particular host address and port; the
Relay listeners listen on a leaf of a namespace tree and that namespace may be shared
amongst many listeners living on a multitude of different machines in different locations.&amp;nbsp;
Fourth,&amp;nbsp;&amp;nbsp; ... well you get the picture. 
&lt;/p&gt;
&lt;p&gt;
Bottom line: Not having support for WAS activation and &lt;em&gt;xyz.svc&lt;/em&gt; service endpoints
is by no means an oversight. It’s on the list.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,3cc2bb9c-9a43-4c4c-9fdb-1f7bbfcaec43.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=f7500883-e4a6-4697-ad1d-8a8829ec40d9</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,f7500883-e4a6-4697-ad1d-8a8829ec40d9.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,f7500883-e4a6-4697-ad1d-8a8829ec40d9.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=f7500883-e4a6-4697-ad1d-8a8829ec40d9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://msdn.microsoft.com/en-us/azure/netservices.aspx">MSDN Developer
Center for .NET Services</a> is the first stop to go to for technical information
on the Service Bus, the Access Control Service and the Workflow Service. 
</p>
        <p>
There quite a bit of documentation for “my” feature area, the <a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx">.NET
Service Bus</a>, including description of all the bindings and most of the object
model surface area. Since we had quite a bit of object model churn up until a few
weeks before PDC as we’ve exploded the former, singular <em>RelayBinding</em> into
two handful of WCF-aligned bindings, the reference documentation isn’t yet in the
familiar MSDN reference format and also doesn’t yet work with Visual Studio’s “F1”.
We’re obviously going to address that in the next major milestone now that the dust
is settling a bit and the programming model is already quite a bit closer to what
we want it to be for our “V1” release. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=f7500883-e4a6-4697-ad1d-8a8829ec40d9" />
      </body>
      <title>.NET Services: MSDN Developer Center</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,f7500883-e4a6-4697-ad1d-8a8829ec40d9.aspx</guid>
      <link>http://vasters.com/clemensv/2008/11/05/NET+Services+MSDN+Developer+Center.aspx</link>
      <pubDate>Wed, 05 Nov 2008 19:27:31 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://msdn.microsoft.com/en-us/azure/netservices.aspx"&gt;MSDN Developer
Center for .NET Services&lt;/a&gt; is the first stop to go to for technical information
on the Service Bus, the Access Control Service and the Workflow Service. 
&lt;/p&gt;
&lt;p&gt;
There quite a bit of documentation for “my” feature area, the &lt;a href="http://msdn.microsoft.com/en-us/library/dd129877.aspx"&gt;.NET
Service Bus&lt;/a&gt;, including description of all the bindings and most of the object
model surface area. Since we had quite a bit of object model churn up until a few
weeks before PDC as we’ve exploded the former, singular &lt;em&gt;RelayBinding&lt;/em&gt; into
two handful of WCF-aligned bindings, the reference documentation isn’t yet in the
familiar MSDN reference format and also doesn’t yet work with Visual Studio’s “F1”.
We’re obviously going to address that in the next major milestone now that the dust
is settling a bit and the programming model is already quite a bit closer to what
we want it to be for our “V1” release. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=f7500883-e4a6-4697-ad1d-8a8829ec40d9" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,f7500883-e4a6-4697-ad1d-8a8829ec40d9.aspx</comments>
      <category>.NET Services</category>
      <category>Azure</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=535b30fb-3e2c-442b-9fa2-33adb0f4acb1</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,535b30fb-3e2c-442b-9fa2-33adb0f4acb1.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,535b30fb-3e2c-442b-9fa2-33adb0f4acb1.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=535b30fb-3e2c-442b-9fa2-33adb0f4acb1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the sea of PDC 2008 announcements you may have missed the following two signficant
developments:
</p>
        <ul>
          <li>
            <a href="http://jdotnetservices.com/">.NET Services for Java</a>
          </li>
          <li>
            <a href="http://www.dotnetservicesruby.com/">.NET Services for Ruby</a>
          </li>
        </ul>
        <p>
For the past 2 months our team has worked very closely with our partners at <a href="http://www.schakra.com">Schakra</a> on
the Java SDK parts and with <a href="http://www.thoughtworks.com">ThoughtWorks</a> on
the Ruby parts. These are the first baby steps and these two SDKs cover only
a small subset of the capabilities of the .NET SDK so far. That's merely a function
of when we started with these projects and how far we've gotten with the required
protocol support; we want and we will take this a lot further over the next development
milestones. In the end, the .NET Services fabric ought not to care much what language
the senders and listeners are written in and what platform they run
on. We're building a universal services platform. We're taking Java and Ruby
very seriously and have a few more platforms on the list for which we want to
add explicit support. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=535b30fb-3e2c-442b-9fa2-33adb0f4acb1" />
      </body>
      <title>.NET Services - Two things you may not have noticed yet....</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,535b30fb-3e2c-442b-9fa2-33adb0f4acb1.aspx</guid>
      <link>http://vasters.com/clemensv/2008/11/03/NET+Services+Two+Things+You+May+Not+Have+Noticed+Yet.aspx</link>
      <pubDate>Mon, 03 Nov 2008 05:03:21 GMT</pubDate>
      <description>&lt;p&gt;
In&amp;nbsp;the sea of PDC 2008 announcements you may have missed the following two signficant
developments:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://jdotnetservices.com/"&gt;.NET Services for Java&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.dotnetservicesruby.com/"&gt;.NET Services for Ruby&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
For the past 2 months our team has worked very closely with our partners at &lt;a href="http://www.schakra.com"&gt;Schakra&lt;/a&gt;&amp;nbsp;on
the Java SDK parts and with &lt;a href="http://www.thoughtworks.com"&gt;ThoughtWorks&lt;/a&gt; on
the Ruby parts. These are&amp;nbsp;the first baby steps and these two SDKs cover only
a small subset of the capabilities of the .NET SDK so far. That's&amp;nbsp;merely a function
of when we started with these projects and how far we've gotten with the required
protocol support; we want and we will take this a lot further over the next&amp;nbsp;development
milestones. In the end, the .NET Services fabric ought not to care much what language
the senders and listeners&amp;nbsp;are written in&amp;nbsp;and what platform&amp;nbsp;they run
on. We're building a universal services platform. We're taking&amp;nbsp;Java and Ruby
very seriously and have a few more platforms on the list for which we want&amp;nbsp;to
add explicit support. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=535b30fb-3e2c-442b-9fa2-33adb0f4acb1" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,535b30fb-3e2c-442b-9fa2-33adb0f4acb1.aspx</comments>
      <category>PDC 08</category>
      <category>Azure</category>
      <category>.NET Services</category>
    </item>
  </channel>
</rss>