net enterprise services and their implementations
TRANSCRIPT
.NET Enterprise Services.NET Enterprise Servicesand their Implementationand their Implementation
Presented By:Presented By:
KASHIF ALEEMKASHIF ALEEMSP10-MS-0016SP10-MS-0016
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
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
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.
Transaction Service (Example)
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
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
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
Transaction Service (Example)
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.
Queued Components (Cont’d.)
Client
QC Recorder (COM component)
MSMQ Queue
MSMQ Queue
MSMQ Queue
Queued ComponentListener
Queued ComponentPlayer (COM comp.)
COM Object
Server
MSMQ Configuration
Installation through Add/Remove Windows Components
MSMQ Configuration (Cont’d)
Configuring Queues
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)
Queued Components (Implementation)
Queued Components (Implementation)