Raymond Ong

Ranch Hand
+ Follow
since Jul 17, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Raymond Ong

Originally posted by Stan James:
I took "at the same time" to rule synchronizing like that out, but it oughtta help.

I also understood the trouble with "individual threads sending messages (synchronously) over the same socket ..." and wanted to try individual threads sending messages over different client sockets. If the server is built in a conventional manner it will accept many client threads connecting to the same server socket at the same time.



Yup. Thanks

Originally posted by Ernest Friedman-Hill:
The client threads need to do the entire "send message, read response" sequence while holding onto a single shared lock object. i.e., what you're describing will work perfectly fine if you do



Assuming, of course, that the server is designed to handle multiple messages on a single client connection.

Make sense? I'm not sure why no one has explained this already.



the code you posted is basically queueing, right? I just have to implement a time-out mechanism when reading replies from the server.

Thanks

Originally posted by Stan James:
So poke around a bit ... what does the server do if you open multiple sockets from the client? The code I showed is almost pseudo code for any self respecting server. It might behave perfectly. Or not.

If you send multiple messages over the same socket and look for responses to come back possibly out of order, you're into classic asnychronous mode. Messaging products like MQ-Series create a "correlation id" when they send the request, and put the same id on the response. That helps you know which requester wants each response. I think I have a bit on this HERE.



I've already done some tests As I've mentioned in my second post and the replies that the individual threads get aren't always the expected response which means that individual threads sending messages (synchronously) over the same socket will not work. Adding an ID for each message won't work also since there is no provision for this in the server using the CIMD/UCP protocol.

Thanks
Thanks Stan,

Actually the server implementation is not my problem. It's the client side.
Thanks Ibrahim,

Let me clarify that. I have am developing a client app. I have a single client socket connected to a server. Now I have serveral threads that will send messages to the server (write to the ouput buffer, concurrently and otherwise). These threads are supposed to wait for a reply from the server before it proceeds to its next task. I've tested this setup and it doesn't seem to work.

Here's my test setup:

1. Create a client socket
2. Create 3 threads which will write to the socket output buffer and wait for server reply
3. Start the 3 threads

Now here's how the program behaves:

1. The threads were able to send the messages "concurrently", although I'm sure this is syncrhonized.
2. The server replies got mixed up, i.e. thread 1 received reply for thread 2, thread 2 received reply for thread 3, etc.

So it is evident this setup will not work. What I'd like to ask is what setup is best for multiple threads writing to a single socket.

This is what I have in mind:

1. Create a client socket
2. Create a thread A which will pull outgoing messages from a queue, send messages to a server and wait for reply
3. Start thread A
4. Create 3 threads B which will write to the outgoing message queue and wait for a notification of server reply from thread A
5. Start B threads

So B threads will write to the queue and wait for a notification of a server reply by thread A. Thread A sees an outgoing message. Send the message and waits for a reply. When it receives a reply, it notifies a thread B, then thread A continues sending the next message on the queue and so on.

This seems slow especially if server reply takes long. Is this the correct design?

By the way, the protocol i'm using is CIMD and UCP/EMI

Thanks in advance.

[ August 27, 2006: Message edited by: Raymond Ong ]
[ August 27, 2006: Message edited by: Raymond Ong ]
Hi,

I'd like to ask if it's possible for multiple threads to write on a socket at the same time, then wait and read a response from the server on the same socket. I plan to create client socket, which can send and receive messages to and from the server concurrently. If not what's the best design? Do I have to queue the outgoing messages while waiting for the reply for the last message sent?

Thanks in advance.
Thanks man! Will check the docs and try to post what I find out.
How come after all threads have died, I still have javaw.exe running? I'm debugging using eclipse.

Thanks
Hi,

I'm a Physics graduate and a Java programmer at the same time. I'm also familiar with Borland Delphi, and SQL in general. Can anyone advice on how I can slowly shift careers from programming financial software to programming software for Science or Physics in general? I'm interested in Physics and I'd like to apply what I've learned in college. What fields should I explore and what kinds of software and algorithms do I have to start to learn and develop?

Any advice will be appreciated.

Thanks!
15 years ago
Hi everyone,

How do you retrieve sessions in a SimpleFormController for session tracking?
Thanks a lot.
Hi,

I would just like to ask if anyone has successfully used MySQL 5 with JBoss for both data storage and JMS message persistence as well. I'd like to get some feedback before I seriously start considering an upgrade from MySQL 4 to 5. Thanks a lot.
Since I really can't get my previous code to work, looks like i'm gonna stick to sending plain text xml.

Thanks a lot.
15 years ago
Hi,

I have made a servlet that sends an XML data via an HttpServletResponse object. With this approach I can send the XML data to a browser or an HttpClient object which uses the getResponseBody() method. Problem is, it does not work with the MIDP2 HttpConnection object using the openInputStream(). Has anyone tried sending XML data to a mobile phone?

Please see code below for doPost().

Thanks a lot.



code based on : http://www.javazoom.net/services/newsletter/xmlgeneration.html
[ November 08, 2005: Message edited by: Raymond Ong ]
15 years ago
Hi,

I'm having problems using Log4j JDBC Appender for my MDB. When I deploy my MDB to JBoss I get an error saying that the database connection could not be created due to too many connections. I have set my minimum database connections to 150 in mysql-ds.xml and I have 50 instances of MDBs but still I have this error. This occurs only once during start up. I'll be investigating this but if there's anyone who has encountered a similar scenario, I'd be happy to hear your comments.

Thanks!