Top Banner
.NET Enterprise .NET Enterprise Services Services and their and their Implementation Implementation Presented By: Presented By: KASHIF ALEEM KASHIF ALEEM SP10-MS-0016 SP10-MS-0016
17
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: .Net Enterprise Services and their Implementations

.NET Enterprise Services.NET Enterprise Servicesand their Implementationand their Implementation

Presented By:Presented By:

KASHIF ALEEMKASHIF ALEEMSP10-MS-0016SP10-MS-0016

Page 2: .Net Enterprise Services and their Implementations

Enterprise ServicesEnterprise Services

Provides support for Provides support for Distributed TransactionsDistributed Transactions SecuritySecurity Object PoolingObject Pooling Just in time activationJust in time activation Queued ComponentsQueued Components Loosely Coupled EventsLoosely Coupled Events Server Application Process ModelServer Application Process Model

Page 3: .Net Enterprise Services and their Implementations

Enterprise ServicesEnterprise Services

The .NET Enterprise Services are today a The .NET Enterprise Services are today a wrapper around the COM+ Servicewrapper around the COM+ Service Are a strategic part of .NETAre a strategic part of .NET

In .NET, those types are know under the In .NET, those types are know under the namename .NET Enterprise Services.NET Enterprise Services

Page 4: .Net Enterprise Services and their Implementations

Transaction Service

Transaction is a unit of work in which a series of operations occur.

COM+ uses programmatic transactions to ensure that resources are not permanently updated unless all operations within the transaction complete successfully.

Page 5: .Net Enterprise Services and their Implementations

Transaction Service (Example)

Page 6: .Net Enterprise Services and their Implementations

Transaction Service (Example)

<TransactionAttribute(TransactionOption.Required)> _Public Class TransferService Inherits ServicedComponent

Public Function transfer(ByVal ConnString1 As String, _ ByVal ConnString2 As String, _ ByVal Account1 As String, ByVal Account2 As String, _ ByVal AmountToTransfer As Integer) As Boolean

Dim RetValue As Boolean Dim objCredit As New BankOne Dim objCharge As New BankTwo

Try objCredit.credit(ConnString2, Account2, AmountToTransfer) objCharge.charge(ConnString1, Account1, AmountToTransfer) RetValue = True ContextUtil.SetComplete()

Catch exc As Exception ContextUtil.SetAbort() . . . End TryEnd Function

End Class

Page 7: .Net Enterprise Services and their Implementations

Transaction Service (Example)<TransactionAttribute(TransactionOption.Required)> _Public Class BankOne Inherits ServicedComponent

Public Sub charge(ByVal ConnString As String, _ ByVal Account As String, ByVal AmountToCharge As Integer)

Dim strSQL As String strSQL = "UPDATE Accounts SET … WHERE Description = '" & Account & "'“

Dim RowsUpdated As Integer Dim cnn As New SqlConnection(ConnString) Dim cmd As New SqlCommand(strSQL, cnn)

Try cnn.Open() RowsUpdated = cmd.ExecuteNonQuery()

If RowsUpdated = 1 Then ContextUtil.SetComplete() Exit Sub Else ' UPDATE failed ContextUtil.SetAbort() Throw New Exception("Invalid account or insufficient money.") End If

Catch exc As Exception ContextUtil.SetAbort() . . . End Try End SubEnd Class

Page 8: .Net Enterprise Services and their Implementations

Transaction Service (Example)<TransactionAttribute(TransactionOption.Required)> _Public Class BankTwo Inherits ServicedComponent

Public Sub credit(ByVal ConnString As String, _ ByVal Account As String, ByVal AmountToCredit As Integer) Dim strSQL As String strSQL = "UPDATE Accounts SET … WHERE Description = '" & Account & "'"

Dim RowsUpdated As Integer ' Number of modified rows Dim cnn As New SqlConnection(ConnString) Dim cmd As New SqlCommand(strSQL, cnn) Try cnn.Open() RowsUpdated = cmd.ExecuteNonQuery() If RowsUpdated = 1 Then ContextUtil.SetComplete() Exit Sub Else ' UPDATE failed ContextUtil.SetAbort() Throw New Exception("Invalid account.") End If Catch exc As Exception ContextUtil.SetAbort() . . . End Try End SubEnd Class

Page 9: .Net Enterprise Services and their Implementations

Transaction Service (Example)

Page 10: .Net Enterprise Services and their Implementations

Queued Components

Queued components provide for an easy implementation of asynchronous (as well as disconnected) method calls, where the client does not have to wait until the method call finishes. The Queued component architecture in COM+ internally uses the MSMQ queues to deliver the messages (method calls) to a COM+ component. The transmitted message is stored in the queue and attempted for delivery when the receiving component’s machine becomes available.

Page 11: .Net Enterprise Services and their Implementations

Queued Components (Cont’d.)

Client

QC Recorder (COM component)

MSMQ Queue

MSMQ Queue

MSMQ Queue

Queued ComponentListener

Queued ComponentPlayer (COM comp.)

COM Object

Server

Page 12: .Net Enterprise Services and their Implementations

MSMQ Configuration

Installation through Add/Remove Windows Components

Page 13: .Net Enterprise Services and their Implementations

MSMQ Configuration (Cont’d)

Configuring Queues

Page 14: .Net Enterprise Services and their Implementations

Imports System.Messaging

. . .Private Sub Send() Dim myQueue As MessageQueue

Try

' connect to the queue and send the message myQueue = New MessageQueue(".\private$\DevXTestQueue”) myQueue.Send("Test Message”)

Catch ex As Exception MessageBox.Show("Exception was thrown: " & ex.Source & ": " &

ex.Message) End Try End Sub

Queued Components (Implementation)

Page 15: .Net Enterprise Services and their Implementations

Queued Components (Implementation)

Page 16: .Net Enterprise Services and their Implementations

Queued Components (Implementation)

Page 17: .Net Enterprise Services and their Implementations