ASP series lecture (two ten one) found routine script
Tuesday, March 03, 2009 by rain
Commercial application process often needs to have the capacity that runs script and package in clerical interior.General affairs is operation of a kind of server,Although this operation includes a lot of measure (for example,Indent, examine goods in stock, pay the bill etc) ,Also can whole returns an operation is success or failure.The user can found the ASP scenario that runs in clerical interior,If any one part of script fails,Whole routine will be stopped.
Processing of ASP general affairs is with Microsoft%26reg;Transaction Server (MTS) is a foundation.Microsoft%26reg;Transaction Server (MTS) is processing system of a general affairs,Use at development, configuration and management high-powered, can classification, the enterprise Internet that has rash club sex and process of application of Intranet server.Transaction Server is development distributed,The applied process that is based on package provided an application programming model.It also applied a program to provide a moving environment to configure and manage these.
The buy inside the function that founds routine script is in Internet Information Server and Personal Web Server.If you installed Microsoft Transaction Server,Can bale package,In order to make package moves in clerical interior.
About general affairs
The operation that general affairs is integral success or failure.Clerical processing is used at undertaking to the database reliable ground is updated.When undertaking to the database heterogeneous closes to change or update many databases at the same time making,Should assure all changing to be carried out correctly.If these change medium any,fail,The savagery that needs to restore a database to express.
If do not have MTS,You write script and package with respect to need,Dog by hand of the request change a condition,So that be in certain data restores when changing failure.Use MTS,You need the simple script you and package statement to be only " need general affairs " the consistency that lets MTS handle work.Clerical processing applies to a database to visit only;MTS cannot is opposite file system or other blame are routine of resource change undertake resumptive to operate.The database that uses program place visit must support for MTS place.At present,SQL Server of MTS support reachs agreements of any supportive XA (make by X/Open association) server.MTS will continue to expand the support of pair of other databases.
General affairs cannot span page of many ASP.If a general affairs needs to come from the object of many component,Need the operation combination that will use these targets to be in page of an ASP.For example,Assume have a package at updating payroll database with,The employee in still a component is used at updating manpower resource database is recorded.To record the new salary information of an employee,You need to write a such script,This script calls these two package in environment of a work,One at updating payroll database with,Another employee social estate that is used in database of resource of newer labor power.
Statement is routine script
In a page statement is routine when,Any script commands in this page and object move in same a clerical environment is medium.Processing of Transaction Server generates clerical detail and decision general affairs succeeds (refer) or failure (stop) .Should be statement of a certain page routine,Can be in page head adds @TRANSACTION to dictate:
%26lt;%@ TRANSACTION = Value %%26gt;
Value parameter can be following one of:
Value sense
Requires_New starts a new work.
Required starts a new work.
Supported does not start work.
Not_Supported does not start work.
@TRANSACTION instruction must be in one of one page,Will produce a mistake otherwise.In the each page that must add this statement need to move below general affairs.When script handles an end,Current general affairs announces an end namely.
Process of great majority application has a few specific operations to need clerical environment only.For example,The site of an airline may need routine script processing to buy ticket and arrangement seat only,And other and all script is beardless clerical environment can safety moves.The page that because clerical simply is used at needing work,handles can,The statement of Global.asa file that will not use a program is routine.
If general affairs is stopped,Transaction Server will restore the resource to supporting work any changing.At present,Only database server supports work completely,Because amount to occupies the data in the library to apply to the enterprise,be most crucial.The file on incorrect hard disk of Transaction Server, conversation and the change that apply the variable of the program, gather to wait undertake resumptive.However you can be like article topic place to narrate,Restore variable and aggregate script through writing clerical incident to write.In certain moment,Refer or stop a work your script is OK also and explicitly,When if keep data to the file,failing.
Refer or stop script
Because Transaction Server dogs,general affairs is handled,So it decides general affairs is complete success still is failure.Script can state explicitly through calling ObjectContext.SetAbort stop a work.For example,Be in when a general affairs receive erroneous information from a component, when violating commercial standard (for example,Account remaining sum is less than 0) or read write the blame such as the file when routine operation fails,Script stops this work with respect to need.If the page is overtime before general affairs is finished,Also must stop work.
Write clerical incident
Script itself cannot decide general affairs is successful or fail.But,Can write the event that when refer or stopping work, is called.For example,The scenario that suppose one confirms bank account,And you need the different position in the light of general affairs will different page returns an user,What can use OnTransactionCommit and OnTransactionAbort incident to write pair of users so is different answer.
%26lt;%@ TRANSACTION = Required %%26gt;
%26lt;%
'Buffer Output So That Different Pages Can Be Displayed.
Response.Buffer = True
%%26gt;
%26lt;HTML%26gt;
%26lt;BODY%26gt;
%26lt;H1%26gt;Welcome To The Online Banking Service%26lt;/H1%26gt;
%26lt;%
Set BankAction = Server.CreateObject("MyExample.BankComponent" )
BankAction.Deposit(Request("AcctNum" ) )
%%26gt;
%26lt;P%26gt;Thank You. Your Transaction Is Being Processed. %26lt;/P%26gt;
%26lt;/BODY%26gt;
%26lt;/HTML%26gt;
%26lt;%
' Display This Page If The Transaction Succeeds.
Sub OnTransactionCommit()
Response.Write %26quot;%26lt;HTML%26gt; %26quot;
Response.Write %26quot;%26lt;BODY%26gt; %26quot;
Response.Write "Thank You. Your Account Has Been Credited. Your Account Has Been Credited..
Response.Write %26quot;%26lt;/BODY%26gt; %26quot;
Response.Write %26quot;%26lt;/HTML%26gt; %26quot;
Response.Flush()
End Sub
%%26gt;
%26lt;%
' Display This Page If The Transaction Fails.
Sub OnTransactionAbort()
Response.Clear()
Response.Write %26quot;%26lt;HTML%26gt; %26quot;
Response.Write %26quot;%26lt;BODY%26gt; %26quot;
Response.Write "We Are Unable To Complete Your Transaction. Response.Write "We Are Unable To Complete Your Transaction..
Response.Write %26quot;%26lt;/BODY%26gt; %26quot;
Response.Write %26quot;%26lt;/HTML%26gt; %26quot;
Response.Flush()
End Sub
%%26gt;
Manage in MTS resource implement in register a component
To share a work,Package must be registered in MTS bag,And must be to need work by configuration.For example,If your script is,handle order through calling two component to come,Database of a newer stock,Another pay newlier database.So,These two component are about to be in same a clerical environment is medium move.If,Transaction Server assures random a component fails,So will not the database is updated.Certain component does not need work;For example,Component of Ad Rotator.
Register and configure routine component to be able to use MTS resource to manage implement.The setting is need general affairs or must need clerical property new work.Clerical component must be registered in MTS bag.In putting package in process of IIS interior wrap,And the bag that should found oneself.Normally,In answering to put all package in library of a component.The component of package library can be used by process of application of many ASP and with ASP application order process moves.Resource of use MTS manages implement the setting of Activation attribute that can found new package and will include is Library.
Also can register routine component in Server bag.The course that Server includes an independence that goes up with the server normally moves.If hope to use the security examination that is based on function group or hope,the applied course that can be attended by long-range computer visits your component,Can wrap to routine component use Server.
Should use MTS resource to manage implement,Must install Microsoft Transaction Server.
Object scope
Usually,Not be the object memory that founds from inside MTS component in ASP Application or Session object.MTS object disappears after general affairs is finished.Because Session object and Application object are,design for the object example that uses between page of different ASP,The object that when protecting existence general affairs to end with them so, is released namely.
ASP script is already the root of the general affairs of reputation,Namely initial drop.The one part that the MTS target that place of any page of routine ASP use is considered as general affairs.After general affairs is finished,The MTS target that uses in the page will disappear,Include memory among them the object in Session or Application object.After this,The attempt that calls conversational scope or boy or girl friend of applied process scope from inside another routine page will fail.
General affairs queues up
The newer likelihood that occupies a library from logarithm of a long-range server causes clerical delay because of network defer or breakdown or stop.Must refer because of all parts of general affairs,So applied process hangs the likelihood,Refer or stop a message what await long-range server,Because cannot be sent,bring about general affairs possibly also to be abandoned.
Update to what must finish at the same time,Right way is before all participator in general affairs can be referred,Stop work or suspend the work that finish.For example,The program deciding a ticket of airline should complete the bank to the client at the same time account plan joins debit and the bank to airline account plan joins credit.If one replaces the one part that attributes clerical whole,But the likelihood is later than other update,You may not hope to let what the client awaits whole newer procedure finish.For example,The itinerary allowance that airline ticket books general affairs to also may want to send food order for goods or newer client to food supplier.Although these operations also must be finished,But can a few later.
Microsoft Message Queue Server makes you can will or update one group long-range server sends in binding a routine message.Message Queue Server assures to will be sent newlier to send long-range server,Although the network is not at present usable.Your application will receive to submit an information,Can continue to handle work thereby.
...
Processing of ASP general affairs is with Microsoft%26reg;Transaction Server (MTS) is a foundation.Microsoft%26reg;Transaction Server (MTS) is processing system of a general affairs,Use at development, configuration and management high-powered, can classification, the enterprise Internet that has rash club sex and process of application of Intranet server.Transaction Server is development distributed,The applied process that is based on package provided an application programming model.It also applied a program to provide a moving environment to configure and manage these.
The buy inside the function that founds routine script is in Internet Information Server and Personal Web Server.If you installed Microsoft Transaction Server,Can bale package,In order to make package moves in clerical interior.
About general affairs
The operation that general affairs is integral success or failure.Clerical processing is used at undertaking to the database reliable ground is updated.When undertaking to the database heterogeneous closes to change or update many databases at the same time making,Should assure all changing to be carried out correctly.If these change medium any,fail,The savagery that needs to restore a database to express.
If do not have MTS,You write script and package with respect to need,Dog by hand of the request change a condition,So that be in certain data restores when changing failure.Use MTS,You need the simple script you and package statement to be only " need general affairs " the consistency that lets MTS handle work.Clerical processing applies to a database to visit only;MTS cannot is opposite file system or other blame are routine of resource change undertake resumptive to operate.The database that uses program place visit must support for MTS place.At present,SQL Server of MTS support reachs agreements of any supportive XA (make by X/Open association) server.MTS will continue to expand the support of pair of other databases.
General affairs cannot span page of many ASP.If a general affairs needs to come from the object of many component,Need the operation combination that will use these targets to be in page of an ASP.For example,Assume have a package at updating payroll database with,The employee in still a component is used at updating manpower resource database is recorded.To record the new salary information of an employee,You need to write a such script,This script calls these two package in environment of a work,One at updating payroll database with,Another employee social estate that is used in database of resource of newer labor power.
Statement is routine script
In a page statement is routine when,Any script commands in this page and object move in same a clerical environment is medium.Processing of Transaction Server generates clerical detail and decision general affairs succeeds (refer) or failure (stop) .Should be statement of a certain page routine,Can be in page head adds @TRANSACTION to dictate:
%26lt;%@ TRANSACTION = Value %%26gt;
Value parameter can be following one of:
Value sense
Requires_New starts a new work.
Required starts a new work.
Supported does not start work.
Not_Supported does not start work.
@TRANSACTION instruction must be in one of one page,Will produce a mistake otherwise.In the each page that must add this statement need to move below general affairs.When script handles an end,Current general affairs announces an end namely.
Process of great majority application has a few specific operations to need clerical environment only.For example,The site of an airline may need routine script processing to buy ticket and arrangement seat only,And other and all script is beardless clerical environment can safety moves.The page that because clerical simply is used at needing work,handles can,The statement of Global.asa file that will not use a program is routine.
If general affairs is stopped,Transaction Server will restore the resource to supporting work any changing.At present,Only database server supports work completely,Because amount to occupies the data in the library to apply to the enterprise,be most crucial.The file on incorrect hard disk of Transaction Server, conversation and the change that apply the variable of the program, gather to wait undertake resumptive.However you can be like article topic place to narrate,Restore variable and aggregate script through writing clerical incident to write.In certain moment,Refer or stop a work your script is OK also and explicitly,When if keep data to the file,failing.
Refer or stop script
Because Transaction Server dogs,general affairs is handled,So it decides general affairs is complete success still is failure.Script can state explicitly through calling ObjectContext.SetAbort stop a work.For example,Be in when a general affairs receive erroneous information from a component, when violating commercial standard (for example,Account remaining sum is less than 0) or read write the blame such as the file when routine operation fails,Script stops this work with respect to need.If the page is overtime before general affairs is finished,Also must stop work.
Write clerical incident
Script itself cannot decide general affairs is successful or fail.But,Can write the event that when refer or stopping work, is called.For example,The scenario that suppose one confirms bank account,And you need the different position in the light of general affairs will different page returns an user,What can use OnTransactionCommit and OnTransactionAbort incident to write pair of users so is different answer.
%26lt;%@ TRANSACTION = Required %%26gt;
%26lt;%
'Buffer Output So That Different Pages Can Be Displayed.
Response.Buffer = True
%%26gt;
%26lt;HTML%26gt;
%26lt;BODY%26gt;
%26lt;H1%26gt;Welcome To The Online Banking Service%26lt;/H1%26gt;
%26lt;%
Set BankAction = Server.CreateObject("MyExample.BankComponent" )
BankAction.Deposit(Request("AcctNum" ) )
%%26gt;
%26lt;P%26gt;Thank You. Your Transaction Is Being Processed. %26lt;/P%26gt;
%26lt;/BODY%26gt;
%26lt;/HTML%26gt;
%26lt;%
' Display This Page If The Transaction Succeeds.
Sub OnTransactionCommit()
Response.Write %26quot;%26lt;HTML%26gt; %26quot;
Response.Write %26quot;%26lt;BODY%26gt; %26quot;
Response.Write "Thank You. Your Account Has Been Credited. Your Account Has Been Credited..
Response.Write %26quot;%26lt;/BODY%26gt; %26quot;
Response.Write %26quot;%26lt;/HTML%26gt; %26quot;
Response.Flush()
End Sub
%%26gt;
%26lt;%
' Display This Page If The Transaction Fails.
Sub OnTransactionAbort()
Response.Clear()
Response.Write %26quot;%26lt;HTML%26gt; %26quot;
Response.Write %26quot;%26lt;BODY%26gt; %26quot;
Response.Write "We Are Unable To Complete Your Transaction. Response.Write "We Are Unable To Complete Your Transaction..
Response.Write %26quot;%26lt;/BODY%26gt; %26quot;
Response.Write %26quot;%26lt;/HTML%26gt; %26quot;
Response.Flush()
End Sub
%%26gt;
Manage in MTS resource implement in register a component
To share a work,Package must be registered in MTS bag,And must be to need work by configuration.For example,If your script is,handle order through calling two component to come,Database of a newer stock,Another pay newlier database.So,These two component are about to be in same a clerical environment is medium move.If,Transaction Server assures random a component fails,So will not the database is updated.Certain component does not need work;For example,Component of Ad Rotator.
Register and configure routine component to be able to use MTS resource to manage implement.The setting is need general affairs or must need clerical property new work.Clerical component must be registered in MTS bag.In putting package in process of IIS interior wrap,And the bag that should found oneself.Normally,In answering to put all package in library of a component.The component of package library can be used by process of application of many ASP and with ASP application order process moves.Resource of use MTS manages implement the setting of Activation attribute that can found new package and will include is Library.
Also can register routine component in Server bag.The course that Server includes an independence that goes up with the server normally moves.If hope to use the security examination that is based on function group or hope,the applied course that can be attended by long-range computer visits your component,Can wrap to routine component use Server.
Should use MTS resource to manage implement,Must install Microsoft Transaction Server.
Object scope
Usually,Not be the object memory that founds from inside MTS component in ASP Application or Session object.MTS object disappears after general affairs is finished.Because Session object and Application object are,design for the object example that uses between page of different ASP,The object that when protecting existence general affairs to end with them so, is released namely.
ASP script is already the root of the general affairs of reputation,Namely initial drop.The one part that the MTS target that place of any page of routine ASP use is considered as general affairs.After general affairs is finished,The MTS target that uses in the page will disappear,Include memory among them the object in Session or Application object.After this,The attempt that calls conversational scope or boy or girl friend of applied process scope from inside another routine page will fail.
General affairs queues up
The newer likelihood that occupies a library from logarithm of a long-range server causes clerical delay because of network defer or breakdown or stop.Must refer because of all parts of general affairs,So applied process hangs the likelihood,Refer or stop a message what await long-range server,Because cannot be sent,bring about general affairs possibly also to be abandoned.
Update to what must finish at the same time,Right way is before all participator in general affairs can be referred,Stop work or suspend the work that finish.For example,The program deciding a ticket of airline should complete the bank to the client at the same time account plan joins debit and the bank to airline account plan joins credit.If one replaces the one part that attributes clerical whole,But the likelihood is later than other update,You may not hope to let what the client awaits whole newer procedure finish.For example,The itinerary allowance that airline ticket books general affairs to also may want to send food order for goods or newer client to food supplier.Although these operations also must be finished,But can a few later.
Microsoft Message Queue Server makes you can will or update one group long-range server sends in binding a routine message.Message Queue Server assures to will be sent newlier to send long-range server,Although the network is not at present usable.Your application will receive to submit an information,Can continue to handle work thereby.
...