This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Manage multiple UDP calls Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Manage multiple UDP calls" Watch "Manage multiple UDP calls" New topic
Author

Manage multiple UDP calls

ray frid
Ranch Hand

Joined: Dec 23, 2010
Posts: 79
Hi all,
I would like to have an advice for this issue:
I am using Jbos 5.1.0, EJB3.0

I have system, which sending requests via UDP'S to remote modems, and suppose to wait for an answer from the target modem.
the remote modems support only UDP calls, therefor I o design asynchronous mechanism. (also coz I want to request X modems parallel)

this is what I try to do:

all calls are retrieved from Data Base, then each call will be added as a message to JMS QUE.
let's say i will set X MDB'S on that que, so I can work asynchronous. now each MDB will send UDP request to the IP-address(remote modem) which will be parsed from the que message.

so basicly each MDB, which takes a message is sending a udp request to the remote modem and waiting for an answer from that modem.

now here is the BUG:

could happen a scenario where MDB will get an answer, but not from the right modem( which it requested in first place).

that bad scenario cause two wrong things:

a. the sender which sent the message will wait forever since the message never returned to him(it got accepted by another MDB).
b. the MDB which received the message is not the right one, and probablly if it was on a "listener" mode, then it supposed to wait for an answer from diffrent sender.(else it wouldnt get any messages)

so ofcourse I can handle everything with a RETRY mechanisem. so both mdb's(the one who got message from the wrong sender, and the one who never got the answer) will try again, to do thire operation with a hope that next time it will success.


This is the mechanism, mybe you could tell me if there is any design pattren, or any other effective solution for this problem?

Thanks,

ray.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
could happen a scenario where MDB will get an answer, but not from the right modem( which it requested in first place).


But each datagram packet should contain an IP address of the originating machine, right?

I am not understanding your use of the term "modem" - what is really creating packets?

Bill
ray frid
Ranch Hand

Joined: Dec 23, 2010
Posts: 79
William Brogden wrote:
could happen a scenario where MDB will get an answer, but not from the right modem( which it requested in first place).


But each datagram packet should contain an IP address of the originating machine, right?

I am not understanding your use of the term "modem" - what is really creating packets?

Bill



Yes, the modem is creating packets automatically, and as we know it should return the answer to the same socket. but there is some bug, sometimes it send the answer to the wrong socket.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Yes, the modem is creating packets automatically, and as we know it should return the answer to the same socket. but there is some bug, sometimes it send the answer to the wrong socket.


If the fault is in the "modem" packet creation, and you have no control over the "modems" about the only thing you can do is ignore wrongly addressed packets.

Bill
 
jQuery in Action, 2nd edition
 
subject: Manage multiple UDP calls
 
Similar Threads
Mdb and runtime exceptions
MDB with MessageConsumers
Architecture advice about handling multiple UDP calls
Mock question on messaging and design pattern
Distributed transactions in EJB