Service Bus Service Bus adds a set of cloud-based, message- oriented-middleware technologies...
If you can't read please download the document
Service Bus Service Bus adds a set of cloud-based, message- oriented-middleware technologies including reliable message queuing and durable publish/subscribe
Service Bus Service Bus adds a set of cloud-based, message-
oriented-middleware technologies including reliable message queuing
and durable publish/subscribe messaging. The Service Bus provides
connectivity options for Windows Communication Foundation (WCF) and
other service endpoints including REST endpoints -- that would
otherwise be difficult or impossible to reach.
Slide 3
Service Bus Endpoints can be located behind network address
translation (NAT) boundaries, or bound to frequently- changing,
dynamically-assigned IP addresses, or both.
Slide 4
Service Bus
Slide 5
Slide 6
Slide 7
The Service Bus provides both relayed and brokered messaging
capabilities. In the relayed messaging pattern, the relay service
supports direct one-way messaging, request/response messaging, and
peer-to-peer messaging.
Slide 8
Relay Messaging
Slide 9
The on-premises service connects to the relay service through
an outbound port and creates a bidirectional socket for
communication tied to a particular rendezvous address. The client
can then communicate with the on- premises service by sending
messages to the relay service targeting the rendezvous address. The
relay service will then relay messages to the on- premises service
through the bidirectional socket already in place.
Slide 10
Relay Messaging The client does not need a direct connection to
the on- premises service nor does it need to know where it resides.
The on-premises service doesnt need any inbound ports open on the
firewall. Ultimately, a service bus that successfully operates at
Internet scope must provide a messaging fabric capable of dealing
with these connectivity challenges through a relay service in the
cloud.
Slide 11
Relay Messaging The Service Bus was designed for all
developers, regardless of platform, but was highly optimized
for.NET developers using Windows Communication Foundation (WCF),
both in terms of performance and usability. The Service Bus
provides full access to its relay service through SOAP and REST
interfaces. This makes it possible for any SOAP or REST programming
environment to integrate with it.
Slide 12
Relay Messaging You can download several SDKs for integrating
with the Service Bus that target different programming
environments. Today there are SDKs available for.NET, Java, and
even Ruby. One needs to create a service namespace with service bus
in the AMP before working with service bus. Each service namespace
acts as a container for a set of Service Bus endpoints. Each
namespace has the service bus issuer name/key which acts
credentials.
Slide 13
Relay Messaging The base URI for all endpoints is
sb://.servicebus.windows.net/
Slide 14
Service Bus These brokered messaging capabilities can be
thought of as asynchronous, or decoupled messaging features that
support publish-subscribe, temporal decoupling, and load balancing
scenarios using the Service Bus messaging fabric.
Slide 15
Service Bus Decoupled communication has many advantages; for
example, clients and servers can connect as needed and perform
their operations in an asynchronous fashion. There are three
messaging patterns that form the core of the new brokered messaging
capabilities in the Service Bus: Queues, Topics/Subscriptions,
Rules/Actions.
Slide 16
Service Bus Queues offer First In, First Out (FIFO) message
delivery to one or more competing consumers. Messages are typically
expected to be received and processed by the receivers in the
temporal order in which they were enqueued. Each message will be
received and processed by only one message consumer.
Slide 17
Service Bus A key benefit of using queues is to achieve
temporal decoupling of application components: in other words, the
producers and consumers do not need to be sending and receiving
messages at the same time, since messages are stored durably in the
queue. A related benefit is load leveling, which enables producers
and consumers to send and receive messages at different rates.
Slide 18
Service Bus Microsoft.ServiceBus Microsoft.ServiceBus.Messaging
Microsoft.ServiceBus.Description
Slide 19
Service Bus private static string ServiceNamespace=
becprincipal; private static string IssuerName=owner; private
static string IssuerKey="M0IioQTw0CFN/5JmU7eYy73093GD
2GvA4UvPNhcq4QA=";
Slide 20
Service Bus // create a shared secret //credential using a
TokenProvider TokenProvider credentials =
TokenProvider.CreateSharedSecretTokenProvi der(IssuerName,
IssuerKey); A token provider in Windows Communication Foundation
(WCF) is used for supplying credentials to the security
infrastructure. The token provider in general examines the target
and issues appropriate credentials so that the security
infrastructure can secure the message.
Slide 21
Service Bus /* Create a servicebus Uri*/ Uri
serviceUri=ServiceBusEnvironment.Create ServiceUri("sb",
ServiceNamespace, string.Empty); /* Create Create a new service
namespace management object*/ NamespaceManager namespaceClient =
new NamespaceManager(serviceUri, credentials);
Slide 22
Service Bus QueueDescription myQueue; if
(!namespaceClient.QueueExists( messagequeue")) myQueue =
namespaceClient.CreateQueue(" messagequeue "); MessagingFactory
factory = MessagingFactory.Create(serviceUri, credentials);
QueueClient myQueueClient = factory.CreateQueueClient
(messageQueue");
Slide 23
Service Bus BrokeredMessage msg = new BrokeredMessage();
msg.Properties.Add(TID,CR); msg.Properties.Add(AMT,2000);
myQueueClient.Send(msg);
Service Bus Message.Complete(); factory.Close();
myQueueClient.Close(); namespaceClient.DeleteQueue(messagequeu
e");
Slide 26
Service Bus When creating a queue or subscription client, you
can specify a receive mode: Peek-lock or Receive and delete. The
default receive mode is PeekLock.
Slide 27
Service Bus In the ReceiveAndDelete mode, the receive operation
is single-shot, that is, when the Service Bus receives the request,
it marks the message as being consumed and returns it to the
application. ReceiveAndDelete mode is the simplest model and works
best for scenarios in which the application can tolerate not
processing a message in the event of a failure.
Slide 28
Service Bus To understand this, consider a scenario in which
the consumer issues the receive request and then crashes before
processing it. Since the Service Bus marks the message as being
consumed, when the application restarts and begins consuming
messages again, it will have missed the message that was consumed
prior to the crash.
Slide 29
Service Bus In PeekLock mode, the receive operation becomes
two-stage, which makes it possible to support applications that
cannot tolerate missing messages. When the Service Bus receives the
request, it finds the next message to be consumed, locks it to
prevent other consumers from receiving it, and then returns it to
the application.
Slide 30
Service Bus After the application finishes processing the
message, it completes the second stage of the receive process by
calling Complete on the received message. When the Service Bus sees
the Complete, it will mark the message as being consumed.
Slide 31
Service Bus If the application is unable to process the message
for some reason, it can call the Abandon method on the received
message (instead of Complete ). This will cause the Service Bus to
unlock the message and make it available to be received again,
either by the same consumer or by another completing consumer.
Slide 32
Service Bus Secondly, there is a timeout associated with the
lock and if the application fails to process the message before the
lock timeout expires (for example, if the application crashes),
then Service Bus will unlock the message and make it available to
be received again.