473,574 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Xml-Rpc + Mysql.NET = Threading problem

Hello all,

I come to you to getting help for managing multi threading and database connection.

My project use Xml-Rpc to receive messages, so each call come from a different
thread.
Incoming calls are executing SQL on a MysqlConnection .
MysqlConnection does not like when concurents calls appends.

For a fast and dirty solution, I've put a Monitor() at messages arrived.
But I would like to finally got a nicer solution.

What do you think about the architecture I should make ?

Should I create and manage a Pool of MysqlConnection and only locking when pool
is fully occuped ?

Do you know already made solutions for that case ?

Thanks a lot for you comments and ideas,
cyrille.

PS: Before I put the ugly Monitor, I got some errors like :

Exception: Connection must be valid and open. StackTrace:
at MySql.Data.MySq lClient.MySqlCo mmand.CheckStat e()
at MySql.Data.MySq lClient.MySqlCo mmand.ExecuteRe ader(CommandBeh avior behavior)
at MySql.Data.MySq lClient.MySqlCo mmand.ExecuteRe ader()

Exception: Expected prepared statement marker. StackTrace:
at MySql.Data.MySq lClient.NativeD river.Prepare(S tring sql, String[] parmNames)
at MySql.Data.MySq lClient.MySqlCo mmand.Prepare()
Feb 10 '06 #1
11 2145
what's wrong with the Monitor?

Anyway it's very typical and advised to have a connection pool which (the
pool) as a properly synchronized access and return a private connection on
demand.
In fact SqlConnection (for SqlServer), does it for you under the hood.

Otherwise you could open a new connection for each incoming message..

One thing you should NOT do is use the same connection at the same time in
different thread.

"# Cyrille37 #" <cy*******@free .fr> wrote in message
news:up******** ******@TK2MSFTN GP11.phx.gbl...
Hello all,

I come to you to getting help for managing multi threading and database
connection.

My project use Xml-Rpc to receive messages, so each call come from a
different thread.
Incoming calls are executing SQL on a MysqlConnection .
MysqlConnection does not like when concurents calls appends.

For a fast and dirty solution, I've put a Monitor() at messages arrived.
But I would like to finally got a nicer solution.

What do you think about the architecture I should make ?

Should I create and manage a Pool of MysqlConnection and only locking when
pool is fully occuped ?

Do you know already made solutions for that case ?

Thanks a lot for you comments and ideas,
cyrille.

PS: Before I put the ugly Monitor, I got some errors like :

Exception: Connection must be valid and open. StackTrace:
at MySql.Data.MySq lClient.MySqlCo mmand.CheckStat e()
at MySql.Data.MySq lClient.MySqlCo mmand.ExecuteRe ader(CommandBeh avior
behavior)
at MySql.Data.MySq lClient.MySqlCo mmand.ExecuteRe ader()

Exception: Expected prepared statement marker. StackTrace:
at MySql.Data.MySq lClient.NativeD river.Prepare(S tring sql, String[]
parmNames)
at MySql.Data.MySq lClient.MySqlCo mmand.Prepare()

Feb 11 '06 #2
Hi Lloyd,

Lloyd Dupont a écrit :
what's wrong with the Monitor?
I loos multi-threading processing of incoming messages.
Anyway it's very typical and advised to have a connection pool which (the
pool) as a properly synchronized access and return a private connectionon
demand.
In fact SqlConnection (for SqlServer), does it for you under the hood.
That's Great.
I've to find or write a connections pool for MySqlConnection ...
Perhaps someone already done it ?
Otherwise you could open a new connection for each incoming message..
I think it will be to heavy.
One thing you should NOT do is use the same connection at the same timein
different thread.
Thanks for your advise. I'll be care ;o)

Thanks a lot for your councils.
Regards,
cyrille.

"# Cyrille37 #" <cy*******@free .fr> wrote in message
news:up******** ******@TK2MSFTN GP11.phx.gbl...
Hello all,

I come to you to getting help for managing multi threading and database
connection.

My project use Xml-Rpc to receive messages, so each call come from a
different thread.
Incoming calls are executing SQL on a MysqlConnection .
MysqlConnection does not like when concurents calls appends.

