TcpIpConnection issues

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

TcpIpConnection issues

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:08 pm

by allistar >> Sat, 8 Jun 2002 10:39:26 GMT

Hi there,
I am using the "listenContinuousAsynch" method on a TcpIpConnection object and have specified a callback method. This works fine, and I can get communications with my external process (written in C++). The problem is that I want another Jade thread to take the new connection and work with it while leaving the original thread to continue to receive new connections.

This doesn't work as the new TcpIpConnection object that is created is not created as a shared transient, and the new thread (spawned using the app.startAppMethod method) gets a 1266 exception (A non-shared transient object is being accessed by another process).

Is there way way of processing this new connection in another thread so the asynchronous listen can continue receiving conections?

Thanks,
Allistar.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: TcpIpConnection issues

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:08 pm

by cdshearer >> Sun, 9 Jun 2002 9:08:53 GMT

Hi Allistar

This is pretty simple to fix, as is documented in the help for the TcpIpConnection class:



"As you can create a TcpIpConnection object as a shared transient object, you can pass it to another JADE process on the same JADE node, if required. Shared transient TCP/IP connection objects enable you to create a communicator application that passes on messages to worker threads and to share connections between processes so that a new connection can be passed on to a worker application.

Ensure that you are in shared transient transaction state before you create or delete a TcpIpConnection object, by setting the port property or the Connection class name property."



So, if you create the initial connection as a SharedTransient object, then your listenContinuousAsynch method will pass you SharedTransient instances of the new connections that you can then pass off to a worker thread.

I'm currently using just such an architecture. I take it you're creating the threads in advance and using a thread pool - the cost of starting a new thread for each connection would typically be prohibitive.

Hope this helps,

Craig Shearer

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: TcpIpConnection issues

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:08 pm

by allistar >> Sun, 9 Jun 2002 20:43:36 GMT

Craig,
Thanks for that. I did try creating my original connection object as a sharedTransient and I'm sure that the new instance created by listContinuousAsynch was not a shared transient. I'll try this again and see if I missed something originally.

The nature of these connections is that starting another process each time to handle them should be ok as the connections are not expected to be received very often.

Thanks,
Allistar.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: TcpIpConnection issues

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:08 pm

by allistar >> Mon, 10 Jun 2002 8:55:42 GMT

Craig,
Yes, that worked fine this time.

Thanks,
Allistar.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 33 guests