Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

Marcel Gnoth – www.gnoth.net Einer für alle – alle für einen! E3 Verteilte Transaktionen mit.NET-Komponenten.

Ähnliche Präsentationen


Präsentation zum Thema: "Marcel Gnoth – www.gnoth.net Einer für alle – alle für einen! E3 Verteilte Transaktionen mit.NET-Komponenten."—  Präsentation transkript:

1 Marcel Gnoth – www.gnoth.net Einer für alle – alle für einen! E3 Verteilte Transaktionen mit.NET-Komponenten

2 Marcel Gnoth – www.gnoth.net Wer bin ich...? Dipl. Inf. Marcel Gnoth Entwickler, Trainer, MCSD, Autor Geschäftsanwendungen, COM, Datenbanken, Verteilte Informationssysteme www.gnoth.net aktuelle Folien und Beispiele auf der Webseite NTeam GmbH, Berlin www.nteam.de (MS Server Familie, BI, Entwicklung) Microsoft Gold Certified Partner

3 Marcel Gnoth – www.gnoth.net Inhalt Die Herausforderung Einführung Transaktionen Transaktionen mit dem SQL Server Mehrbenutzer-Zugriff auf eine Datenbank Verteilte Transaktionen mit SQL Server Transaktionen mit ADO.Net Transaktionen mit COM+ Steuerung einer COM+ Transaktion

4 Marcel Gnoth – www.gnoth.net Inhalt Eine transaktionale System.EnterpriseServices – Komponente Der Distributed Transaction Coordinator (DTC) Komponente mit verteilten Transaktionen DTC und andere Welten Schlußbemerkungen Links

5 Marcel Gnoth – www.gnoth.net Die Herausforderung Es war einmal.....

6 Marcel Gnoth – www.gnoth.net Transaktion Überall Transaktionen Unser Leben besteht aus Transaktionen Das alte Beispiel mit den zwei Bankkonten Eheschließung Beim Notar Server Hypobank Konten Konto C – 10 Konto D Server Sparkasse Konten Konto A + 10 Konto B

7 Marcel Gnoth – www.gnoth.net SQL Server MSMQOracle Die Computerwelt Verarbeitung von Geschäftsprozessen SQL-Server / Oracle / MSMQ (Message Queue) Main Frame Systeme Zusammenarbeit mit anderen IT-Systemen Dienste unter Windows Alle unter einen Hut bringen TX = Transaktion

8 Marcel Gnoth – www.gnoth.net Einführung Transaktionen

9 Marcel Gnoth – www.gnoth.net Merksatz Eine Transaktion ist eine Menge von Aktionen, die ein System von einem konsistenten Zustand zu einem anderen konsistenten Zustand transformieren. Ein konsistenter Zustand wird durch die Anwendungslogik definiert.

10 Marcel Gnoth – www.gnoth.net ACID I Atomicity (Unteilbarkeit) Alles oder nichts wenn eine Aktion fehlschlägt, dann Rollback für alle Consistency (Konsistenz) System von einem konsistenten zu einem anderen konsistenten Zustand transformieren abhängig von den Geschäftsregeln Beispiel: Einfügen in verkettete Liste Vorgänger und Nachfolger Pointer aktualisieren oder keinen

11 Marcel Gnoth – www.gnoth.net ACID II Isolation (Isolation) mehrere Transaktionen gleichzeitig jede Transaktion läuft für sich allein, als wenn sie die einzige wäre laufende Transaktionen sind für andere nicht sichtbar Serialisierbarkeit Beispiel: Durchsuchen der verketteten Liste entweder vor dem Einfügen eines Elementes oder danach

12 Marcel Gnoth – www.gnoth.net ACID II – Isolation Beispiel Transaktion A multipliziert Daten mit Faktor 2 Transaktion B addiert zu den Daten 1 zwei Werte: 0 und 10 Ergebnisse: A zuerst: 1 und 21 -> (0*2)+1 und (10*2)+1 B zuerst: 2 und 22 -> (0+1)*2 und (10+1)*2 Beides gut, aber 1 und 22 oder 2 und 21 sind schlecht!

13 Marcel Gnoth – www.gnoth.net ACID III Durability (Beständigkeit) Resultate einer bestätigten Transaktion sind dauerhaft Computer / Netzwerkausfälle

