Andrew Cooke | Contents | Latest | RSS | Previous | Next

C[omp]ute

Welcome to my blog, which was once a mailing list of the same name and is still generated by mail. Please reply via the "comment" links.

Always interested in offers/projects/new ideas. Eclectic experience in fields like: numerical computing; Python web; Java enterprise; functional languages; GPGPU; SQL databases; etc. Based in Santiago, Chile; telecommute worldwide. CV; email.

Personal Projects

Choochoo Training Diary

Last 100 entries

Surprise Paradox; [Books] Good Author List; [Computing] Efficient queries with grouping in Postgres; [Computing] Automatic Wake (Linux); [Computing] AWS CDK Aspects in Go; [Bike] Adidas Gravel Shoes; [Computing, Horror] Biological Chips; [Books] Weird Lit Recs; [Covid] Extended SIR Models; [Art] York-based Printmaker; [Physics] Quantum Transitions are not Instantaneous; [Computing] AI and Drum Machines; [Computing] Probabilities, Stopping Times, Martingales; bpftrace Intro Article; [Computing] Starlab Systems - Linux Laptops; [Computing] Extended Berkeley Packet Filter; [Green] Mainspring Linear Generator; Better Approach; Rummikub Solver; Chilean Poetry; Felicitations - Empowerment Grant; [Bike] Fixing Spyre Brakes (That Need Constant Adjustment); [Computing, Music] Raspberry Pi Media (Audio) Streamer; [Computing] Amazing Hack To Embed DSL In Python; [Bike] Ruta Del Condor (El Alfalfal); [Bike] Estimating Power On Climbs; [Computing] Applying Azure B2C Authentication To Function Apps; [Bike] Gearing On The Back Of An Envelope; [Computing] Okular and Postscript in OpenSuse; There's a fix!; [Computing] Fail2Ban on OpenSuse Leap 15.3 (NFTables); [Cycling, Computing] Power Calculation and Brakes; [Hardware, Computing] Amazing Pockit Computer; Bullying; How I Am - 3 Years Post Accident, 8+ Years With MS; [USA Politics] In America's Uncivil War Republicans Are The Aggressors; [Programming] Selenium and Python; Better Walking Data; [Bike] How Fast Before Walking More Efficient Than Cycling?; [COVID] Coronavirus And Cycling; [Programming] Docker on OpenSuse; Cadence v Speed; [Bike] Gearing For Real Cyclists; [Programming] React plotting - visx; [Programming] React Leaflet; AliExpress Independent Sellers; Applebaum - Twilight of Democracy; [Politics] Back + US Elections; [Programming,Exercise] Simple Timer Script; [News] 2019: The year revolt went global; [Politics] The world's most-surveilled cities; [Bike] Hope Freehub; [Restaurant] Mama Chau's (Chinese, Providencia); [Politics] Brexit Podcast; [Diary] Pneumonia; [Politics] Britain's Reichstag Fire moment; install cairo; [Programming] GCC Sanitizer Flags; [GPU, Programming] Per-Thread Program Counters; My Bike Accident - Looking Back One Year; [Python] Geographic heights are incredibly easy!; [Cooking] Cookie Recipe; Efficient, Simple, Directed Maximisation of Noisy Function; And for argparse; Bash Completion in Python; [Computing] Configuring Github Jekyll Locally; [Maths, Link] The Napkin Project; You can Masquerade in Firewalld; [Bike] Servicing Budget (Spring) Forks; [Crypto] CIA Internet Comms Failure; [Python] Cute Rate Limiting API; [Causality] Judea Pearl Lecture; [Security, Computing] Chinese Hardware Hack Of Supermicro Boards; SQLAlchemy Joined Table Inheritance and Delete Cascade; [Translation] The Club; [Computing] Super Potato Bruh; [Computing] Extending Jupyter; Further HRM Details; [Computing, Bike] Activities in ch2; [Books, Link] Modern Japanese Lit; What ended up there; [Link, Book] Logic Book; Update - Garmin Express / Connect; Garmin Forerunner 35 v 230; [Link, Politics, Internet] Government Trolls; [Link, Politics] Why identity politics benefits the right more than the left; SSH Forwarding; A Specification For Repeating Events; A Fight for the Soul of Science; [Science, Book, Link] Lost In Math; OpenSuse Leap 15 Network Fixes; Update; [Book] Galileo's Middle Finger; [Bike] Chinese Carbon Rims; [Bike] Servicing Shimano XT Front Hub HB-M8010; [Bike] Aliexpress Cycling Tops; [Computing] Change to ssh handling of multiple identities?; [Bike] Endura Hummvee Lite II; [Computing] Marble Based Logic; [Link, Politics] Sanity Check For Nuclear Launch; [Link, Science] Entropy and Life

