NetTalk Central

Author Topic: Webserver - Make sure of local data  (Read 4671 times)

Andjane

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Webserver - Make sure of local data
« on: October 21, 2013, 06:57:57 AM »
I have a netwebpage that receives soap posts .I use Xfiles which loads a local queue. This Queue that i have made,  i ticked static and threaded.
So that should make it unique for that session on not ?

Just want to confirm if this is correct

Thanks in advance

Andreas

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Webserver - Make sure of local data
« Reply #1 on: October 21, 2013, 08:47:47 AM »
Threaded queues, variables, etc will only work in a NetTalk server for duration of the transaction, not the duration of the session. Unless you can load, process, free the queue in a single transaction (likely in a procedure), then you should not use a queue. A session does not use the same thread, but multiple threads and the thread is terminated after each transaction along with the local threaded variables. Thus queues are replaced with files. Copy your records to a file or clarion in-memory table with the either a table  field name  or the file name containing the session id. Then when processing  transactions for each session retrieve the desired records from the file that have the same session id. Remember after the terminating the session to remove the session's records from the common file or entire file, if a new file as created for each session.

I hope that helps.
Rob

Andjane

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Webserver - Make sure of local data
« Reply #2 on: October 21, 2013, 12:10:22 PM »
Hi Rob

Thanks for the input, much appreciated.
I meant transaction seeing this a session with only one transaction. The servers receives the post request, processes it and returns the result and that's it. I do not need the local variables anymore.
So as far as Nettalk webserver page is concerned is does not matter if you specify the storage class of the local variable or not. Is that correct ?

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Webserver - Make sure of local data
« Reply #3 on: October 21, 2013, 12:56:06 PM »
Hi Andreas,
I have not made a Soap server, but what I know from Nettalk web server is that each session will have multiple threads both concurrently and sequentially, thus you cannot use a threaded variables to store session related information.  Use nettalk session variables to retain session related variables and use files instead of queues. You can use local variables and queue within your source code procedures. However as soon as the procedure returns to the web handler, consider the thread as done along with anything you had put into the threaded variables. So there is no sense using static local threaded variables.

I hope this helps,
Rob
« Last Edit: October 21, 2013, 01:05:14 PM by Rob Kolanko »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Webserver - Make sure of local data
« Reply #4 on: October 21, 2013, 09:45:11 PM »
Hi Andreas,

Rob is generally right - for multi-transaction events you can't use local variables, and in the case of the Web pages things you might think are single transaction are indeed multi-transaction.

However I'm guessing your SOAP service is using the NetWebPage template to handle the request. This is indeed likely to be a single transaction - ie the client makes a request, and you serve a single response. In effect everything is contained in the NetWebPage, and it runs from start to finish, so in this circumstance using local variables in the procedure is ok.

However,
>>I use Xfiles which loads a local queue. This Queue that i have made,  i ticked static and threaded.

Threaded has no meaning on a local variable. In clarion all local variables are local to the procedure instance. Unless of course you add Static.
Static means that the variable is no longer local, but global. It can only be accessed from this procedure, but in other respects it is Global. Since you have Threaded on it'll be unique on each thread though.

In this context I would recommend leaving off both the Static and Thread attributes. Neither is actually adding any benefit to your code, and _may_ be causing a memory leak (although I've not tested this, and my guess is it's not.)

Cheers
Bruce


Andjane

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Webserver - Make sure of local data
« Reply #5 on: October 21, 2013, 10:03:15 PM »
Hi Bruce

Thanks for your reply. Yes indeed the Netwebpage handles only one request.
Is it the right way to use a netwebpage to handle a soap request ? Or what is the best suggested way to do it with nettalk.
It works fine at the moment (in testing here) but i do not want to run into a brick wall once the webserver receives multiple requests for a webpage at the same time from various users.

Thanks for your input Rob And Bruce

Much appreciated

Regards

Andreas

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Webserver - Make sure of local data
« Reply #6 on: October 22, 2013, 01:08:33 AM »
>> Is it the right way to use a netwebpage to handle a soap request ?

yes. (at least for now. there's a _slight_ possibility that will change with NT8, but the NetWebPage will still be supported - and it's the best way to do it in Nt7 and earlier.)

>> once the webserver receives multiple requests for a webpage at the same time from various users.

This is not a problem. Each incoming request will be processed on a different thread, with a different "instance" of the NetWebPage. So they are completely isolated from each other in that sense - and local variables are indeed "local".

cheers
Bruce