asynchronous rpc - eth zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/lecture8.pdf · remote...
TRANSCRIPT
![Page 1: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/1.jpg)
Asynchronous RPC
![Page 2: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/2.jpg)
Abstraction Motivation
Strong coupling induces strong dependencies in distributedapplication
Latency of remote invocations different than local onesRemove flow coupling
(Subtypes of) proxy abstractionOneway call: no return valueExplicit future: no inherent waiting for return valueImplicit future: no necessary waiting for return value
From concurrent programmingUsually based on specific compilation
![Page 3: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/3.jpg)
Oneway Call Abstraction
Proxy
TypeSame as server objectReply-less calls can have different semantics by default, orMethods without return value can be marked, e.g, onewaypublic interface Bob {
public void helloBob();
public String howIsBob();
}
![Page 4: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/4.jpg)
Remote invocation returns without waitingFor termination of the remote method body executionOr even without awaiting an ack for successful reception
Obviously flow coupling is removedWhen anyway not necessary, or by reasoning/designing
differently, e.g.,1 synchronous invocation -> 2 asynchronous invocationspublic interface BobCallback {
oneway public void BobIs(String s); }
public interface Bob {
oneway public void howIsBob(BobCallback bcb); }
![Page 5: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/5.jpg)
E.g.,ABCL, Actalk, Hybrid, PO, CORBAWith or without different semantics for reply-less methods
AnthropomorphismA hologram which can not talk, only listenTransmits what initiator saysReplies (if any) must be sent by some other means, e.g., a
second hologram which only talks
![Page 6: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/6.jpg)
![Page 7: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/7.jpg)
Explicit Future - Polling Principle
Return future object instead of return valueReturn value can be queried through future object
AbstractionFuture proxy
TypeOriginal server object type modified/subtypedMaybe use of keyword to mark methods, e.g., future
E.g.,ABCL, Act++, CSmalltalk, PO, CORBA AMI
![Page 8: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/8.jpg)
Each return value type TIs changed to TFuture, e.g.,public interface Bob {
public String howIsBob();
}
Becomespublic interface BobProxy extends Bob, Proxy{
public String howIsBob();
public StringFuture howIsBob();
}
![Page 9: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/9.jpg)
Basic future typepublic abstract class Future {public boolean isAvailable() {…}public void wait() {…}…
}
Hence StringFuture is something likepublic class StringFuture extends Future {public String poll() {…}public String pull() {…}…
}
![Page 10: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/10.jpg)
![Page 11: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/11.jpg)
Example Consumer
ClientInvoker
Bob bob =new BobProxyImpl(…);
StringFuture how =bob.howIsBob();
System.out.println(how.pull());
ProducerServerInvokee
public class BobServerimplementsBobSkeleton {…}
Bob bob = newBobServer(…);
bob.howIsBob();
![Page 12: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/12.jpg)
Explicit Future - Callback When polling for replies with futures
Flow coupling is reduced, but not entirely avoidedOnly callback mechanism can fully remove flow coupling
AbstractionCallback proxy
TypeOriginal server object type Is modified/subtypedMaybe use of keyword to mark methods, e.g., future
E.g.,ABCL, Act++, CSmalltalk, CORBA AMI
![Page 13: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/13.jpg)
Each return value type TIs changed to void, and the operation gets an
additional argument, e.g.,public interface Bob {
public String howIsBob();}
Becomes (generated by compiler)public interface BobProxy extends Bob, Proxy{ public String howIsBob(); public void howIsBob(StringCallback c);}
![Page 14: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/14.jpg)
Basic callback typepublic interface Callback {public void exceptionOcc(Exception ex);…
}
Hence StringCallback is somethinglikepublic interface StringCallback extendsCallback {public void reply(String s);
}
Implemented by application
![Page 15: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/15.jpg)
![Page 16: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/16.jpg)
Example Consumer
Client Invoker
public class mySCB
implements StringCallback {
public void reply(String s)
{ System.out.println(s); }
… }
Bob bob =
new BobProxyImpl(…);
bob.howIsBob(new mySCB());
> good
ProducerServer Invokee
public class BobServerimplements BobSkeleton{…}
Bob bob = new BobServer(…);
bob.howIsBob();
![Page 17: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/17.jpg)
Implicit Future Principle
Developer● Use the return value of a remote invocation as late as
possible in the codeSystem
● Return immediately from the call● Even though the value is not fixed● « Insert » it as soon as available● If it is queried before, block
![Page 18: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/18.jpg)
AbstractionProxy
TypeSame as original typeFuture by default, or explicitly mark future calls e.g, futurepublic interface Bob {
public String howIsBob();
}
E.g.,Eiffel//, Karos, Meld
![Page 19: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/19.jpg)
IllustrationBob bob = …; /* lookup */
/* remote call is issued */
String how = bob.howIsBob();
…
/* how might still be undefined */
…
/* if how is still undef., this will block */
System.out.println(how);
…
![Page 20: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/20.jpg)
Anthropomorphisms Explicit future - polling
A hologram which does (can) not answer to your questionInstead you get a phone nb etc., where you can get the replyYou might only get « occupied » if the reply is not readyE.g., hologram of a stupid and lazy assistant who promises
to find the answer for you, or tells you where to find it
Explicit future – callbackA hologram which does not reply immediately, still « listens »When a reply is ready, you will be calledE.g., hologram of a stupid but nice assistant who will find out
some details calls you
![Page 21: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/21.jpg)
Implicit futureA hologram which replies immediately with some
« superficial » replyYou think you have understood, yet you have notIf you need more details immediately, you must give the
hologram timeOtherwise, you can continue, the hologram will give you
more information later anyway, which will help understand -« aha » effect
E.g., hologram of a smart assistant: you ask a question, andshe/he does not know the reply, so you are drowned insuperficial talk giving him/her more time to find the right reply
![Page 22: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/22.jpg)
Asynchronous RPC
CORBA Asynchronous MessagingInterface (AMI)
![Page 23: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/23.jpg)
Asynchr. Invocations in CORBA CORBA enables
Oneway operations with best-effort semanticsExplicit future with DIIAnd offers the Asynchronous Messaging Interface (AMI):
Consisting of two partsInterface for specifying invocation policies (qualities of
service for invocations)Implied IDL: asynchronous variants of IDL defined operations
● Future● Callback
![Page 24: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/24.jpg)
For each interface <I>, the IDL compiler generatesAn AMI_<I>Poller value type for futuresAn AMI_<I>Handler interface for callbacksAn AMI_<I>ExceptionHolder value type for exceptions
Exampleinterface Agenda {
void add_appointment(in Time at, in Person p)
raises (AlreadyTaken);
void remove_appointment(in Time at)
raises (NoAppointment);
Person get_appointment(in Time at);
};
![Page 25: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/25.jpg)
Implied IDLinterface Agenda
{
AMI_AgendaPoller sendp_add_appointment(in Time at, in Person p);
AMI_AgendaPoller sendp_remove_appointment(in Time at); AMI_AgendaPoller sendp_get_appointment(in Time at);
void sendc_add_appointment(in AMI_AgendaHandler handler, in Time at, in Person p);
void sendc_remove_appointment(in AMI_AgendaHandler handler, in Time at);
void sendc_get_appointment(in AMI_AgendaHandler handler, in Time at);
};
![Page 26: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/26.jpg)
Pollerinterface AMI_AgendaPoller : Messaging::Poller
{
void add_appointment(in unsigned long timeout)raises(AlreadyTaken, CORBA::WrongTransaction);
void remove_appointment(in unsigned long timeout)
raises(ToAppointment, CORBA::WrongTransaction);
void get_appointment(in unsigned long to, out Person p);
};
Only in/inout parameters remain in operationinout parameters are changed to in
out/inout parameters including any return valueare added to corresponding parameters of polleroperationinout parameters are transformed to out
![Page 27: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/27.jpg)
Handlerinterface AMI_AgendaHandler : Messaging::ReplyHandler
{
void add_appointment();
void add_appointment_excep(in AMI_AgendaExceptionHolderh);
void remove_appointment();
void remove_appointment_excep(inAMI_AgendaExceptionHolder h);
void get_appointment(in Person p);
void get_appointment_excep(in AMI_AgendaExceptionHolderh);
};
xxx_excep() method is called if an exceptionoccurred
![Page 28: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/28.jpg)
ExceptionHoldervalue AMI_AgendaExceptionHolder :Messaging::ExceptionHolder
{ void raise_add_appointment()
raises (AlreadyTaken); void raise_remove_appointment()
raises (NoAppointment);void raise_get_appointment();
};
Additional information, e.g., target can be obtainedthrough supertypes ofExceptionHolder, ReplyHandler, Poller
![Page 29: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/29.jpg)
Publish/Subscribe
![Page 30: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/30.jpg)
Origins Group-based systems
Inherently one-to-n
Anonymous CommunicationDerived from Generative Communication (Tuple Space)Targeting at strong decoupling of participants, e.g., forVery large, long-lasting, scalable applicationsBased on Information Bus abstraction, several flavors
● Topic-based : iBus, SmartSockets, TIBCO, Vitria / JMS,CORBA Event & Notification Srvcs, some with a touch of
● Content-based : Gryphon, Siena, Jedi, JavaSpaces, DACs● Type-based : GDACs, JavaPS
![Page 31: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/31.jpg)
Publish/Subscribe Model
Producers publish informationConsumers subscribe to informationUsually producers and consumers both in push mode
Decoupling of participantsIn timeIn spaceIn flow
Enforces scalability
![Page 32: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/32.jpg)
![Page 33: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/33.jpg)
AbstractionChannel
Basic typepublic interface Channel {}
With publish()and subscribe() methods topublish/subscribe to events
Signatures varying according to flavor
![Page 34: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/34.jpg)
AbstractionUntyped channel
Typepublic interface UntypedChannel {
void publish(Event e);
}
Events are usually « serializable » data objectspublic interface Event extends Serializable {}
In most cases, only predefined types are allowed, e.g., self-describing messages, including QoS description
![Page 35: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/35.jpg)
Topic-Based Publish/Subscribe A.k.a. subject-based publish/subscribe News-like approach
Messages are classified according to topic names, e.g.,EPFL
Topics can be seen as (dynamic) groups
URL-like topic names for convenienceTopics arranged in a hierarchy, e.g., /EPFL/DSCAutomatic subscriptions to subtopicsWildcardsAliases
![Page 36: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/36.jpg)
Topic-Based
![Page 37: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/37.jpg)
AbstractionTopic
Typepublic interface Topic extends UntypedChannel {
public String getTopicName();
public void subscribe(Notifiable n);
public void unsubscribe(Notifiable n);
}
Where a Notifiable represents a callback objectpublic interface Notifiable {
public void notify(Event e);
}
One-to-n, all-of-n
![Page 38: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/38.jpg)
Examplepublic TopicImpl implements Topic {
public TopicImpl(String topicName) {…} … }
public class State implements Event {
public String mood;
public String name;
public State(String m, String n)
{ mood = m; name = n;}
}
Producer (publisher)Topic t = new TopicImpl("/People/Moods");
Entry bobState = new State("good", "Bob");
t.publish(bobState);
![Page 39: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/39.jpg)
public class StateNotifiable implements Notifiable {
public void notify(Event e) {
if (e instanceOf State) {
State s = (State)e;
System.out.println(s.name + "is doing" + s.state);}
}
}
Consumer (subscriber)Topic t = new TopicImpl("/People/Moods");
t.subscribe(new StateNotifiable());
> Bob is doing good
> Alice is doing better
![Page 40: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/40.jpg)
Content-Based Publish/Subscribe A.k.a. property-based publish/subscribe Events classified according to their
propertiesConsumers subscribe by specifying properties of events of
interestApplication criteria are seen as subscription patternTranslated to filter, or predicate, matched against events
Classic approachMap event attributes to propertiesSubscription language and parser,E.g., "name == ‘Bob’"
![Page 41: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/41.jpg)
Content-Based
![Page 42: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/42.jpg)
AbstractionContent channel
Type public interface ContentChannel extends UntypedChannel {
public void subscribe(Notifiable n, Filter f);
public void unsubscribe(Notifiable n);
}Where a Filter represents the subscriber’s individual criteria
public interface Filter { public boolean conforms(Event e); }
One-to-n, some-of-n Attention: filtering opaque!
![Page 43: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/43.jpg)
Self-Describing Messages Similar to DynAny in CORBA
Represent rather structures than objects, e.g.,public class SelfDescribingEvent extends Event {
public void addString(String fieldName, String s) {…}
public void addByte(String fieldName, Byte b) {…}public void addObject(String fieldName, Object o) {…}
…
public String getString(String fieldName) {…}
public Byte getByte(String fieldName) {…}
public Object getObject(String fieldName) {…}
…
public String[] getFieldNames() {…}
public Class getFieldType(String fieldName) {…}
…
}
![Page 44: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/44.jpg)
Examplepublic class Contents {
public static ContentChannel getChannel() {…} … }
Producer (publisher)ContentChannel channel = Contents.getChannel();
Event bobState = new SelfDescribingEvent();
event.addString("name", "Bob");
event.addString("mood", "good");
event.addInteger("time", 15);
channel.publish(bobState);
![Page 45: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/45.jpg)
public class ContentNotifiable implements Notifiable {
public notify(Event e) {
if (e instanceof SelfDescribingEvent) {
SelfDescribingEvent s = (SelfDescribingEvent)e;
System.out.print(s.getString("name") + " feels ");
System.out.print(s.getString("mood") + " at ");
System.out.println(s.time); } }
}
Consumer (subscriber)ContentChannel content = Contents.getChannel();
Filter filter = new AttributeFilter("time > 21 && (mood== ‘good’ || mood == ‘very good’)");
content.subscribe(new StateNotifiable(), filter);
![Page 46: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/46.jpg)
Most topic-based systems nowadays alsoincorporate content-based featuresMore flexible
● Can be used to express topics
Self-describing messagesOffer much dynamismEnforce interoperabilityRarely requiredNot « type- »safe
![Page 47: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/47.jpg)
Oneway Proxy Approach Reuse proxy abstraction
Without repliesDispatch request through channel, to all consumers of same type as
proxy
AbstractionProxy (oneway)
TypeConsumer typepublic interface Bob {
oneway public void helloBob();
}
public interface BobProxy extends Bob, Proxy {}
![Page 48: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/48.jpg)
Example Producer
Publisherpublic class BobProxyImpl
extends ProxyImpl
implements BobProxy {
public BobProxyImpl(
ContentChannel c){ super(c); } … }
ContentChannel content =Contents.getChannel();
Bob bob =
new BobProxyImpl(content);
bob.helloBob();
Consumer (i-th)Subscriber
public class BobServer
extends BobSkeleton {
public BobServer(
ContentChannel c){ super(c); } … }
ContentChannel content =Contents.getChannel();
Bob bobi = newBobServer(content);
bobi.helloBob();
![Page 49: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/49.jpg)
E.g.,COM+: based on application-provided « dummy » proxy
● Content-based: values for invocation argumentsCORBA Event Service: precompiler based
NoteAlso been applied to synchronous « group » invocationsE.g., transform all return types to array types, and return
after obtention of a certain number of repliesSimilarly, futures and callbacks can be used to return repliesCoupling?
![Page 50: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/50.jpg)
Genericity Approach Abstraction
Typed channel (type-parameterized channel)
Typepublic interface TypedChannel<EventType> { void publish(EventType e);
void subscribe(TypedNotifiable<EventType> n, TypedFilter<EventType>);
}
Withpublic interface TypedNotifiable<EventType> {public void notify(EventType e); }
public interface TypedFilter<EventType>) {public boolean conforms(EventType e); }
![Page 51: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/51.jpg)
Based on parametric polymorphismA form of genericityChannels are type parameterized by the effective event typeBounded parametric polymorphism is used to ensure
« serializability »:public interface
TypedChannel<EventType extends Event> {}
The application can use its own event (sub)types
![Page 52: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/52.jpg)
Type-Based Publish/Subscribe Subscription criterion
The type (its interface) of application-defined eventsContent-based queries based on methods
Combines static and dynamic schemesStatic classification should be made as far as possible for
efficiencyFilters for fine-grained content-based subscription increase
expressiveness if required
Languages which support structuralreflectionNo need for specific events (e.g., Java introspection),In other languages, events can subtype an introspective
event type
![Page 53: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/53.jpg)
Type-Based
P1
P2 P3
T1
T2 T3
T4 T5
EventTypes
T1
T2
T3
T4T5
![Page 54: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/54.jpg)
Examplepublic class TypedImpl<T> implements TypedChannel<T> { … }
public class State implements Event {
private String mood;
private String name;
private long time;
public String getMood() { return mood; }
public String getName() { return name; }
public long getTime() { return time; }
public State(String m, String n, long t)
{ mood = m; name = n; time = t;} }
Producer sideTypedChannel<State> stateChannel = newTypedImpl<State>();
State bobState = new State("good", "Bob", 15);
stateChannel.publish(bobState);
![Page 55: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/55.jpg)
public class StateNotif implements Notifiable<State> {
public notify(State s) {
System.out.print(s.getName() + " feels ");
System.out.print(s.getMood() + " at ");
System.out.println(s.getTime());
}
}
Consumer side TypedChannel<State> stateChannel = new
TypedImpl<State>();
Subscription sub = stateChannel.subscribe(newStateNotifiable());
sub.constrain().getMood().equals("good");
sub.start();
![Page 56: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/56.jpg)
JavaPS Two primitives added, e.g.,
publish new State(…);subscribe (State s)
{ return s.getMood().equals(“good”); }
{ System.out.println(s.getName()); };
Heterogenous transl. with extendedcompilerGeneration of “adapter” code, e.g., StateAdapter,
invocations of primitives transformedAbstract syntax trees for content filters
![Page 57: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/57.jpg)
Publish/Subscribe
Java Message Service (JMS)
![Page 58: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/58.jpg)
Java Message Service The Java Message Service is only an API
Standardized API for messaging in JavaImplemented by most industrial solutions
● TIBCO● iBus● Gryphon● …
Two messaging styles:Publish/subscribe (topic-based & content-based): some-of-nPoint-to-point (message queuing): one-of-n
![Page 59: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/59.jpg)
Benefit of JMS Sun standard
Ensures a certain degree of portabilityIntegration with other Java concepts/services
● Enterprise Java Beans (EJB): asynchronous beans vs.synchronous beans
● Java Database Connectivity (JDBC) for databaseintegration
● Java Transaction Service (JTS) for messages as part ofdistributed transactions
● Java Naming and Directory Intf (JNDI) for object lookupAPI can be downloaded: package javax.jms
![Page 60: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/60.jpg)
JMS Event Model General-purpose messages which require
explicit marshalling Message body can contain
StreamPropertiesStringObjectBytes
Additional attributesMessage header: explicit messagingMessage properties: for content-based filtering
![Page 61: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/61.jpg)
Message Attributes Message header
Assigned by service upon send● Destination● Delivery mode (PERSISTENT,
NON_PERSISTENT)● Message ID● Timestamp● Priority● Expiration
Provided by client● Correlation ID, e.g., refer to
other message● Type● Reply destination
…
Message propertiesName-to-value properties
provided by message producerProperty types (native Java
types)● boolean● byte● short● int● long● float● double● String
Note: attributes mapped toproperties, encapsulation…!
![Page 62: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/62.jpg)
Properties for Content-Based Properties of messages are assigned
explicitlyNot java.util.Properties
Subscriber describes required propertiesMessage selector = filterSubscription language: message selector is StringSyntax specified by JMSMust be mapped to service provider’s subscription language
syntax
E.g., "JMSType = ‘car’ AND color = ‘blue’ AND weight > 2500"
![Page 63: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/63.jpg)
Common Facilities Destination
Named object (topic, queue) obtained through JNDI: empty interface
ConnectionFactoryObtained through JNDI, used to create Connection to a topic, queue:
empty
ConnectionMay require authenticationRegister ExceptionListener for problem detectionFactory for Session
SessionRequired by client (producer/consumer) to interact with topic, queueCreates MessageProducer (push), MessageConsumer (push/pull)Single threaded. Transaction support, unacknowledged messages, order,
…
![Page 64: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/64.jpg)
Connectionspublic interface Connection {
public String getClientID() throws JMSException;
public void setClientID(String ID) throws …;
public void setExceptionListener(ExceptionListener l)throws …;
public ExceptionListener getExceptionListener() throws…;
public void close() throws …;
public start() throws …;
public stop() throws …;
…/* (Sessions created through implementation classes) */
}
![Page 65: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/65.jpg)
Sessionspublic interface Session {
public void setMessageListener(MessageListener l) throws…;
public MessageListener getMessageListener() throws …;
public TextMessage createTextMessage() throws …;
public StreamMessage createStreamMessage() throws …;
…
public void close() throws …;
public void recover() throws …;public void commit() throws …;
public void rollback() throws …;
…
}
![Page 66: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/66.jpg)
Message Producerspublic interface MessageProducer {
public void setDeliveryMode(int deliveryMode) throws …;
public int getDeliveryMode() throws …;
public void setPriority(int defaultPriority) throws …;
public int getPriority() throws …;
public void setTimeToLive(long ttl) throws …;
public long getTimeToLive() throws …;
…
}
![Page 67: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/67.jpg)
Message Consumerspublic interface MessageConsumer {
/* Provide content-based filter */
public String getMessageSelector() throws …;
/* Push model */
public void setMessageListener(MessageListener l) throws…;
public MessageListener getMessageListener() throws …;
/* Poll */
public Message receive() throws …;/* Blocking pull */
public Message receive(long timeout) throws …;
…
}
![Page 68: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/68.jpg)
Point-To-Point (PTP) Objects
Queue represents a vendor-specific implementationTemporaryQueue is a temporary incarnation, bound to aQueueConnection
Created through a QueueConnectionFactoryQueueSession, QueueReceiver (message consumer:
push/pull), QueueSender (message producer)QueueBrowser to query queue without removing messages
… Note
Message selector can be specified by consumer
![Page 69: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/69.jpg)
Queuepublic interface Queue {
public String getQueueName() throws …;
public String toString() throws …;}
public interface QueueBrowser {
public Enumeration getEnumeration() throws …;
public String getMessageSelector() throws …;
public String getQueue() throws …;
…}
![Page 70: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/70.jpg)
Publish/Subscribe Objects
Topic gives access to pub/sub system: no naming conventionsTemporaryTopic, TopicConnectionFactory, TopicConnection,TopicSession, as seen previously
TopicSubscriber (message consumer) and TopicPublisher(producer)
Durable subscriptionClient provides unique ID
TopicRequestorUse pub/sub to make request/replies
Mixed topic/content-basedClient provides a message selector
![Page 71: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/71.jpg)
Topicpublic interface Topic {
public String getTopicName() throws …;
public String toString() throws …;
}
public class TopicRequestor {
public TopicRequestor(TopicSession session, Topic topic)
throws … {…}
public Message request(Message message) throws … {…}
…
}
![Page 72: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/72.jpg)
JMS Exceptions JMSException
Checked exceptionRoot of exception hierarchy
Specific exceptionsJMSSecurityException: authentication problemInvalidDestination: destination not understood by
providerInvalidSelectorException: « syntax error » in filterMessageFormatException: e.g., unsupported payload
class …
![Page 73: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/73.jpg)
Publish/Subscribe
CORBA Event & NotificationServices
![Page 74: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/74.jpg)
Overview Untyped events
The effective events are of type org.omg.CORBA.Any
Typed eventsOneway proxy
Structured eventsStarting from Notification ServiceSemi-typed eventsSet of predefined self-describing messages
![Page 75: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/75.jpg)
Event Service Event Channel abstraction
Event channel is CORBA objectSubscriber is called ConsumerPublisher is called Supplier
Information
![Page 76: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/76.jpg)
Event channel appears as Supplier for consumers Consumer for suppliers
Different interaction styles Between consumers and channel Suppliers and channel
Guarantees Not necessarily FIFO Best-effort QoS only with Notification Service
![Page 77: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/77.jpg)
Styles Usual: push model
Special: pull model
![Page 78: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/78.jpg)
Supplier / Consumer IDLmodule CosEventComm {
exception Disconnected {};
…
interface PushConsumer { void push(in any data) raises (Disconnected);
void disconnect_push_consumer(); };
interface PushSupplier { void disconnect_push_supplier(); };
interface PullConsumer { void disconnect_consumer(); };interface PullSupplier { any pull() raises (Disconnected);
any try_pull(out boolean has_event) raises(Disconnected);
void disconnect_pull_supplier(); };
};
![Page 79: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/79.jpg)
Setup Channel creation (vendor-specific)
Usually manually, suppliers and consumers connect Certain implementations provide in-process channels
Supplier connection exampleGet a supplier admin for the channelGet a proxy push / pull consumer (subtype of push / pull
consumer) from the supplier adminConnect to proxy consumer
Consumer connection exampleGet a consumer admin for the channelGet a proxy push / pull supplier (subtype of push / pull
supplier) from the consumer adminConnect to proxy supplier
![Page 80: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/80.jpg)
Admin IDLmodule CosEventChannelAdmin {…interface ConsumerAdmin { ProxyPushSupplier obtain_push_supplier(); ProxyPullSupplier obtain_pull_supplier(); };interface SupplierAdmin { ProxyPushConsumer obtain_push_consumer(); ProxyPullConsumer obtain_pull_consumer(); };interface EventChannel { ConsumerAdmin for_consumers(); SupplierAdmin for_suppliers(); void destroy(); };
};
![Page 81: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/81.jpg)
Notification Service QoS New proxies
For structured events, e.g.,StructuredProxyPushConsumer
For sequences of structured events, e.g.,SequenceProxyPullSupplier
Filtering And many more, e.g.,
Event type repositoryTransactions
![Page 82: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/82.jpg)
QoS Represented through PolicySeq
module CosNotification {
typedef string PolicyName;
typedef any PolicyValue;
struct Policy {
PolicyName name;
PolicyValue value;
};
typedef sequence<Policy> PolicySeq;
…
};
Set at different levels, e.g., channel, admin,proxy
![Page 83: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/83.jpg)
Policies Reliability policy
EventReliability, ConnectionReliability: best-effort orpersistent● best-effort & best-effort: no reliability● best-effort & persistent: automatic reconnect after recovery● persistent & persistent: « reliable »
Order policyAnyOrder, FIFOOrder, PriorityOrder, DeadlineOrder
Discard policy For sequences: batch size, pacing interval
![Page 84: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/84.jpg)
Structured Events
struct EventType { string type_name;
string domain_name;};
struct FixedEventHeader { EventType event_type;
string event_name;};
…};
struct EventHeader {
FixedEventHeader fixed_header;
OptionalHeaderField var_fields;
};
struct StructuredEvent {
EventHeader header;
FilterableEventBody filterable;
any remainder_of_body;
};
module CosNotification {
typedef PolicySeq OptionalHeaderFields;typedef PolicySeq FilterableEventBody;
![Page 85: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/85.jpg)
Filtering Header fields
EventReliability, Priority, StartTime, StopTime, Timeout
Filterable fieldsSimilar to JMS, fields as propertiesNotification Service suggests « standard » structured types
Two types of filtersFilter: affect event forwarding by proxiesMappingFilter: affect event handling with respect to QoSBoth queried through match(), match_structured( ,match_typed() methods
![Page 86: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/86.jpg)
Filter expressionBased on Default Filter Constraint LanguageAn extension of the Trader Constraint Language (cf. Trading
Service)E.g.,
● $type_name == `CommunicationAlarm´ and $priority < 2
● $.value1 > $.value2
● exists $.howIsBob
Note● $type_name is abbreviation for$header.fixed_header.event_type.type_name
![Page 87: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/87.jpg)
Typed EventsOneway proxy approach
E.g.,interface Bob {
void say_hi(in String say);
};
Yields for instance the following interface for a pullconsumer
interface PullBob {
void say_hi(out String say);
boolean try_say_hi(out String say);
};
![Page 88: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/88.jpg)
Publish/Subscribe
Generic DistributedAsynchronous Collections
(GDACs)
![Page 89: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/89.jpg)
Distributed Asynchr. Collections Collections
Intuitive by reusing well-known collection abstractionCollection subtypes enable the expression of
● Different interaction styles, e.g., DAQueues for queuing● Different QoS, e.g., DAList has order, DASet is reliable
Distributed● Essentially distributed, unlike JavaSpaces, JGL, …
AsynchronousCallback mechanism: publish/subscribe
![Page 90: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/90.jpg)
Characteristics of DACsCollection Storage order
DeterministicNone
Duplicates Insertion order
Explicit Implicit
Extraction order
DACollection Delivery order Delivery semantics
UnreliableReliableCertified
DuplicatesElementsDelivery
Extraction order: pull
![Page 91: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/91.jpg)
DAC Framework Java DACs
Extension of java.util collectionspublic interface DACollection
extends java.util.Collection {
public boolean add(Object o);
public boolean contains(Object o);
public Object get();
…
}
![Page 92: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/92.jpg)
DAC Interfaces Callback interface
public interface Notifiable { public void notify(Object m, String DACName);}
Subscribe (all-of-n)Without subtopics: contains(Notifiable n);With subtopics: containsAll(Notifiable n);
Subscribe (one-of-n)Without subtopics: remove(Notifiable n);With subtopics: removeAll(Notifiable n);
![Page 93: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/93.jpg)
Generic DACs DACs for type-based publish/subscribe
Represent collections for a specific element type● Published elements are of that type● Subscribe: all elements received are of that type
Compile-time type checksNo (explicit) runtime type conversions
Obtaining a DAC for type TGenerate a specific DAC type T, e.g., precompiler: TDACParametric polymorphism (genericity)
![Page 94: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/94.jpg)
Callback interfacepublic interface GNotifiable<T> { public void notify(T t);
}
GDAC interfacepublic interface GDAC<T> { public boolean contains(T t);
public boolean add(T t);
public T get();
public boolean contains(GNotifiable<T> n,
GCondition<T> c);
…
}
![Page 95: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/95.jpg)
Programming Example Event class
public class ChatMsg implements java.io.Serializable {
private String sender;
private String text;
public String getSender() { return sender; }
public String getText() { return text; }
public ChatMsg(String sender, String text)
{ this.sender = sender; this.text = text; }
}
![Page 96: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/96.jpg)
« Pure » Type-Based Create a local DAC proxy
GDASet<ChatMsg> myChat = new GDAStrongSet<ChatMsg>();
Insert new objects (publish)myChat.add(new ChatMsg("Bob", "Hi from Bob"));
Advertise interest in new objects(subscribe)public class ChatNot implements GNotifiable<ChatMsg> {
public void notify(ChatMsg m) {
System.out.println(m.getText()); }
}
myChat.contains(new ChatNot());
![Page 97: Asynchronous RPC - ETH Zse.inf.ethz.ch/old/teaching/ss2006/0284/slides/Lecture8.pdf · Remote invocation returns without waiting For termination of the remote method body execution](https://reader031.vdocuments.us/reader031/viewer/2022021906/5bb9f6d509d3f2fd488d2b9b/html5/thumbnails/97.jpg)
With Content-Based Pattern
Accessors: enable the access of some information, e.g.attribute
Conditions: express single conditions on events
E.g., verify if message sender is "Alice"Construct accessor (explicitly) Accessor<ChatMsg> getAlice = new Invoke<ChatMsg>("/getSender", null);
Construct pattern Condition<ChatMsg> fromAlice = new Equals<ChatMsg>(getAlice, "Alice");
Subscribe myChat.contains(new ChatNot(), fromAlice);