© 2006-2017 Andrew Cooke (site) / post authors (content).

HowTo Make POJO Workflows

From: "andrew cooke" <andrew@...>

Date: Tue, 16 Jan 2007 11:44:16 -0300 (CLST)

I think I just solved the POJO workflow problem.  I'm not sure this works
(in particular, I'm not sure how it would interact with transactions), but
if it does it would be amazingly sweet.

OK, so the problem is that if you're doing lightweight SOA, you write
services as POJOs.  That's fine for "one shot" services that have no
persistent state between messages, but doesn't work so well for services
that need to maintain conversational state - typically these are composite
services (orchestrators) which call one service ("synchronously") and then
another.

The root of the problem is the "synchronous" call.  This can be
constructed from asynchronous messaging using "replyTo" in an envelope -
no problem there - but the replyTo identifies an *instance*.  So if the
instance dies while the call is being made, the return value has nowhere
to go.

And the obvious solution is to explicitly store state before calls and use
some kind of index to retrieve state for the response.  But this requires
(as far as I can tell, until now) explicit management of state inside the
POJO, or the use of a separate workflow (eg. BPEL engine).

The alternative is to somehow convert a POJO so that it stores state
transparently.  How to do this has not been clear 'til now, although it's
pretty obvious that continuations would be a component.

So.  Here's the trick.  You wrap the *called* service (typically injected
via Spring) in a dynamic proxy which preserves the interface but, when
called:
- triggers a new thread to continue with processing in the injected class
(which is presumably an adapter to call messaging).
- constructs a continuation in the old thread and then throws a runtime
exception (is this exception necessary?  perhaps the wrapper simply stores
the continuation?)

The composite service is itself wrapped in a dynamic proxy which catches
the exception raised at the bean's entry point.

When the response comes back to the wrapper around the called service it
collaborates with the wrapper around the caller bean (or if the exception
is not necessary, simply retrieves the continuation itself) to restart the
process.

Obviously a lot of details need still to be worked out :o)

But the hard part has always been, until now, how to get the continuation
in the right place.  This was hard because I was looking at the composite
service.  What is new here is the idea that you have a wrapper around the
target service (or rather, its messaging adapter).

For background on the problem see http://www.acooke.org/cute/NotesonSta0.html

Andrew

Porqi - the POJO POrquestrator

From: "andrew cooke" <andrew@...>

Date: Sun, 21 Jan 2007 19:45:59 -0300 (CLST)

I've started work on a small library to implement this.  It assumes Spring
and uses factories and dynamic proxies to wrap POJOs.

So far I have the basic framework - the wrapper factories - almost
complete.  Next I need to add a strategy for a particular continuation
library that will be responsible for managing threads, state etc.  The
first implementation will do nothing, of course, but will allow testing. 
The persistence will be a separate pluggable strategy.

The code is pretty cute - it's amazing the level of metaprogramming
possible in pure Java (well, not so pure with the continuation libraries).

Andrew

Asynchronous Java

From: "andrew cooke" <andrew@...>

Date: Tue, 30 Jan 2007 08:27:19 -0300 (CLST)

This works - at least, I've just got some test cases running with a
library that converts Java from sychronous to asynchronous calls.  I don't
yet have the stored state, but that should be a small amount of additional
work (the architecture is modular - I just need continuations based thread
manager).

Here's the test code.  Depending on whether "Pojo" is injected into
"Composite" via a service method or not (ie one specified in the
interface) it is called either synchronously or asynchronously.

  public void testSynchronousCall() throws Throwable {
    assertEquals(1, service.callCount(Target.COMPONENT));
    assertTrue(service.sameThreadName(Target.COMPONENT));
    assertEquals(3, service.callCount(Target.COMPONENT));
  }

  public void testAsynchronousCall() throws Throwable {
    assertEquals(1, service.callCount(Target.SERVICE));
    assertFalse(service.sameThreadName(Target.SERVICE));
    assertEquals(3, service.callCount(Target.SERVICE));
  }

public interface CompositeIface {
  boolean sameThreadName(Target target);
  int callCount(Target target);
  public void setService(PojoIface service);
}

public interface PojoIface {
  String threadName();
  int callCount();
}

Andrew

Comment on this post