As far as I can tell, there is no way in a Web service, per se, to have
a truly shared object or resource such as a file...one that I can manage
multiple updates on with a mutex for both reading and writing.
Therefore, I think I should use a Remoted service that manages calls to
the file, with a mutex. I would then call the Remoted service from the
web service calls.
Thoughts? 9 2090
John,
I don't know if this is the best thing to do. Considering the potential
volume for accessing this, a mutex would be a performance killer.
If this is not an issue, then I don't see why you can't use a mutex in a
web service. You just should make sure that you use a named mutex? I mean,
what else would stop you from using that?
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"John Bailo" <ja*****@earthlink.net> wrote in message
news:2v*************@uni-berlin.de... As far as I can tell, there is no way in a Web service, per se, to have a truly shared object or resource such as a file...one that I can manage multiple updates on with a mutex for both reading and writing.
Therefore, I think I should use a Remoted service that manages calls to the file, with a mutex. I would then call the Remoted service from the web service calls.
Thoughts?
Nicholas Paldino [.NET/C# MVP] wrote: John,
I don't know if this is the best thing to do. Considering the potential volume for accessing this, a mutex would be a performance killer.
If this is not an issue, then I don't see why you can't use a mutex in a web service. You just should make sure that you use a named mutex? I mean, what else would stop you from using that?
I understand how to set up a mutex on a file, but how do I create say a
global object, such as file, that all instances of the web service can
access without collisions ?
John,
You would create a static property in that case. As long as they are in
the same app domain (and they should be), they should all hit the same
instance.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"John Bailo" <ja*****@earthlink.net> wrote in message
news:2v*************@uni-berlin.de... Nicholas Paldino [.NET/C# MVP] wrote: John,
I don't know if this is the best thing to do. Considering the potential volume for accessing this, a mutex would be a performance killer.
If this is not an issue, then I don't see why you can't use a mutex in a web service. You just should make sure that you use a named mutex? I mean, what else would stop you from using that?
I understand how to set up a mutex on a file, but how do I create say a global object, such as file, that all instances of the web service can access without collisions ?
Nicholas Paldino [.NET/C# MVP] wrote: John,
You would create a static property in that case. As long as they are in the same app domain (and they should be), they should all hit the same instance.
Sweet.
So I could define a file object as a static property of the web service
class.
Then I could restict access to it with a named mutex ( would the mutex
be a static property as well ? ) so that multiple calls to the shared
resource would be managed.
Right ?
Nicholas Paldino [.NET/C# MVP] wrote: John,
You would create a static property in that case. As long as they are in the same app domain (and they should be), they should all hit the same instance.
Are you saying that all clients access the same instance of a web
service -- and its associated methods ?
I thought that each call to a web service or web method instantiated a
new copy of the class ...
As you said, every call to a web service is made on its own instance of the
WebService class. But Nicholas has recommended you use a static field, which
is shared by all instances of the web service. So, you would just create a
static instance and use lock() to ensure thread-safe access to it.
Ken
"John Bailo" <ja*****@earthlink.net> wrote in message
news:2v*************@uni-berlin.de... Nicholas Paldino [.NET/C# MVP] wrote: John,
You would create a static property in that case. As long as they
are in the same app domain (and they should be), they should all hit the same instance.
Are you saying that all clients access the same instance of a web service -- and its associated methods ?
I thought that each call to a web service or web method instantiated a new copy of the class ...
Thanks to both you guys, especially Nick.
Here is my code. I ran it with 3 clients calling the service in a loop
posting 1000 records each.
Before I put the .WriteLine method inside the mutex it would skip lines
or else write two numbers next to each other. Before I put the
increment of Register in the mutex it would skip or update to the same
number 2 or 3 times. With both inside the Mutex, it seems to work ok,
but I am going to load test further...
public class Service1 : System.Web.Services.WebService
{
public static int Register=5;
public static StreamWriter sw;
public static Mutex mut = new Mutex();
public Service1()
{
InitializeComponent();
}
[WebMethod]
public int Add1()
{
mut.WaitOne();
Register++;
sw.WriteLine(Register);
mut.ReleaseMutex();
return Register;
}
[WebMethod]
public void closeLog()
{
sw.Close();
}
[WebMethod]
public void openLog()
{
sw = new
StreamWriter("C:\\shareadd\\record.txt");
sw.AutoFlush=true;
}
}
Ken Kolda wrote: As you said, every call to a web service is made on its own instance of the WebService class. But Nicholas has recommended you use a static field, which is shared by all instances of the web service. So, you would just create a static instance and use lock() to ensure thread-safe access to it.
Ken "John Bailo" <ja*****@earthlink.net> wrote in message news:2v*************@uni-berlin.de...
Nicholas Paldino [.NET/C# MVP] wrote:
John,
You would create a static property in that case. As long as they are in the same app domain (and they should be), they should all hit the same instance.
Are you saying that all clients access the same instance of a web service -- and its associated methods ?
I thought that each call to a web service or web method instantiated a new copy of the class ...
Why don't you consider using MSMQ to let each client post it's records to a
queue,where asynchronously you can pick up them up and write them to a file
without the need to lock each client waiting for the Mutex. Sure this will
scale much better than a solution built around a global locking primitive.
Willy.
"John Bailo" <ja*****@earthlink.net> wrote in message
news:2v*************@uni-berlin.de... Thanks to both you guys, especially Nick.
Here is my code. I ran it with 3 clients calling the service in a loop posting 1000 records each.
Before I put the .WriteLine method inside the mutex it would skip lines or else write two numbers next to each other. Before I put the increment of Register in the mutex it would skip or update to the same number 2 or 3 times. With both inside the Mutex, it seems to work ok, but I am going to load test further...
public class Service1 : System.Web.Services.WebService {
public static int Register=5; public static StreamWriter sw; public static Mutex mut = new Mutex();
public Service1() { InitializeComponent(); }
[WebMethod] public int Add1() { mut.WaitOne(); Register++; sw.WriteLine(Register); mut.ReleaseMutex(); return Register; }
[WebMethod] public void closeLog() { sw.Close(); }
[WebMethod] public void openLog() { sw = new StreamWriter("C:\\shareadd\\record.txt"); sw.AutoFlush=true; } }
Ken Kolda wrote: As you said, every call to a web service is made on its own instance of the WebService class. But Nicholas has recommended you use a static field, which is shared by all instances of the web service. So, you would just create a static instance and use lock() to ensure thread-safe access to it.
Ken "John Bailo" <ja*****@earthlink.net> wrote in message news:2v*************@uni-berlin.de...
Nicholas Paldino [.NET/C# MVP] wrote:
John,
You would create a static property in that case. As long as they
are in
the same app domain (and they should be), they should all hit the same instance. Are you saying that all clients access the same instance of a web service -- and its associated methods ?
I thought that each call to a web service or web method instantiated a new copy of the class ...
Willy Denoyette [MVP] wrote:
You know that's a good idea. In fact, I've already proposed another along
similiar lines for building a SOAP/XML Document databse web service.
In that case I would use SOAP messages, sent as email attachments rather
than via HTTP. I would set up an smtp listener and mail queue. Then I
would pull the email messages off the queue and extract the SOAP
attachment, and then finally, it to an XPath method which would retrieve or
modify the data within an XML document.
Instead of having a WSDL, I would create an email autoresponder that would
send the schema to the client as a SOAP attachment.
In this instance, I was simply trying to build a logging method for my web
service to write trace information to a log file and to capture Exceptions
thrown in my try/catch blocks. Why don't you consider using MSMQ to let each client post it's records to a queue,where asynchronously you can pick up them up and write them to a file without the need to lock each client waiting for the Mutex. Sure this will scale much better than a solution built around a global locking primitive.
Willy.
"John Bailo" <ja*****@earthlink.net> wrote in message news:2v*************@uni-berlin.de... Thanks to both you guys, especially Nick.
Here is my code. I ran it with 3 clients calling the service in a loop posting 1000 records each.
Before I put the .WriteLine method inside the mutex it would skip lines or else write two numbers next to each other. Before I put the increment of Register in the mutex it would skip or update to the same number 2 or 3 times. With both inside the Mutex, it seems to work ok, but I am going to load test further...
public class Service1 : System.Web.Services.WebService {
public static int Register=5; public static StreamWriter sw; public static Mutex mut = new Mutex();
public Service1() { InitializeComponent(); }
[WebMethod] public int Add1() { mut.WaitOne(); Register++; sw.WriteLine(Register); mut.ReleaseMutex(); return Register; }
[WebMethod] public void closeLog() { sw.Close(); }
[WebMethod] public void openLog() { sw = new StreamWriter("C:\\shareadd\\record.txt"); sw.AutoFlush=true; } }
Ken Kolda wrote: As you said, every call to a web service is made on its own instance of the WebService class. But Nicholas has recommended you use a static field, which is shared by all instances of the web service. So, you would just create a static instance and use lock() to ensure thread-safe access to it.
Ken "John Bailo" <ja*****@earthlink.net> wrote in message news:2v*************@uni-berlin.de...
Nicholas Paldino [.NET/C# MVP] wrote:
>John, > > You would create a static property in that case. As long as they
are in
>the same app domain (and they should be), they should all hit the same >instance. > >
Are you saying that all clients access the same instance of a web service -- and its associated methods ?
I thought that each call to a web service or web method instantiated a new copy of the class ...
-- http://www.texeme.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bettervssremoting |
last post by:
To view the full article, please visit
http://www.BetterVssRemoting.com
Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere
and VSS Remoting
This article makes a detailed...
|
by: Michael Culley |
last post by:
In vb6 it was possible to create an exe as an activeX exe and communicate
between 2 apps. Now we have remoting which requires opening a tcp port to
listen on, which seems kinda crappy cause another...
|
by: Patty O'Dors |
last post by:
Hi
I posted a similar question like this to a reply to another thread but it
wasn't really relevant to that thread and I don't think anybody read it so
I'm posting a new one.
I'm trying to...
|
by: Uchiha Jax |
last post by:
Hello everyone,
I am a plenty silly person who is trying to
learn .NET remoting through trial and error (all articles I read are going
over my head at the moment (mostly) so I thought i'd give...
|
by: Joe |
last post by:
Question
1.) Since xml web service interface can be obtained directly by wsdl, but
..net remoting need to have the dll (interface) and then take reference to the
solution, right?
2.) remoting...
|
by: AMDRIT |
last post by:
Hello folks,
I appologize for the cross post, but I really need an answer on this:
I do not think that I am seeing the whole picture here. I would like to
create a windows service and a...
|
by: shaziya |
last post by:
Hi there,
I have created a remotig obj(dll) derived from MarshalByRefObject. I
have server application, client application.
If all these server exe, client exe and remorting dll are present in...
|
by: Rich |
last post by:
Can anyone suggest a good (current) tutorial on how to do basic
remoting with C# (2005 express edition)?
|
by: Jeremiah Gowdy |
last post by:
I am interested in deploying .NET binary remoting in a few applications, and
I have learned how to do remoting via interfaces so that I don't have to
share the actual class code with the client...
|
by: William |
last post by:
Hi
I'm busy developing a .NET remoting application. Tcp remoting with a binary formatter is used. The user can specify on the client configuration whether to connect to the hosted Singleton or...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |