Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Azure

Connecting in the cloud with AppFabric : Listening for messages on the bus

3/20/2011 11:37:31 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
Almost all of the magic of the Service Bus is embedded in the new WCF service bindings that are shipped in the AppFabric SDK. All of these bindings start with a protocol identifier of sb (you’re probably familiar with http and others). The binding names also almost always have the word relay in them, to indicate that you’ll be relaying messages through the Service Bus to their destination.

1. Connecting the service to the bus

Changing your application to listen for messages from the bus instead of the HTTP endpoint is easy. You need to change the binding and address information to point to the bus.

We’ve moved the configuration of the service from code to the app.config file to make these changes easier, and you can see these changes in the Service Bus sample code for this article. Two things still need to be set up. You need to configure the address and binding information, and you need to configure the service for authentication to the bus.

First, in the configuration, you need to change the address of the endpoint to your namespace on the bus. For this example, you should change it from http://localhost/processstring to sb://stringreversalinc.servicebus.windows.net/processtring. This change tells WCF to use the Service Bus relay bindings, and that the service you’re publishing should be registered in the stringreversalinc namespace.

<endpoint address=
"sb://stringreversalinc.servicebus.windows.net/processtring"
behaviorConfiguration="sharedSecretClientCredentials"
binding="netTcpRelayBinding"
contract="StringReversalLibrary.Contract.IReverseString" />

Your service also has to authenticate to the Service Bus when it starts up and registers with the bus. You use ACS to do this. In this example, you can use the simple shared secret we used . This will attach the credentials (essentially a username and password) to your request to connect to the Service Bus:

<behavior name="sharedSecretClientCredentials">
<transportClientEndpointBehavior credentialType="SharedSecret">
<clientCredentials>
<sharedSecret issuerName="owner" issuerSecret="MZuYNde3ZOzUJxVKo62kmWoFSlzEZEaKai5Fktlt3pQ=" />
</clientCredentials>
</transportClientEndpointBehavior>
</behavior>


This shared secret behavior that you attach to your service will authenticate to the bus with your issuer name and signing key automatically.

Once you make these changes, you can run the service and it’ll start up, authenticate, and start listening for messages coming from the bus. You’ll then need to perform similar actions on the client.

2. Connecting to the service

In the previous section, we looked at what you had to do to connect a service to the Service Bus. You had to change the bindings to point to the bus and update the address. You also had to add some authentication so that the bus knew you were allowed to use your namespace.

You now need to follow the same steps to change the app.config for the client. You need to change the client binding so it’s sending messages to the bus. For this example, you can name your endpoint SBRelayEndpoint, with the same address the service used.

<client>
<endpoint
name="SBRelayEndpoint"
address=
"sb://stringreversalinc.servicebus.windows.net/processtring"
binding="netTcpRelayBinding"
contract="StringReversalLibrary.Contract.IReverseString"
behaviorConfiguration="sharedSecretClientCredentials"
/>
</client>

The client is going to have to authenticate to the Service Bus as well—you can configure it to use a shared secret. Use the Maine Reversal issuer from section 7 of this article. Keep in mind that there are two endpoints: one for the ACS service, and one for the Service Bus. They don’t share issuers. You can configure the credentials by changing the behavior of the service in the app.config file:

<behavior name="sharedSecretClientCredentials">
<transportClientEndpointBehavior credentialType="SharedSecret">
<clientCredentials>
<sharedSecret issuerName=" MaineReversal" issuerSecret=" ltSsoI5l+8DzLSmvsVOhOmflAsKHBYrGeCR8KtCI1eE=" />
</clientCredentials>
</transportClientEndpointBehavior>
</behavior>


Now the client can call your service from anywhere and always be able to connect to it. This makes it easy to provision new customers. In the old, direct method, you had to reconfigure the firewalls to let the new customer through. Now you can point them to the Service Bus address and give them the credentials they’ll need.

The binding we used in this example is based on TCP, which is one of the fastest bindings you can use in WCF. It adds the relay capabilities to allow us to message through the bus instead of directly. There are other bindings available that support using the relay.

Now that we’ve covered what AppFabric can do today, let’s consider what its future might hold.

Other -----------------
- Connecting in the cloud with AppFabric : Connecting with the Service Bus
- Example: A return to our string-reversing service (part 4) - Configuring the ACS namespace
- Example: A return to our string-reversing service (part 3) - Sending a token as a client & Attaching the token
- Example: A return to our string-reversing service (part 2) - Accepting tokens from ACS & Checking the token
- Example: A return to our string-reversing service (part 1) - Putting ACS in place & Reviewing the string-reversal service
- Connecting in the cloud with AppFabric : Controlling access with ACS
- Joining dynamic and infrequently changing data together
- Enterprise Service Bus with BizTalk Server and Windows Azure : Mapping the Microsoft Platform to the Enterprise Service Bus Pattern
- Enterprise Service Bus with BizTalk Server and Windows Azure : Governance Considerations
- Enterprise Service Bus with BizTalk Server and Windows Azure : Cloud-Enabling the ESB with Windows Azure
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server