Download presentation
Presentation is loading. Please wait.
Published byUrsula Hines Modified over 9 years ago
1
Building Windows ® DNA Applications Today Using Information Server (IIS), Microsoft ® Transaction Server (MTS), And Microsoft Messaging Queue (MSMQ) Joe Homnick And Shervin Shakibi joe@homnick.com, shervin@homnick.com
2
Agenda What is a Windows DNA application? Designing a three-tier architecture Building business logic components Incorporating transaction services Using message queuing Scalability and performance
3
Windows DNA Application Scalable High performance/high availability High performance/high availability Fault-tolerant Handle hardware and network failures Handle hardware and network failures Extensible Modular design Modular design Integrates with existing back end Integrates with existing back end “End-to-end” application solution
4
Internet Information Server, MTS, And MSMQ Infrastructure services Scripting and component hosting Scripting and component hosting Transaction capabilities Transaction capabilities Asynchronous communication Asynchronous communication Security and administration Security and administration Structured framework that allows the development of distributed applications using Web technology Inherently a three-tier architecture Inherently a three-tier architecture
5
Three-Tier Application Presentation User interface User interface Simple data validation Simple data validation Middle tier/business logic Business rules Business rules Consolidate data from multiple sources Consolidate data from multiple sources Data services Data integrity rules Data integrity rules Not just RDBMS - e-mail, file system… Not just RDBMS - e-mail, file system…
6
Presentation Business logic Data services Internet Explorer Others Internet Information Server and ASP MTS DCOM SQL Server Oracle Microsoft Exchange MSMQ Components HTTP HTTP Three-Tier Web Architecture
7
Exploration Airlines Demonstration
8
How Do I Build A Windows DNA Application Today?
9
ExAir Ticket Submission What happens when the user hits the “Finish” button? An Active Server Page (ASP) is called using a standard HTTP request, and is passed all of the relevant order information An Active Server Page (ASP) is called using a standard HTTP request, and is passed all of the relevant order information Business Logic is performed on the server; success or failure of the ticket ordering operation is determined Business Logic is performed on the server; success or failure of the ticket ordering operation is determined Appropriate HTML is returned to client Appropriate HTML is returned to client
10
Active Server Pages ASP is server-side script embedded in html Invocation through standard HTTP requests results in no firewall problems Invocation through standard HTTP requests results in no firewall problems Can target any browser on any platform ASP runs on the server -> returns HTML ASP runs on the server -> returns HTML Multiple Scripting Languages Supported Visual Basic ® Scripting Edition, JScript ®, PERL, REXX, Python… Visual Basic ® Scripting Edition, JScript ®, PERL, REXX, Python… Automatically supports use of “Session” and “Application” metaphors
11
ExAir Business Logic ASP is the critical glue that binds the user interface on the browser with the business logic on the server ASP alone does not provide the code modularity, maintainability, and scalability that business apps require We recommend that ASP is used to call MTS-enabled COM components to perform business logic, then send back the appropriate HTML response
12
Business Logic With COM Business Logic Components in COM can be written with a variety of languages Visual Basic, C++, Java ™, Cobol, Pascal Visual Basic, C++, Java ™, Cobol, Pascal COM components provide: Encapsulation of internal details Encapsulation of internal details Modularity for code reuse Modularity for code reuse Intellectual Property Security Intellectual Property Security Can be compiled and used from ASP Can be several times faster than ASP Can be several times faster than ASP
13
Building A COM Component Visual Basic Demo
14
ExAir Business Logic How can we abstract the order processing elements of ExAir? Two fundamental actions take place Order information must be updated in local ExAir Databases Order information must be updated in local ExAir Databases Remote subcontracting firm must be informed of passenger’s food selection Remote subcontracting firm must be informed of passenger’s food selection We’ll write two COM Components
15
ExAir Business Logic ExAir.Order Calculate price of ticket; decrement user’s balance in “Accounts” database table Calculate price of ticket; decrement user’s balance in “Accounts” database table Insert record into “Orders” table Insert record into “Orders” table Subtract available seats in “Flights” table Subtract available seats in “Flights” table ExAir.Food Insert record into “FoodPref” table owned by ExAir’s food service subcontractor Insert record into “FoodPref” table owned by ExAir’s food service subcontractor
16
Public Sub BookFood( ByVal OrderID As Long, ByVal FlightID As String, ByVal FoodPref As String ) ‘ In the event of an error, jump to error handler On Error GoTo ErrorHandler Dim adoConn As New ADODB.Connection Dim adoCmd As New ADODB.Command ‘ Open ADO Database Connection adoConn.Open (”ExAirFoodContractor") adoCmd.ActiveConnection = adoConn ExAir.Food
17
adoCmd.CommandText = "INSERT into FoodPref (OrderID, FlightID, FoodType) Values (OrderID, FlightID, FoodPref)” FlightID, FoodType) Values (OrderID, FlightID, FoodPref)” ‘ Execute SQL Command adoCmd.Execute Exit Sub ErrorHandler: Err.Raise Number:=911, Source:=”ExAir.Food", Description:=Err.Description Err.Raise Number:=911, Source:=”ExAir.Food", Description:=Err.Description End Sub ExAir.Food
18
<% var objOrder = Server.CreateObject(“ExAir.Order”); var objFood = Server.CreateObject(“ExAir.Food”); orderID = objOrder.BookFlight( Session(“USER”), Request.QueryString(“Flight”), Request.QueryString(“Flight”), Request.QueryString(“Num”), Request.QueryString(“Num”), Request.QueryString(“Class”) ); Request.QueryString(“Class”) ); objFood.BookFood( orderID, Request.QueryString(“Flight”), Request.QueryString(“FoodPref”) ); Request.QueryString(“FoodPref”) );%> ExAir Submit.asp
19
Transaction Services There is a major problem with our application - what if there is a failure? How do we coordinate updates across multiple data sources from multiple vendors? How do we roll back changes? How do we resolve concurrency, deadlock, and atomicity between multiple clients and servers?
20
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp Non-Transacted Order
21
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp Non-Transacted Order
22
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp Non-Transacted Order
23
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp Non-Transacted Order
24
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp Non-Transacted Order
25
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp System failure! Non-Transacted Order
26
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp Non-Transacted Order
27
Transaction Services MTS provides required infrastructure Units of work --> single atomic entity Units of work --> single atomic entity All work commits or all work rolls back All work commits or all work rolls back Two-phase commit with remote servers SQL Server ™, Oracle, DB2, Informix, MSMQ SQL Server ™, Oracle, DB2, Informix, MSMQ Built into Internet Information Server 4.0 with Transacted ASP Link between the Web and MTS Link between the Web and MTS
28
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp Transacted Order
29
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp TX Transacted Order
30
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp TX Transacted Order
31
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp TX Transacted Order
32
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp TX Transacted Order
33
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp TX Transacted Order
34
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp System failure! TX Transacted Order
35
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp TX Transacted Order
36
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp TX Transacted Order
37
Accounts Orders Flights Food preference ExAir.Order ExAir.Food Submit.asp Transacted Order
38
On Error GoTo ErrorHandler Dim adoConn As New ADODB.Connection Dim adoCmd As New ADODB.Command Dim ctxObjectAs ObjectContext Set ctxObject = GetObjectContext adoConn.Open (" ExAirFoodContractor ") adoCmd.ActiveConnection = adoConn adoCmd.CommandText = "INSERT into FoodPref (OrderID, FlightID, FoodType) Values (OrderID, FlightID, FoodPref)” ExAir.Food (Transacted)
39
' Execute SQL Command adoCmd.Execute ' If everything worked, mark as successful and exit ctxObject.SetComplete Exit Sub ErrorHandler: ‘ If failure, abort transaction ‘ If failure, abort transaction ctxObject.SetAbort ctxObject.SetAbort Err.Raise Number:=911, Source:="ExAir.Food", Description:=Err.Description Err.Raise Number:=911, Source:="ExAir.Food", Description:=Err.Description ExAir.Food (Transacted)
40
<% var objOrder = Server.CreateObject(“ExAir.Order”); var objFood = Server.CreateObject(“ExAir.Food”); orderID = objOrder.BookFlight( Session(“USER”), Request.QueryString(“Flight”), Request.QueryString(“Flight”), Request.QueryString(“Num”), Request.QueryString(“Num”), Request.QueryString(“Class”) ); Request.QueryString(“Class”) ); objFood.BookFood ( orderID, Request.QueryString(“Flight”), Request.QueryString(“FoodPref”) ); Request.QueryString(“FoodPref”) );%> Submit.asp (Transacted)
41
<% // If the Transaction Committed, ASP will call this Event Handler function OnTransactionCommit() {Response.Clear();Response.Redirect(“Success.asp”);} // If the Transaction Aborted, ASP will call this Event Handler function OnTransactionAbort() {Response.Clear();Response.Redirect(“Failure.asp”);}%> Submit.asp (Transacted)
42
Message Queuing Notifying the remote food subcontractor is currently done using a database insert This causes several problems Network failures will cause order abort Network failures will cause order abort Latency will kill scalability Latency will kill scalability Does the subcontractor notification have to be synchronous? What about the transaction model? What about the transaction model? How can we guarantee that the food contractor will eventually be notified? How can we guarantee that the food contractor will eventually be notified?
43
Message Queuing Applications are not directly connected Communicate through queued messages Communicate through queued messages Reliable queues survive application, system, and network failures Messages will queue until network connectivity is restored Messages will queue until network connectivity is restored MSMQ can participate in MTS transactions MSMQ will guarantee that a message will be delivered (once and only once) when a transaction commits MSMQ will guarantee that a message will be delivered (once and only once) when a transaction commits
44
Message Queuing Ideal for “time-independent” work Eliminates “resource shortage” errors Eliminates “resource shortage” errors An alternative to long-lock hold times An alternative to long-lock hold times Synchronous versus Deferred Integrity Business policy needs to determine how workflow progresses Business policy needs to determine how workflow progresses What about deferred problems? Requires application-level undo of a prior committed transaction Requires application-level undo of a prior committed transaction Consider how banks handle bad checks Consider how banks handle bad checks
45
Remote SQL MSMQ Food app Browser Internet Information Server and ASP MTS SQL Server MSMQ Components Exploration Airlines
46
Browser SQL Server MSMQ Internet Information Server and ASP MTS Components Remote SQL MSMQ Food app
47
Browser SQL Server MSMQ Internet Information Server and ASP TX 1 MTS Components Remote SQL MSMQ Food app Exploration Airlines
48
Browser SQL Server MSMQ Internet Information Server and ASP TX 1 MTS Components Remote SQL MSMQ Food app
49
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP TX 1 MTS Components Remote SQL MSMQ Food app
50
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP TX 1 MTS Components Remote SQL MSMQ Food app
51
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP TX 1 MTS Components Remote SQL MSMQ Food app
52
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP MTS Components Remote SQL MSMQ Food app
53
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP MTS Components Remote SQL MSMQ Food app
54
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP MTS Components Remote SQL MSMQ Food app
55
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP MTS Components Remote SQL MSMQ Food app TX 2
56
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP MTS Components Remote SQL MSMQ Food app TX 2
57
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP MTS Components Remote SQL MSMQ Food app TX 2
58
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP TX 2 MTS Components Remote SQL MSMQ Food app
59
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP MTS Components Remote SQL MSMQ Food app
60
Exploration Airlines Browser SQL Server MSMQ Internet Information Server and ASP MTS Components Remote SQL MSMQ Food app
61
On Error GoTo ErrorHandler Dim infoSnd As New MSMQQueueInfo Dim infoRespAs New MSMQQueueInfo Dim queryAs New MSMQQuery Dim Msg As New MSMQMessage Dim qSend As MSMQQueue Dim ctxObject As ObjectContext Set ctxObject = GetObjectContext ‘ Open Destination Queue (* using explicit queue name) qinfoSend.PathName = ”FoodContractor\ExAirFoodPref" Set qSend = infoSnd.Open (MQ_SEND_ACCESS, MQ_DENY_NONE) ExAir.Food (MSMQ)
62
' Construct Message Msg.Label = “ExAir Food Order” Msg.Body = Str(OrderID) & ”;" & FlightID & “;” & FoodPref ‘ Set Encryption Msg.PrivLevel = MQMSG_PRIV_LEVEL_BODY ‘ Use Lookup Response Queue (* using DS instead of explicit name) Set qInfos = query.LookupQueue(Label := “Food Response”) qInfos.Reset Set infoResp = qInfos.Next ‘ Identify App Specific Response Queue Set Msg.ResponseQueueInfo = infoResp ExAir.Food (MSMQ)
63
‘ Send Message to Remote Queue Msg.Send qSend, MQ_MTS_TRANSACTION ‘ Close queue qSend.Close ‘ If everything succeeded, mark as successful and exit ctxObject.SetComplete Exit Sub ErrorHandler: ‘ If error occurred, abort transaction ctxObject.SetAbort ExAir.Food (MSMQ)
64
Exploration Airlines Using MSMQ
65
How Do We Know It Scales? Don’t wait until deployment to worry about scalability - by then it maybe too late! Stress test during development WebCat - utility on the Internet Information Server resource kit WebCat - utility on the Internet Information Server resource kit WebLoad - very good third party utility WebLoad - very good third party utility A Web application’s scalability is bounded by its weakest link Stress, examine, optimize…then repeat Stress, examine, optimize…then repeat
66
Call To Action Install the Windows NT ® 4.0 Option Pack Start building simple components in the language of your choosing Start building simple components in the language of your choosing Begin a pilot Windows DNA application Write killer DNA application
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.