14 Marcel Gnoth – www.gnoth.net Transaktionen mit SQL-Server

15 Marcel Gnoth – www.gnoth.net Transaktionsverwaltung SQL-Server Transaktionstypen Explicit, Autocommit, Implicit Sperrvorrichtungen Isolation der Transaktionen Protokollfunktionen Rollback bei Systemfehlern

16 Marcel Gnoth – www.gnoth.net Transaktionensmodi Autocommit Standardmodus jede TSQL-Anweisung ist eine einzelne Transaktion Explicit BEGIN TRANSACTION, COMMIT, ROLLBACK Implicit SET IMPLICIT_TRANSACTIONS ON Transaktionen starten automatisch, bis COMMIT oder ROLLBACK

17 Marcel Gnoth – www.gnoth.net Beispiel Eine Transaktion mit TSQL und dem iSQLw TSQL Tx.sql

18 Marcel Gnoth – www.gnoth.net Mehrbenutzer – Zugriff Probleme mit der Parallelität

19 Marcel Gnoth – www.gnoth.net Probleme der Parallelität Viele Anwender aber parallel auf einer Datenbank zusammenhängende Aktionen eines Anwenders werden in Transaktionen zusammengefaßt Lesen, Schreiben, Löschen, Einfügen arbeiten mehrere Anwender gleichzeitig auf der Datenbank, so müssen deren Transaktionen voneinander isoliert werden. Kompromiss zwischen Isolation und Durchsatz

20 Marcel Gnoth – www.gnoth.net Lost Update Verlorene Aktualisierungen (Lost Update) zwei Anwender lesen die gleichen Daten beide ändern, der letzte gewinnt, die Änderungen des ersten werden überschrieben Begin Transaktion 1 read (Kontostand) Kontostand = Kontostand + 100 write (Kontostand) Commit Transaktion 1 Begin Transaktion 1 read (Kontostand) Kontostand = Kontostand + 100 write (Kontostand) Commit Transaktion 1 Begin Transaktion 2 read (Kontostand) Kontostand = Kontostand – 20 write (Kontostand) Commit Transaktion 2 Begin Transaktion 2 read (Kontostand) Kontostand = Kontostand – 20 write (Kontostand) Commit Transaktion 2

21 Marcel Gnoth – www.gnoth.net Dirty Read Lesen unbestätigter Daten (Dirty Read) TX A liest Daten, die TX B geändert, aber nicht bestätigt hat wenn TX B ein Rollback durchführt...... Begin Transaktion 1 Kontostand = 5000 write (Kontostand) Rollback Transaction 1 Begin Transaktion 1 Kontostand = 5000 write (Kontostand) Rollback Transaction 1 Begin Transaktion 2 read (Kontostand) Kontostand = Kontostand – 20 write (Kontostand) Commit Transaciton 2 Begin Transaktion 2 read (Kontostand) Kontostand = Kontostand – 20 write (Kontostand) Commit Transaciton 2

22 Marcel Gnoth – www.gnoth.net Nonrepeatable Reads Nicht wiederholbarer Lesevorgang (Nonrepeatable Reads) eine Transaktion liest eine Zeile zweimal und erhält unterschiedliche Daten Zeile wurde von anderer TX aktualisiert oder gelöscht mindestens zwei Lesevorgänge Fremd TX hat COMMIT durchgeführt

23 Marcel Gnoth – www.gnoth.net Nonrepeatable Reads Begin Transaktion 1 read (Kontostand)...... Begin Transaktion 1 read (Kontostand)...... Begin Transaktion 2 read (Kontostand) Kontostand = Kontostand – 20 write (Kontostand) Commit Transaktion 2 Begin Transaktion 2 read (Kontostand) Kontostand = Kontostand – 20 write (Kontostand) Commit Transaktion 2

24 Marcel Gnoth – www.gnoth.net Phantoms Lesen eines Phantoms (Phantoms) TX A erhält Datensätze, die einem Kriterium entsprechen (WHERE-Klausel) TX B ändert einen Datensatz oder fügt einen hinzu TX A erhält beim erneuten Abfragen eine andere Menge von Datensätzen

