• Post Reply Bookmark Topic Watch Topic
  • New Topic

Observer / Observable  RSS feed

 
Pearlo Muthukumaran
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Is this pattern scalable when being used in custom event notification scenario?
What will happen if the Observable's Vector or collection object containing the references of observers increase to the tune of say 1000 or so?
Rgds
Muthu
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd expect in most implementations the Observable publishes messages to the Observers one at a time iterating through some collection. "Not much time" times 1000 starts to be "quite a bit of time" so this could take a while. Observers must be careful to return quickly. If some of them are going to take a while, they might spin off the work onto new threads so they can return quickly. If all of them start new threads, managing 1000 threads is another big problem!
BTW: That's a lot of observers! What kind of application are you talking about?
[ June 13, 2003: Message edited by: Stan James ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
"Not much time" times 1000 starts to be "quite a bit of time" so this could take a while. Observers must be careful to return quickly. If some of them are going to take a while, they might spin off the work onto new threads so they can return quickly. If all of them start new threads, managing 1000 threads is another big problem!

Of course this is a more general problem and not specific to observer/observable. When there is much to do in the case of an event, there is much to do whatever pattern you use to react to it.
If the observer typically return quickly, I wouldn't expect it to be a problem, on the other hand.
But I would also be interested in what you are trying to accomplish. It would probably also help us to think about alternatives...
 
Pearlo Muthukumaran
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the interest. My application flows as following:
1. Send an SMS to mobile device beginning a dialog session for some activity on the device
(God alone knows when it reaches device due to awful and not-so-speedy SMS behvaior)
2. Device contacts the server in its own sweet time through HTTP Post once SMS is received
3. The session has to be tracked till then and the device message is escalated to application logic which will determine what messages are to be sent to the device
4. This message is returned to mobile as HTTP Reply to HTTP Post of step 2
Stateful session beans are quiet too much I believe particularly for a live Telecom Application like the one above ....
So I am trying to implement a sort of registered callback through the Observer/Observable type of behavior (Not exactly Observable / Observer)
Any lights...??
Rgds
Muthu
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pearlo Muthukumaran:
Any lights...??

No, sorry. Perhaps you can provide some code sketches?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!