vb.net - WCF transaction in different threads -
a client application calling wcf-service in 1 transactionscope, in hopes of rolling entire transaction if call fails. application & service works fine if 2 clients send @ same time request wcf-service, 1 of clients gets deadlock error.
this code in client application:
using transcop new transactionscope(transactionscopeoption.required, new transactionoptions() {.isolationlevel = isolationlevel.serializable}) try dim test = leapros.rechnungenservice.rechnungeninternalwsclient.facadepdfverarbeitunginternalws.pdfverarbeitungloslegen(11928, true) transcop.complete() catch ex exception transcop.dispose() throw end try end using public shared function pdfverarbeitungloslegen(idausgeplanterechnungen integer, lettershopdrucken boolean) byte() dim client rechnunginternalwsclient = nothing try ' verbindung zum webservice initialiseren. client = new rechnunginternalwsclient("nettcpbinding_irechnunginternalws") client.open() ' verarbeitung starten dim retval = client.pdfverarbeitungloslegen(idausgeplanterechnungen:=idausgeplanterechnungen, lettershopdrucken:=lettershopdrucken) client.close() client = nothing 'pdf zurückgeben. return retval.pdf catch ex exception rechnungenutils.clientkontrolliertbeenden(client) throw end try end function
this service contract:
<servicebehavior(concurrencymode:=concurrencymode.multiple, instancecontextmode:=instancecontextmode.percall, usesynchronizationcontext:=true, transactionisolationlevel:=system.transactions.isolationlevel.serializable, transactiontimeout:="00:00:30", releaseserviceinstanceontransactioncomplete:=false )> public class rechnunginternalws implements irechnunginternalws <operationbehavior(transactionscoperequired:=true, transactionautocomplete:=true)> public function pdfverarbeitungloslegen(idausgeplanterechnungen integer, lettershopdrucken boolean) rechnungpdforiginal implements irechnunginternalws.pdfverarbeitungloslegen ' end function
these configuration files:
<endpoint address="net.tcp://eldienste:555/irechnunginternalws" binding="nettcpbinding" bindingconfiguration="nettcpbinding_irechnunginternalws" contract="servicereference.irechnunginternalws" name="nettcpbinding_irechnunginternalws" /> <binding name="nettcpbinding_irechnunginternalws" closetimeout="00:01:00" opentimeout="00:01:00" receivetimeout="00:01:00" sendtimeout="00:01:00" transactionflow="true" transfermode="buffered" transactionprotocol="oletransactions" hostnamecomparisonmode="strongwildcard" listenbacklog="250" maxbufferpoolsize="524288" maxbuffersize="65536" maxconnections="250" maxreceivedmessagesize="65536"> <readerquotas maxdepth="32" maxstringcontentlength="8192" maxarraylength="2147483646" maxbytesperread="4096" maxnametablecharcount="16384" /> <reliablesession ordered="true" inactivitytimeout="00:10:00" enabled="false" /> <security mode="none"> <transport clientcredentialtype="windows" protectionlevel="encryptandsign" /> <message clientcredentialtype="windows" /> </security> </binding>
what doing wrong?
i found right configuration. service contract must configured follows:
- the concurrenymode property of servicebehavior attribute must assigned following concurrencymode.multiple value.
- the transactionautocomplete property of operationbehavior attribute must true operations. transactions can not span multiple operations.
- the releaseserviceinstanceontransactioncomplete property of servicebehavior attribute service must set false. must explicitly release service instance closing connection client.
the transactionautocompleteonsessionclose property of servicebehavior attribute service must true. transactions in threads must terminated when session ends.
<servicebehavior(concurrencymode:=concurrencymode.multiple, instancecontextmode:=instancecontextmode.persession, usesynchronizationcontext:=false,transactionisolationlevel:=system.transactions.isolationlevel.serializable, transactiontimeout:="00:00:30", releaseserviceinstanceontransactioncomplete:=false, transactionautocompleteonsessionclose:=true )> public class rechnunginternalws implements irechnunginternalws <operationbehavior(transactionscoperequired:=true, transactionautocomplete:=true)> public function pdfverarbeitungloslegen(idausgeplanterechnungen integer, lettershopdrucken boolean) rechnungpdforiginal implements irechnunginternalws.pdfverarbeitungloslegen ' end function end class
Comments
Post a Comment