25 Marcel Gnoth – www.gnoth.net Phantoms Begin Transaktion 1 Select * From Konto Where Kontostand > 100 Select * From Konto Where Kontostand > 100...... Begin Transaktion 1 Select * From Konto Where Kontostand > 100 Select * From Konto Where Kontostand > 100...... Begin Transaktion 2 read (Kontostand) Kontostand = 80 write (Kontostand) Commit Transaktion 2 Begin Transaktion 2 read (Kontostand) Kontostand = 80 write (Kontostand) Commit Transaktion 2

26 Marcel Gnoth – www.gnoth.net Sperren Isolation-Eigenschaft einer Transaktion Viele Anwender arbeiten gleichzeitig auf einer Datenbank -> Problem der Parallelität SET TRANSACTION ISOLATION LEVEL Kompromiß zwischen Isolierung und Performanz hohe Isolation -> Anwender blockieren sich gegenseitig, System wird langsam geringe Isolation -> Anwender können inkonsistente Daten erhalten

27 Marcel Gnoth – www.gnoth.net Isolationsstufen IsolationsstufeDirty ReadNicht wiederholbarer Lesevorgang Phantom Read Uncommitted Ja Read CommittedNeinJa Repeatable ReadNein Ja SerializableNein

28 Marcel Gnoth – www.gnoth.net Verteilte Transaktionen mit SQL-Server

29 Marcel Gnoth – www.gnoth.net Transaktionen zwischen mehreren Servern SQL-Server ist ein Ressourcenmanager verwaltet seine Daten über Transaktionen Transaktionen zwischen verschiedenen Ressourcenmanagern müssen koordiniert werden Distributed Transaction Coordinator (DTC) SQL-Server kann mit Transaktions-Managern zusammenarbeiten X/Open XA-Spezifikation unterstützen

30 Marcel Gnoth – www.gnoth.net Transaktionen mit TSQL Linked Server BEGIN DISTRIBUTED TRANSACTION BEGIN TRANSACTION OLE DB-Datenquelle ITransactionJoin-Schnittstelle TX wird von lokal zur verteilten TX heraufgestuft EXEC sp_addlinkedserver @server='TXTest', provider='SQLOLEDB', @datasrc='SPOCK' EXEC sp_addlinkedsrvlogin 'TXTest', 'false', NULL, 'sa', ''

31 Marcel Gnoth – www.gnoth.net XACT_ABORT automatisches Rollback bei Laufzeitfehler SET XACT_ABORT ON tritt in einer TX ein Laufzeitfehler auf, wird Rollback für die gesamte TX durchgeführt SET XACT_ABORT OFF nur die Anweisung, die den Laufzeitfehler auslöst wird zurückgesetzt, die Tx läuft weiter werden keine verschachtelten Tx unterstützt dann SET XACT_ABORT ON setzen

32 Marcel Gnoth – www.gnoth.net Code Set XACT_ABORT On BEGIN DISTRIBUTED TRANSACTION INSERT INTO [pubs].[dbo].[authors] ([au_id], [au_lname], [au_fname], [phone]) VALUES ('111-22-3333', 'Duck', 'Donald', '123456') INSERT INTO [TXTest].[pubs].[dbo].[authors] ([au_id], [au_lname], [au_fname], [phone]) VALUES ('111-22-3333', 'Duck', 'Donald', '123456') COMMIT Set XACT_ABORT On BEGIN DISTRIBUTED TRANSACTION INSERT INTO [pubs].[dbo].[authors] ([au_id], [au_lname], [au_fname], [phone]) VALUES ('111-22-3333', 'Duck', 'Donald', '123456') INSERT INTO [TXTest].[pubs].[dbo].[authors] ([au_id], [au_lname], [au_fname], [phone]) VALUES ('111-22-3333', 'Duck', 'Donald', '123456') COMMIT

33 Marcel Gnoth – www.gnoth.net DEMO Verteilte Transaktion mit iSQLw und TSQL

34 Marcel Gnoth – www.gnoth.net Transaktionen mit ADO.Net