For a fast and dirty solution, I've put a Monitor() at messages arrived.
But I would like to finally got a nicer solution.

What do you think about the architecture I should make ?

Should I create and manage a Pool of MysqlConnection and only locking when
pool is fully occuped ?

Do you know already made solutions for that case ?

Thanks a lot for you comments and ideas,
cyrille.

PS: Before I put the ugly Monitor, I got some errors like :

Exception: Connection must be valid and open. StackTrace:
at MySql.Data.MySq lClient.MySqlCo mmand.CheckStat e()
at MySql.Data.MySq lClient.MySqlCo mmand.ExecuteRe ader(CommandBeh avior
behavior)
at MySql.Data.MySq lClient.MySqlCo mmand.ExecuteRe ader()

Exception: Expected prepared statement marker. StackTrace:
at MySql.Data.MySq lClient.NativeD river.Prepare(S tring sql, String[]
parmNames)
at MySql.Data.MySq lClient.MySqlCo mmand.Prepare()




Feb 11 '06 #3
Lloyd Dupont a écrit :
Hi Cyrille37
what's wrong with the Monitor? I loos multi-threading processing of incoming messages.

err.... could you reword this sentence?
I don't manage to guess its meaning....


Sorry for my bad english. I use my extra ball to try again :

With Monitor() at messages arriving, I lose the advantage of multi-threading.

Is that more readable ?
;o)
I have something like that (as an attached document of this answer).
Well it was a useless peace of code as SqlConnection already use a
connection pool under the hood.
But if you replace all the SqlConnection stuff by MySqlConnection it will
suddenly start to make sense!


THANKS A LOT !!!

Ok, I'll try it this afternoon.

<;oP> I hope you've make a non buggy code </;oP>

I give you a report after tests...

Cheers,
cyrille

Feb 11 '06 #4
>>> I loos multi-threading processing of incoming messages.
err.... could you reword this sentence?
I don't manage to guess its meaning....
Sorry for my bad english. I use my extra ball to try again :

With Monitor() at messages arriving, I lose the advantage of
multi-threading.

Is that more readable ?
;o)

Oh.. I see... right!
I have something like that (as an attached document of this answer).
Well it was a useless peace of code as SqlConnection already use a
connection pool under the hood.
But if you replace all the SqlConnection stuff by MySqlConnection it will
suddenly start to make sense!


THANKS A LOT !!!

Ok, I'll try it this afternoon.

<;oP> I hope you've make a non buggy code </;oP>

I hope too! ;-)

I give you a report after tests...

Cheers,

Yep, do tell me! Hopes it will work great!

Feb 11 '06 #5
Lloyd Dupont a écrit :
what's wrong with the Monitor?

Anyway it's very typical and advised to have a connection pool which (the
pool) as a properly synchronized access and return a private connectionon
demand.


What about the Prepared Statements ?

I think they are associated with a SqlConnection.
So If I create some prepared statements they will stay associated with the
connection but I could not use them if Pool give me another connection ...

I'm not clear because I could not imagine how Prepared Statement will be managed
when using a ConnectionPool.

What do you think about that ??

thanks
cyrille.
Feb 11 '06 #6
Lloyd Dupont a écrit :
I have something like that (as an attached document of this answer).
Well it was a useless peace of code as SqlConnection already use a
connection pool under the hood.
But if you replace all the SqlConnection stuff by MySqlConnection it will
suddenly start to make sense!


Yeah !
Your code works fine.

I've just made one change that do not close connections when freeing them, to
avoid the open/close overload.
Connections will be closed by MySqlConnection .Dispose() in MySql.Data.

Another stuff appends to me. While reading the source code of MySql.Data to be
shure connections will be closed, I found that there is already a Connection
Pool in the connector... But I did not know because the documentation does not
talk about...

I don't know if I still need to use the DBConnectionPoo l ...
By the way, it was fun to test your code ;oP

Cyrille.
Feb 11 '06 #7
# Cyrille37 # a écrit :
Lloyd Dupont a écrit :
I have something like that (as an attached document of this answer).
Well it was a useless peace of code as SqlConnection already use a
connection pool under the hood.
But if you replace all the SqlConnection stuff by MySqlConnection it
will suddenly start to make sense!


Yeah !
Your code works fine.

