Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Mona Mehta   on Jun 29 In Java Category.

  
Question Answered By: Umaiza Hashmi   on Jun 29

I should say I disagree

observer pattern  is not a messaging technique while publish-subscriber is a messaging technique.

I understand what you are trying to achive but this is not the correct direction. observer in simple terms is used for callback, but not for messaging. in observer pattern, subjects call out / notify observers (more like a method call), and there is no implementation / concept of queuing in this pattern.

you shouldn't confuse GoF observer with enterprise messaging.

now apart from messaging and observer discussion, consider the scenario below

client1 asks for a session to register in class  A
client2 asks for a session to register in class A

note that only one place is available

both are in the middle  of the session and both trigger a registeration request for the class A? what will you gain here from messaging? you can't stop them from registeration unless you have a logic with the data source to protect the data from exceeding a certain threshold.

This needs a protection over the common resource (class). one technique could be the use of transation and its proper attibutes (refer to transaction documents)

the other could be a singleton object per cluster (only a raw idea for the moment)

Share: