Skip to main content

Notes from Wednesday at Jazoon

Posted by haroldcarr on June 24, 2009 at 10:11 AM PDT

Here are my notes from the Wednesday at
jazoon.com

==============================================================================
Wednesday June 24, 2009

------------------------------------------------------------------------------
Web Services and Transactions
Jonathan Halliday, JBoss (TX lead at JBoss)

A transaction is
- set of activities that require some shared properties
- consensus of outcome
- short: ACID
- longer: relaxation of some properities

Distributed TX
- involve two or more systems
- require agreement on protocol
- may span organizational boundaries

Web service may be used in different ways
- Same administrative domain
- Fast network
- same role as CORBA

WS-Atomic TX: ACID TX for Web Services
- JTA behavior
- Suits closely coupled environments
- short duration TX due to locking model
- begin / commit/ ROLLBACK

WS-AT specifies the wire protocol only
- No standard Java API (yet)

Using WS-AT on client side (JBoss)

  tx = factory.userTX();
  tx.begin();
  service.method(param);
  ...
  tx.commit();
  or
  tx.rollback();

Server side APIs

txmgr = factory.txMgr();
txtmgr.enlistForVolatileTwoPhase(myVolatileParticipant);
txtmgr.enlistForVolatileTwoPhase(myDurableParticipant);
txmgr.suspend();
txmgr.resume();

Participants

Users must implement not only business logic, but the TX event
handling logic too.

interface Participant {
  public Vote prepare();
  public Vote commit();
  public Vote rollback();
}

Using WS-AT is hard

JEE containers provide lots of abstraction on top of JTA
- business programmers hardly ever implement XARResource
- or even call begin/commit/rollback thanks to EJB3
 
TX Bridging
- Existing JEE code understands JTA TX
- WS understand WS-AT TX
- Interop and reuse improved by linking these domains
  WS can use existing XA aware resource mgrs
  JEE code can call TX web services

TXBRIDGE does
- interoposition plus protocol adapter
- bi-directional
- near invisible to app - just add standard annotation
- provides XAResource / Participant

TX Bridging

@Stateless
@Remote(Bistro.class)
@WebService()
@SOAPBinding(style = SOAPBinding.Sytle.RPC)
@HandlerChain(file = jboss bridge)
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class BistroImpl implements Bistro {
...
}

[ HC NOTE: Metro has done this for years, without the need
  for the HandlerChain ]

[ HC NOTE: Why Style.RPC ? ]

Business Activities
Relax ACID properities
- locking won't work
- use compensations instead
- reduced isolation of TX
- per-application undo behavior
- WS-BusinessActivity

WS-BA events
- begin()
- complete() - presist changes, log compensation data
- close() - clean up, discard logs
- cancel() - discard changes
- compensate() - undo previously completed changes

WS-BA client side

tx = factory.userBusinessActivity()
tx.begin();
...
tx.close()
or
tx.cancel();

WS-BA server side

mgr = factory.businessActivityManager();
mgr.enlistForBusinessAgreementWithCoordinatorCompletion(p);
mgr.enlistForBusinessAgreementWithParticipantCompletion(p);
mgr.suspend()
mgr.resume()

WS-BA participants

programmer must implement:

interface Participant {
  close()
  cancel();
  compensate();
  complete();
}

BA Framework to make above easier

- compensation are application specific
- framework has annotations
  ideas from EJB3, JSR-181
  @CompensatedBy()

BA Framework
- TX plumbing
  serialization, concurrency, locking, versioning, crash recovery
  business logic does not respond directly to tx control events
    or Participant interface
- separate business logic from tx mgmt as much as possible
  but compesation belong on business side
- declarative approach

BA Framework via annotations

@BACompensatedBy("cancelRoom")
public int bookRoom() {...}
public int cancelRoom() {...}

optional annotations