I've just made one change that do not close connections when freeing
them, to avoid the open/close overload.
Connections will be closed by MySqlConnection .Dispose() in MySql.Data.

Another stuff appends to me. While reading the source code of MySql.Data
to be shure connections will be closed, I found that there is already a
Connection Pool in the connector... But I did not know because the
documentation does not talk about...

I don't know if I still need to use the DBConnectionPoo l ...
By the way, it was fun to test your code ;oP


I did some stress tests with the DBConnectionPoo l and without it.

Result are very very faster with DBConnectionPoo l (my version without Closing).

Cyrille
Feb 11 '06 #8
>> I don't know if I still need to use the DBConnectionPoo l ...
By the way, it was fun to test your code ;oP


I did some stress tests with the DBConnectionPoo l and without it.

Result are very very faster with DBConnectionPoo l (my version without
Closing).


Good!
I guess you'll keep using it! ;-)
Feb 11 '06 #9
I would say, don't reuse them.
Create them on demand each time.
Not only it will make easier to maintain/use/understand, but I dont believe
there is that much to gain by trying to reuse them....

"# Cyrille37 #" <cy*******@free .fr> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Lloyd Dupont a écrit :
what's wrong with the Monitor?

Anyway it's very typical and advised to have a connection pool which (the
pool) as a properly synchronized access and return a private connection on
demand.


What about the Prepared Statements ?

I think they are associated with a SqlConnection.
So If I create some prepared statements they will stay associated with the
connection but I could not use them if Pool give me another connection ...

I'm not clear because I could not imagine how Prepared Statement will be
managed
when using a ConnectionPool.

What do you think about that ??

thanks
cyrille.
Feb 11 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2340
by: Robert J Egan | last post by:
Hi i'm trying to search a remote website page. The form returns xml information, though the page extension is missing. I retrieve the information and write it to the screen. So far so good - However i cannot format this information in anyway. A copy of the returned information saved to my server results in the xml data being formatted and...
1
2157
by: felipe_azv | last post by:
a got this code in asp to construct a xml , to export it to a url this is de asp code: <% SQL = "Select * from User where CodeUser in ("& request.form("C1" &")" set rs = server.CreateObject("ADODB.Recordset") rs.CursorType = 3
0
1540
by: MarionEll | last post by:
Premier XML Industry Event Slated for Dec. 7-12 in Philadelphia; Presenters Include Adobe, BEA, Microsoft, IBM, Sun, Hewlett-Packard, Oracle Alexandria, Va. Sept. 30, 2003 - IDEAlliance, a leading trade association dedicated to fostering XML and other information technology standards, today announced the full program for XML Conference...
6
6771
by: yzzzzz | last post by:
Hi, In which cases is the <?xml version="1.0" encoding="UTF-8"?> processing instruction required at the beginning of an XML document, for the document to be valid? e.g. does it depend on the encoding used in the document, of the version of XML being used... Thanks.
0
1729
by: Stylus Studio | last post by:
World's Most Advanced XML Schema Editor Adds Support for IBM AlphaWorks XML Schema Quality Checker to Improve XML Schema Style and Quality BEDFORD, MA -- 09/13/2005 -- Stylus Studio (http://www.stylusstudio.com), the industry-leading provider of XML development tools for advanced data integration, today announced new support for IBM's...
5
4197
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple values in the where clause as below
0
2220
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): PERL5LIB=/Users/Ric/Library/Perl/ ls XML-Parser-2.34/ XML-Parser-2.34.tar
9
2473
by: Lie | last post by:
Why this generates AttributeError, then not? Python 2.5.2 (r252:60911, Apr 21 2008, 11:17:30) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'dom' <module 'xml.dom' from...
0
2163
by: Jacker | last post by:
Xpress Author for MS Word XML Documents In.vision Research empowers knowledge workers to create complex XML documents in Microsoft Word (2000-2003) with a normal Word experience. Deploy XML authoring across the enterprise. http://e.goozw.com/xml.htm Powerful XML Editing Tool - XMLSPY XMLSPY is a powerful XML tool for editing XML documents,...
0
7813
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8066
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8249
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6461
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5631
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2251
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 we have to send another system
1
1350
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1066
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.