35 Marcel Gnoth – www.gnoth.net Transaktionen mit ADO.Net SQLConnection, OLEDBConnection BeginTransaction SQLTransaction, OLEDBTransaction Commit, Rollback cnScotty = new SqlConnection("data source =.....); cmdScotty = new SqlCommand(query,cnScotty); cnScotty.Open(); Txn = cnScotty.BeginTransaction(ReadCommitted); cmdScotty.Transaction = Txn; cmdScotty.ExecuteNonQuery(); cnScotty = new SqlConnection("data source =.....); cmdScotty = new SqlCommand(query,cnScotty); cnScotty.Open(); Txn = cnScotty.BeginTransaction(ReadCommitted); cmdScotty.Transaction = Txn; cmdScotty.ExecuteNonQuery();

36 Marcel Gnoth – www.gnoth.net Transaktionen mit ADO.NET Tx – Anweisungen bedeuten Roundtrip zum Server (Begin, Commit, Rollback) keine eigene Unterstützung von verteilten Transaktionen, andere Mechanismen benutzen TSQL-Anweisungen, die sich auf Linked Server beziehen COM+ und DTC (folgt....) Local Transaction Client Server ADO.NET OLE DB Accounts Account A Account B SQL TDS

37 Marcel Gnoth – www.gnoth.net OLEDB und ODBC – APIs direkte Programmierung ohne ADO ermöglichen ebenfalls Steuerung von verteilten Transaktionen aufwendige Programmierung nur in Sonderfällen sinnvoll DBDBDBDB OLE DB ADO Clien t

38 Marcel Gnoth – www.gnoth.net COM+ Überblick Theorie (nur ein wenig )

39 Marcel Gnoth – www.gnoth.net Überblick COM+ Transaktionen Ressourcen Management Just in Time Aktivierung (JIT), Objekt-pooling Synchronisation bei parallelem Zugriff auf Komponenten (Threads) Deklarative Sicherheit Loosely coupled events, Queued Components Compensating Resource Managers (CRM) ermöglicht nicht transaktionalen Ressourcen an Transaktionen teilzuhaben (Filesystem,...)

40 Marcel Gnoth – www.gnoth.net COM+ Welt und.Net die üblichen Verdächtigen..... COM and Win32 COM+ Services.NET Enterprise Services.NET Enterprise Services Common Language Runtime

41 Marcel Gnoth – www.gnoth.net Applikationstypen Bibliotheksanwendung ( ActivationOption.Library ) Komponente im Prozeßraum des Clients bessere Performance, nicht alle COM+ Dienste verfügbar Serveranwendung ( ActivationOption.Server ) Komponente in eigenem Mutterprozeß stabiler, da eigener Prozeß, mehr Möglichkeiten Dienst Client Process Dllhost.exe Process Server Application Library Application Class A Class B

42 Marcel Gnoth – www.gnoth.net Transaktionen in COM+.Net Enterprise Services

43 Marcel Gnoth – www.gnoth.net Attribute einer COM+ Komponente Transaction Disabled Tx-Attribut wird von COM+ ignoriert Not Supported Komponente wird in einem Kontext ohne Tx aktiviert Supported beteiligt sich an Tx, wenn vorhanden [Transaction(TransactionOption.Required)] Class MyTxClass : ServicedComponent {…} [Transaction(TransactionOption.Required)] Class MyTxClass : ServicedComponent {…}

44 Marcel Gnoth – www.gnoth.net Attribute einer COM+ Komponente Required Komponente muß in einem transaktionalen Kontext laufen Requires New Für die Komponente wird ein neuer transaktionaler Kontext angelegt.

45 Marcel Gnoth – www.gnoth.net Transaktions – Ströme Gruppe von COM+ Komponenten in der selben Tx -> Tx-Stream Zugriff auf Transaktion ID (unit-of-work ID) und Transaktion Objekt über Objekt Kontext Database Connections nehmen automatisch teil Root Sub2 Root Client Sub1 Transaction Stream Root = Required oder Requires New Sub1 und Sub2 = Required oder Supported

46 Marcel Gnoth – www.gnoth.net Das Ergebnis einer Transaktion Ergebnis der Transaktion und Lebensdauer der Komponente Pro Objektkontext: Consistent- und Done Flag Pro Transaktion: Abort Flag Root Transaction Stream Root Client Sub1 Sub2 Done Consistent Done Consistent Done Consistent Abort

47 Marcel Gnoth – www.gnoth.net Done und Consistent - Flags Done False wenn Objekt in Kontext Aktiviert wird Wenn am Ende des Methodenaufrufs Flag = True, dann wird Objekt deaktiviert -> Objekt wird nicht mehr benötigt Consistent (Happy-Flag) wenn alle Komponenten Consistent-Flag = True, dann kann Commit für die Tx durchgeführt werden

48 Marcel Gnoth – www.gnoth.net Abort Flag Abort (Doomed-Flag) gilt für die gesamte Tx initialisiert mit False wenn True, dann muß Abort für die Tx durchgeführt werden wenn True, dann kann es nicht mehr auf False zurückgesetzt werden

49 Marcel Gnoth – www.gnoth.net Ergebnis der Transaktion wenn Aufruf des Root-Client zum Root-Objekt zurückkehrt entscheidet COM+ über Ergebnis Wenn Abort-Flag = True -> Abort Wenn eines der Consistent-Flags = False -> Abort Wenn Abort=False, alle Consistent=True -> Commit Wenn Done-Flag = True -> Objekt deaktiviert Ist Done-Flag = False -> weitere Aufrufe in der gleichen Tx möglich. Nicht empfohlen!

50 Marcel Gnoth – www.gnoth.net Ergebnisse Consistent – Flag entscheidet über Commit einer Transaktion Done – Flag entscheidet, ob Objekt deaktiviert werden kann Objekt kommt in Pool, Object – State geht verloren Ressourcen werden freigegeben Client behält eine Objektreferenz bei erneuten Aufrufen erhält Client ein Objekt aus Pool oder ein neues

51 Marcel Gnoth – www.gnoth.net Steuerung einer COM+ Transaktion

52 Marcel Gnoth – www.gnoth.net Client gesteuerte Transaktionen Root Client steuert Transaktion COM+ TypeLibrary TransactionContext COM – Komponente CreateInstance (transaktionale COM+ Komponente) Abort und Commit ITransactionContext tx; tx = (ITransactionContext) new TransactionContext( ); MyTXClass txCl1=(MyTXClass) tx.CreateInstance("ProgID1"); MyTXClass txCl2=(MyTXClass) tx.CreateInstance("ProgID2"); txCl1.DoWork( ); txCl2.DoWork( ); tx.Commit ( ); ITransactionContext tx; tx = (ITransactionContext) new TransactionContext( ); MyTXClass txCl1=(MyTXClass) tx.CreateInstance("ProgID1"); MyTXClass txCl2=(MyTXClass) tx.CreateInstance("ProgID2"); txCl1.DoWork( ); txCl2.DoWork( ); tx.Commit ( );

