Question

I have a webservice that needs to use a jabber-net object to send XMPP messages to clients.

(It's for handling printing: when the webservice needs something to be printed, I send an XMPP message to a windows forms client that's running on the particular machine plugged into the printer, with the print job type and the URL, and the client then downloads the data and sends it to the printer. This communication channel will also be used for other POS functions such as opening till drawers, talking to chip and pin devices, etc, so printing alternatives won't be helpful).

I have a static object which contains an instance of the jabber-net object, which signs into the XMPP server, and is then available to send messages.

This works fine single threaded. When I convert the webservice to a web garden so that it can work on more than one thread, it seems as though each thread gets its own instance of the jabber-net object, so they're all trying to sign into the XMPP server at once as the same user, which means they continually get kicked out.

Question: Is there any way to share a live object (that might handle events, not a serialised object, not just data) between all the threads in a web garden, and if so, what's the best way to do it?

Was it helpful?

Solution

Web gardens are basically miniature web farms, and should be treated as such - look for solutions that would be involved in web farms and those same solutions will apply in your case.

I was caught out by sessions and web gardens, and I eventually switched to an out of process session provider (I used a memcached based provider, but the SQL Server provider would have worked). You could do something similar, and have a shared provider that eac thread could request the object from.

This won't solve your events issue though - I doubt that that will be solvable in this way, and you might have to switch to a messaging system (msmq for example), with all messages handled by a single process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top