---
title: "ODE的实现技术研究（jacob）"
author: "cocogg"
date: "2009-03-09T14:25:22Z"
tags: []
slug: "ode-jacob"
draft: false
lastmod: "2009-03-09T15:12:55Z"
id: 345826
url: "https://cocogg.iteye.com/blog/345826"
---

<span style="color:blue">ODE引擎运行时利用Java并发对象（Java Concurrent Objects，Jacob）来完成过程实例的状态表示和并发性管理。
Jacob提供了应用级的并发机制，它不依赖于线程，这样就降低了系统的开销。

ODE的官方网站提供了一份Jacob的教程，粗略的读了以下，略知一二。
希望有兴趣的朋友一起探讨，或者明白的朋友，不吝赐教。

继续研究中.....</span><http://ode.apache.org/jacob.html>

基本原理
先看一个例子

```java
void process(order) {
  billingService.bill(order.billing);
  shippingService.ship(order.product, order.shipping, self);
  shipping = receive("shipping")
  order.customer.send(shipping.details);
}
```

java 伪代码看起来没什么问题，但是存在缺陷：
1、程序执行过程中出现问题，用户不得不再次发送订单。
2、等待线程过多的时候会导致java虚机down掉。

做如下修改

```java
void process(order) {
  billingService.bill(order.billing);
  shippingService.ship(order.product, order.shipping, self);
  listenOn("shipping", part2);
}
void part2(shipping) {
  order.customer.send(shipping.details);
}
```


看起来会好一些，
but still has a lot of points of failure, where you're not sure if you actually billed the customer and shipped the product or not.