@BACompensatedBy("cancelRoom")
@BAResult("reservationNumber")
public int bookRoom(@BAParam("clientID") String client) {...}
public int cancelRoom(
   @BAParam("clientID" String who,
   @BAParam("reservationNumber") int id)
{...}

RESTful TX
- Model the TX coordinator and participants as resources
- TX context propagation STANDARD IS ALSO REQUIRED

Experiments

TX Coordinator
- POST .../transaction-coordinator/begin
- PUT .../transaction-coordinator/<id>/commit
- GET .../transaction-coordinator/active

JAX-RS version
@PUT
@Path("transaction-coordinator/{id}/commit")
public Response commitTransaction(....

RESTful TX Participants

Enlist a participant in a TX
- PUT  Tx id
  body identifies the participant URL
Operations on participants
- GET   ... status
- POST  ... prepare

JBoss only proprietary spec - no interoperability

Summary
- TX useful for structuring data manipulations
- ACID not suitable for all cases
  Use lock-free forward compensating model
- WS-AT (ACID) and WS-BA (compensating) standards
- Ease of use requires going beyond the standards
  JBoss TX Bridging framework
- JBoss Proprietary REST versions - no standards

JSR 156
- standard API for ACID (reuse JTA)
- standard API for long running TX

Question: what happens if compensation fails.
Answer: best effort then send data to an administrator

Question: does't Metro already do EJB annotations and WS-AT?
Answer: Yes.  But JSR-181 does not require it (but probably should)

------------------------------------------------------------------------------
Next Gen Wikis
Vincent Massol, XWiki SAS

Wiki 1.0 - unstructured

Wiki 2.0 - custom structured data, apps (blog, calendar), mashup
  Use for applications too small to devote programming team
  or a fast turnaround time (i.e., excel of the web)

Demo: create Wiki-based app to request vacation days

Future
- P2P and Offline Wikis
  concerto.xwiki.org
- real tim collaboration
- annotations - comment on portion of text
- mobile wiki
- semantic wiki
- ide-like dev tools in the wiki
- more social features
- merge of CMS and Wikis

------------------------------------------------------------------------------
Binding Java Objects to Web 3.0
The JenaBean Open Source Library
Taylor Cowan, Travelocity (web portal for Sabre holdings)

thewebsemantic.com
jenabean.googlecode.com
taylor.cown@travelocity.com
geosparlq.appspot.com
  
RDF (triples):
subject         verb          object
travelocity.com aka           travelocity
                isA           oline travel agency
                hasCompetitor expedia

Raw Jena API code is verbose

JenaBeans is more concise object-based model.

write: Bean2RDF
read:  RDF2Bean

@Id specifies a unique field
@Namespace provides a domain
@RdfProperty maps java properties to RDF properties

package examples.com
import thewebsematnti.Id;
public class Person {
  private String email;
  @Id
  public String getEmail() { return email; }
  public void setEmail(String email) { this.email = email; }
}

package examples.com
import thewebsematnti.Id;
import thewebsematnti.Namespace

@Namespace("foo#")
public class Person {
  private String email;
  @Id
  public String getEmail() { return email; }
  public void setEmail(String email) { this.email = email; }
}

@Namespace("foo#")
public class Person {
  private String email;
  private String name;
  @Id
  public String getEmail() { return email; }
  public void setEmail(String email) { this.email = email; }
  @RdfProperty(FOAF.NS + "name")
  public String getName() { return name; }
}

JenaBean Fluent Programming Interface

public static void main(String[] av) {
  Model m = ...;
  new Thing("<TBL foaf>", m)
   .as(Foaf.class).isa(Foaf.Person.class)
   .name("TBL");
   .as (Skos.class)
   .prefLable("TBL", "en")
   ...

------------------------------------------------------------------------------
AdNovum

Motivation - Why do we need industrialization in software engineering
- defined/strict quality
- process, tech mgmt, dependency mgmt, repository, build & test

How to achieve?
- focus on process rather than final product
- establish measuring points
- define consequences if targets not reached
- continuous integration
- PRO: early identification of issues

Measuring points
- dependency and tech mgmt
- config mgmt
- compile checks
- code style checks (e.g., PMD, findbugs, FIXMEs)
- architecture style checks (eg package dependencies)
- unit and integration tests
- test coverage
- load and performance tests

Management
- setup repositories
- metadata collection (dependencies)
- incorporate in continuous integration

Risk-based coverage analysis
- test coverage needs visualization and consequences
- Auto: Cyclomatic Complexity
- Manual: ...
Related Topics >>