Title: Distributed Programming in Java
1Distributed Programming in Java
2Business Process
3- Business activity unit of work
- Business process
- set up a sequence of business activities to
process the order - set up data into the data pool
4Product Order Process
5setup
- Creates the sequence of activities
6setData
- Bootstraps the common data pool
7createProductOrder
- Creates a process order, and kicks off a sequence
of business activities
8processOrder
- Processes an order by executing business
activities in sequence as defined
9Publish-Subscribe
- Stand-alone event service that receives and
distributes events to other services - For example, if we use an asynchronous business
process we would want to notify a Customer on
completing their order - Service forwards published events to subscribers
without requiring subscribers to be aware of
publishers (as in Observer)
10Motivation
- A single event mechanism instead of writing many
specific ones - A situation where we cannot anticipate all
publishers of events - Addresses needs by centralizing event
distribution in a generic mechanism - Mechanism can be thoroughly tested
11Topic-Based Subscription
- Topics are names of events
- Events identified by topics do not need to follow
a particular interface - We dont even need to know originators
Topic hierarchy
12Publish-Subscribe
13Participants (1)
- Subscriber
- Interface that event service calls to notify a
client about an event it subscribed for - May register for multiple types of events
- SubscriberImpl
- Subscriber web service with a distinct URL for
sending update messages
14Participants (2)
- EventService
- Subscribers can subscribe to events
- Publishers can publish events, and events and
data will be forwarded to subs - EventServiceImpl
- Maintains subscriber lists and event types for
which a subscriber registers - Determines which subscribes to notify
15Participants (3)
- PublisherImpl
- Assembles information that subscribers expect to
see, which is an implicit contract between
subscribers and publishers - Delivers event type and associated data to the
event service for distribution - Loosely coupled when subscribers register for
event types they do not need to care how
publishers deliver events
16Dynamics
17Design Considerations
- Subscription lists should be persistent
- Event service can become a bottleneck between
publishers and subscribers - Event data structure and topic should be
considered part of the contract - between publishers and subscribers
- so subscribers can be programmed against stable
assumptions
18EventService
19EventService
20service.getSubscriber
- service.getSubscriber() returns a stub to the
Subscriber service we want to notify - Can specify a different URL than the default by
invoking getSubscriber(URL) directly
21Subscriber
- Create a subscriber web service, register it
for the ProductOrderUpdate topic
22Subscriber
- It uses the EventServiceLocator which was
generated from the WSDL file
23Generating the WSDL
- These commands generate the WSDL files
!/bin/sh java org.apache.axis.wsdl.Java2WSDL
\ -o "com/servicefoundry/books/webservices/eventse
rvice/Subscriber.wsdl" \ -l "http//localhost9090
/axis/services/Subscriber" \ -n "urnPubSub"
\ -p"com.servicefoundry.books.webservices.eventser
vice.stubs" "urnPubSub" \ com.servicefoundry.book
s.webservices.eventservice.Subscriber java
org.apache.axis.wsdl.Java2WSDL \ -o
"com/servicefoundry/books/webservices/eventservice
/EventService.wsdl" \ -l "http//localhost9090/ax
is/services/EventService" \ -n "urnPubSub"
\ -p"com.servicefoundry.books.webservices.eventser
vice.stubs" "urnPubSub" \ com.servicefoundry.book
s.webservices.eventservice.EventService
24Stub Generation
- Generate the stubs from the WSDL
- These commands create the EventService stub in
the ....stubs package
!/bin/sh java org.apache.axis.wsdl.WSDL2Java -o
. \ -NurnPubSub com.servicefoundry.books.webservi
ces.eventservice.stubs \ com/servicefoundry/books/
webservices/eventservice/Subscriber.wsdl java
org.apache.axis.wsdl.WSDL2Java -o .
\ -NurnPubSub com.servicefoundry.books.webservice
s.eventservice.stubs \ com/servicefoundry/books/we
bservices/eventservice/EventService.wsdl
25Publisher
- Publisher does not implement a service
26Physical Tiers
- Subscriber should not execute lengthy business
logic in the Axis container - Inefficient use of connection pooling,
persistence layer, etc. - Implement the logic in another physical tier and
talk to it using a Connector - Example connector is RMI
27(No Transcript)
28Problem with Publisher/Subscriber
- Client must provide a web service itself to be
able to receive notification from another web
service - Standalone application is not bundled with an
integrated full-blown web service engine - How can a standalone client application receive
notification?
29Faux Implementation
- Requiring subscribers to run an Axis engine is
too heavy-weight a solution - Instead, clients can use a simple solution to
receive callbacks, which amounts to implementing
your own SOAP processing - However, you dont want to affect the service
invoker (eg EventService) in any way - Thus, you make it look like the real thing
- Use a class that executes in a separate thread
and is waiting for incoming socket connection
with SOAP messages
30(No Transcript)
31Faux Implementation
32(No Transcript)
33References
- In todays lecture we covered in detail
- Chapter 12, Publish-Subscribe
- And briefly discussed
- Chapter 13, Physical Tiers
- Chapter 14, Faux Implementation
- This gives us an overview of most of the patterns
documented in PM