473,756 Members | 1,764 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 2150
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
2349
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 displayed as intended! Can anyone explain to me why one would work but not the other. Regards ...
1
2168
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
1557
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 and Exposition 2003, being held Dec. 7-12, at the Pennsylvania Convention Center in Philadelphia,...
6
6786
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
1757
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 alphaWorks XML Schema Quality Checker, furthering solidifying its position as the provider of the...
5
4210
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
2240
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
2481
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 '/usr/lib/python2.5/xml/dom/__init__.pyc'>
0
2170
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, XML schema, DTDs, XSL/XSLT stylesheets, SOAP applications, debugging Web services and more....
0
9271
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9869
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9708
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7242
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5140
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2665
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.