53 Marcel Gnoth – www.gnoth.net Steuerung durch Komponente System.EnterpriseServices.ContextUtil, Statische Methoden: SetComplete / SetAbort EnableCommit / DisableCommit IsInTransaction = True, wenn Objekt in Transaktion läuft public void DoWork() { try { //Tu Du something ContextUtil.SetComplete(); } Catch (Exception e) {ContextUtil.SetAbort();}} public void DoWork() { try { //Tu Du something ContextUtil.SetComplete(); } Catch (Exception e) {ContextUtil.SetAbort();}}

54 Marcel Gnoth – www.gnoth.net Steuerung durch Methoden Methoden steuern das Ergebnis der Transaktion MethodeDone-FlagConsistent-Flag EnableCommitfalsetrue DisableCommitfalse SetCompletetrue SetAborttruefalse

55 Marcel Gnoth – www.gnoth.net Steuerung durch Eigenschaften Individuelles lesen und setzen der Flags DeactivateOnReturn = true Done – Flag = 1 MyTransactionVote = true Happy – Flag = 1 public void DoTxWork( ) { ContextUtil.DeactivateOnReturn = true; ContextUtil.MyTransactionVote = TransactionVote.Abort;... // use ADO.NET to work with databases ContextUtil.MyTransactionVote=TransactionVote.Commit; } public void DoTxWork( ) { ContextUtil.DeactivateOnReturn = true; ContextUtil.MyTransactionVote = TransactionVote.Abort;... // use ADO.NET to work with databases ContextUtil.MyTransactionVote=TransactionVote.Commit; }

56 Marcel Gnoth – www.gnoth.net AutoComplete – Attribut Tritt keine Exception in der Methode auf, wird automatisch SetComplete aufgerufen Bei einer Exception wird automatisch SetAbort aufgerufen Exception wird direkt an Aufrufer weitergereicht macht Code nicht lesbarer, implizites Wissen [AutoComplete(true)] public string TestAutoComplete(int i){ i = i * 3; return "Ready"; } [AutoComplete(true)] public string TestAutoComplete(int i){ i = i * 3; return "Ready"; }

57 Marcel Gnoth – www.gnoth.net Transaktions – Isolation COM+ 1.0: eine Stufe: alle Tx Serialized COM+ 1.5 WinXP: vier Stufen: ReadUncommited, ReadCommited, RepeatableRead, Serialized, (Any) Nicht alle Ressourcen – Manager unterstützen alle Stufen [Transaction(TransactionOption.RequiresNew, Isolation = TransactionIsolationLevel.ReadCommitted, Timeout = 180)] public class cEnterprise : ServicedComponent {... } [Transaction(TransactionOption.RequiresNew, Isolation = TransactionIsolationLevel.ReadCommitted, Timeout = 180)] public class cEnterprise : ServicedComponent {... }

58 Marcel Gnoth – www.gnoth.net Eine transaktionale System.EnterpriseServices Komponente Schluß mit der Theorie, ab in die Praxis

59 Marcel Gnoth – www.gnoth.net Eine transaktionale Klasse Projekt vom Typ ClassLibrary (Dll) System.EnterpriseServices Namespace referenzieren Klasse muß erben von ServicedComponent Transaktionsattribut TransactionOption.RequiresNew using System.EnterpriseServices; [Transaction(TransactionOption.RequiresNew)] public class cEnterprise : ServicedComponent { } using System.EnterpriseServices; [Transaction(TransactionOption.RequiresNew)] public class cEnterprise : ServicedComponent { }

60 Marcel Gnoth – www.gnoth.net Code [Transaction(TransactionOption.RequiresNew)] public class SQLKirk : ServicedComponent { public SQLKirk(){...} public string DoTrans(){ SqlConnection cnKirk; SqlCommand cmAuthors; string query, constr; try{ query = "Update authors set... where..."; cnKirk = new SqlConnection(constr); cmAuthors = new SqlCommand(query,cnKirk); cnKirk.Open(); cmAuthors.ExecuteNonQuery(); ContextUtil.SetComplete(); } catch (Exception exc){ ContextUtil.SetAbort(); throw exc; } return "ready";´ } } [Transaction(TransactionOption.RequiresNew)] public class SQLKirk : ServicedComponent { public SQLKirk(){...} public string DoTrans(){ SqlConnection cnKirk; SqlCommand cmAuthors; string query, constr; try{ query = "Update authors set... where..."; cnKirk = new SqlConnection(constr); cmAuthors = new SqlCommand(query,cnKirk); cnKirk.Open(); cmAuthors.ExecuteNonQuery(); ContextUtil.SetComplete(); } catch (Exception exc){ ContextUtil.SetAbort(); throw exc; } return "ready";´ } }

61 Marcel Gnoth – www.gnoth.net Kompilieren und Installieren

62 Marcel Gnoth – www.gnoth.net Attribute in AssemblyInfo.cs ApplicationName Name im COM+ Katalog ApplicationActivation Library oder Server Werden im COM+ Katalog gespeichert [assembly:ApplicationName(MyApplication)] [assembly:ApplicationActivation(ActivationOption.Server)] [assembly:ApplicationName(MyApplication)] [assembly:ApplicationActivation(ActivationOption.Server)]

63 Marcel Gnoth – www.gnoth.net Strong Name COM + Integration erfordert Strong Name Schlüsseldatei mit sn.exe erzeugen AssemblyKeyFile Attribut auf die Schlüsseldatei setzen Anwendung Kompilieren [assembly: AssemblyKeyFile("..\\..\\TXComponentDTC.snk")]

64 Marcel Gnoth – www.gnoth.net Installation In COM+ Katalog eintragen regsvcs.exe TXComponentDTC.dll Assembly als COM Komponente registrieren Eintragen in COM+ Katalog durch Reflection wird Assembly auf Attribute untersucht und der Eintrag im COM+ Katalog aktualisiert Testen

65 Marcel Gnoth – www.gnoth.net COM+ Verwaltung SnapIn für MMC: comexp.msc Konfiguration der COM+ Anwendungen und DTC

66 Marcel Gnoth – www.gnoth.net Beobachten des Transaktionsverhalten Verwaltung -> Komponentendienste -> DTC

67 Marcel Gnoth – www.gnoth.net DEMO Eine COM+ Komponente

68 Marcel Gnoth – www.gnoth.net Distributed Transaction Coordinator (DTC)

69 Marcel Gnoth – www.gnoth.net DTC Überblick Transaktionen mit mehreren Ressourcen Managern werden zu einer einzelnen logischen Transaktion zusammengefaßt Koordiniert Commit / Abort der Ressourcen Manager Transaction Processing Monitor Server A Server B Transaction DTC Connection Database #1 Database #2

70 Marcel Gnoth – www.gnoth.net DTC Koordiniert Connections zu Datenquellen Connections werden automatisch zur Tx zugefügt Achtung! Pooled Objects, Conn existiert bereits ursprünglich Teil von MS SQL Server 6.5 wird mit Windows XP installiert COM+ Transaktionen kapseln DTC Funktionalität verteilter Dienst, muß auf jedem Computer laufen, der an Tx beteiligt ist

71 Marcel Gnoth – www.gnoth.net Verteilte Tx mit DTC Distributed Transaction Client Account AAccount B Coordinating DTC TXID=1234 Server AServer B Participating DTC TXID=1234 Component A TXID=1234 Component B TXID=1234 DCOM TM Protocol Koordinierender DTC startet Tx Partizipierende DTC treten Tx bei Steuert Zwei Phasen Commit Protokoll Ressource Manager Ressource Manager

72 Marcel Gnoth – www.gnoth.net Komponente mit verteilten Transaktionen

73 Marcel Gnoth – www.gnoth.net Das Projekt Vier Klassen cEnterprise: koordiniert die anderen drei Objekte cKirk und cSpock greifen auf verschiedene DBs zu cUhura greift auf MSMQ zu

74 Marcel Gnoth – www.gnoth.net Message Queueing Transport von Nachrichten zwischen Computern

75 Marcel Gnoth – www.gnoth.net Message Queueing – Konzepte Asynchrone Abarbeitung von Aufgaben Empfänger oder Sender kann Offline sein Nachrichten werden zwischengepuffert vergleichbar mit e-mail für Computerprogramme Aktiver Austausch von Informationen zwischen Programmen / Computern Pushen von Informationen BasicPro 5/2001

76 Marcel Gnoth – www.gnoth.net Compensating Resource Manager CRM = Ressource Manager Light Datei – System oder Registry Infrastruktur im.Net Framework leichter zu entwickeln, wenn kein Ressource Manager verfügbar ist Keine kompensierenden Transaktionen erlauben kompensierende Aktionen in der gleichen Transaktion

77 Marcel Gnoth – www.gnoth.net DTC und andere Welten Zwei Fragen Gibt es für die Daten, auf die ich zugreifen möchte einen Ressourcen Manager? Nein? -> CRM Wie kann ich diesen Ressourcen Manager überreden mit dem DTC zusammenzuarbeiten?

78 Marcel Gnoth – www.gnoth.net DTC und andere Welten OLE – Transaktionsmodell um mit Ressourcenmanagern zu kommunizieren kann teilnehmen an Tx kontrolliert durch: X/Open DTP (X/Open Distributed Transaction Processing) XA konforme Transaktionverarbeitungsmonitore Encina, TopEnd, Tuxedo IBM DB/2 Transaction Internet Protocol (TIP)

79 Marcel Gnoth – www.gnoth.net DTC und Oracle Alle sagen es geht MS und Oracle zeigen verschiedene Wege Installation und Konfiguration von Client und Server sind nicht ganz einfach Registry Key, Patches, Versionen Konfiguration von Server und Client

80 Marcel Gnoth – www.gnoth.net DTC und Oracle – Oracle Oracle9i Data Provider für.Net using Oracle.DataAccess.Client; unterstützt Oracle spezifische Datentypen verteilte Transaktionen mit Oracle Services for Microsoft Transaciton Server Oracle als Ressourcen Manager in DTC Transactionen Oracle9i: Developing with Microsoft.NET http://otn.oracle.com/tech/windows/Oracle_dotnet.pdf

81 Marcel Gnoth – www.gnoth.net DTC und Oracle – Oracle ODP.NET - Sample Corner http://otn.oracle.com/sample_code/tech/windows/odpnet/content.html Handling Distributed Transactions using Microsoft Transaction Server through Oracle Data Provider for.NET (ODP.NET) http://otn.oracle.com/sample_code/tech/windows/odpnet/DistributedTransactionSample/Readme.html

82 Marcel Gnoth – www.gnoth.net Oracle Services for Microsoft Transaction Server Überblick http://otn.oracle.com/tech/windows/ora_mts/content.html Proxy zwischen Oracle – DB und DTC Oracle – Server muß nicht unter Windows laufen Oracle 8, 8i, 9i Server

83 Marcel Gnoth – www.gnoth.net DTC und Oracle – Microsoft Using Oracle with Microsoft Transaction Server and COM+, ausführliche Anleitung http://support.microsoft.com/support/complus/mtsandoracle.asp Oracle Services for MTS werden nicht benötigt Best Practices for Using Oracle and COM+ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncomser/html/complus_best.asp Using Oracle Databases with Microsoft Transaction Server (Q193893)

84 Marcel Gnoth – www.gnoth.net DTC und Oracle – Microsoft Microsoft.NET Data Provider for Oracle using System.Data.OracleClient; KB Artikel Q322343: Using.NET Framework Data Provider for Oracle to Improve.NET Application Performance

85 Marcel Gnoth – www.gnoth.net IBM DB2 IBM DB2 Driver Available for Use with MTS Knowledge Base Article - 197208 Configuring Data Sources for the Microsoft OLE DB Provider for DB2 Knowledge Base Article - 218590 Configuring Microsoft ODBC Driver for DB2 Knowledge Base Article - 216428

86 Marcel Gnoth – www.gnoth.net Schlußbemerkungen reine DB Tx sind über SQL Server schneller, müssen aber in TSQL geschrieben werden COM+1.0 Tx laufen nur im Isolationsmodus Serialized Müssen andere Ressourcenmanager eingebunden werden, dann.Net kein AutoCommit

87 Marcel Gnoth – www.gnoth.net Links Transaktionen SQL Server Onlinedokumentation Transaction Processing Monitors und DTC MSDN, Microsoft SQL Server, Technical Articles: An Overview of Transaction Processing Concepts and the MS DTC Distributed Transactions: What you need to know to stay out of trouble? http://otn.oracle.com/tech/java/architect/distributed_transactions.html

88 Marcel Gnoth – www.gnoth.net Links EnterpriseServices COM+ Integration: How.NET Enterprise Services Can Help You Build Distributed Applications http://msdn.microsoft.com/msdnmag/issues/01/10/complus/default.aspx Microsoft Official Curriculum, Course 2557A: Building COM+ Applications Using Microsoft®.NET Enterprise Services Performance Comparison: Transaction Control http://msdn.microsoft.com/library/en-us/dnbda/html/bdadotnetarch13.asp

89 Marcel Gnoth – www.gnoth.net Links COM+ Windows XP: Make your Components more robust with COM+ 1.5 Innovationes http://msdn.microsoft.com/msdnmag/issues/01/08/ComXP/default.aspx Verteilte Anwendungen mit COM+ und Microsoft Visual Basic programmieren, Ted Pattison, MSPress MSMQ Reliable Messaging with MSMQ and.NET http://msdn.microsoft.com/library/en-us/dnbda/html/bdadotnetasync2.asp

90 Marcel Gnoth – www.gnoth.net Fragen? Uff...


Herunterladen ppt "Marcel Gnoth – www.gnoth.net Einer für alle – alle für einen! E3 Verteilte Transaktionen mit.NET-Komponenten."

Ähnliche Präsentationen


Google-Anzeigen