Distributed Programming in Java - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Distributed Programming in Java

Description:

set up a sequence of business activities to process the ... Topic-Based Subscription. Topics are names of events ... Subscription lists should be persistent ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 34
Provided by: protonScs
Category:

less

Transcript and Presenter's Notes

Title: Distributed Programming in Java


1
Distributed Programming in Java
  • Web Services (6)

2
Business 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

4
Product Order Process
5
setup
  • Creates the sequence of activities

6
setData
  • Bootstraps the common data pool

7
createProductOrder
  • Creates a process order, and kicks off a sequence
    of business activities

8
processOrder
  • Processes an order by executing business
    activities in sequence as defined

9
Publish-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)

10
Motivation
  • 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

11
Topic-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
12
Publish-Subscribe
13
Participants (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

14
Participants (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

15
Participants (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

16
Dynamics
17
Design 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

18
EventService
19
EventService
20
service.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

21
Subscriber
  • Create a subscriber web service, register it
    for the ProductOrderUpdate topic

22
Subscriber
  • It uses the EventServiceLocator which was
    generated from the WSDL file

23
Generating 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
24
Stub 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
25
Publisher
  • Publisher does not implement a service

26
Physical 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)
28
Problem 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?

29
Faux 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)
31
Faux Implementation
32
(No Transcript)
33
References
  • 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
Write a Comment
User Comments (0)
About PowerShow.com