QQQ Bounces back …

As expected, the good economic news has pushed the market across the board higher today. QQQ closed at 35.34. The volume is higher, but not very high. The resistence is now 36 and support is 34. Interestingly, the intraday high was right below the SMA20, which acted as the resistence at current level. The market is still weak, we shall see if the 34 is the intermediate bottom.

QQQ

QQQ moves up a little, but it needs to take out 35 to reverse the slide started two months ago. If the rotation of big money out of tech stocks has come to an end, it may go sideway for a while. Any good news probably will invite some to jump back in the market. Anyway, it has to hold the 34 support level firm, next support is at 32.5.

COM+ like Transactions

I’m implementing a component that offers COM+ like programming model on local transaction on a single database. You will be able to decorate a class using attribute like [Transactional(TransactionOption, TransactionIsolation)]. Inside each method, SetComplete or SetAbort will vote to commit or rollback the transactions. It will support nested transactions on a single thread.

The motivation is to ease business component development that needs flexible transaction management when component reuse is important. Here’s a sample test case.

[Transactional(TransactionOption.Required, TransactionIsolation.Standard)]
public class Account : Transactional {
	public Account() : base() {
	}

	public void Debt(string account, decimal amount) {
		try {
			// make database calls in adapter via ADO.NET
			Auditor auditor = new Auditor();
			DA.PostDebt(account, amount);
			auditor.Log("post debt trx");

			TransactionUtil.SetComplete();
		}
		catch (Exception ex) {
			auditor.Log("error in posting debt trx");
			TransactionUtil.SetAbort();
		}
	}

	public void Credit(string account, decimal amount) {
		try {
			// make database calls in adapter via ADO.NET
			DA.PostCredit(account, amount);
			Auditor auditor = new Auditor();
			auditor.Log("post credit trx");

			TransactionUtil.SetComplete();
		}
		catch (Exception ex) {
			auditor.Log("error in posting debt trx");
			TransactionUtil.SetAbort();
		}
	}
}

[Transactional(TransactionOption.RequiresNew, TransactionIsolation.Standard)]
public class TransferAgent : Transactional {
	public TransferAgent() : base() {
	}
	public void Transfer(string from, string to, decimal amount) {
		try {
			Auditor auditor = new Auditor();
			auditor.Log("validating balance in " + from);

			Validator v = new Validator();
			v.Validate(from, amount);
			auditor.Log(from + " balance checked OK");

			Account account = new Account();
			account.Debt(from, amount);
			account.Credit(to, amount);

			TransactionUtil.SetComplete();
			auditor.Log("transfer OK");
		}
		catch (Exception ex) {
			auditor.Log("error in transfer");
			TransactionUtil.SetAbort();
		}
	}
}

[Transactional(TransactionOption.RequiresNew, TransactionIsolation.Standard)]
public class Auditor : Transactional {
	public Auditor() : base() {
	}

	public void Log(string msg) {
		try {
			DA.Log(msg);
			TransactionUtil.SetComplete();
		}
		catch (Exception ex) {
			TransactionUtil.SetAbort();
		}
	}
}

[Transactional(TransactionOption.Supported, TransactionIsolation.Standard)]
public class Validator : Transactional {
	public Validator() : base() {
	}

	public void Validate(string account, decimal balance) {
		try {
			if (DA.CheckBalance(account, balance))
				TransactionUtil.SetComplete();
			else
				TransactionUtil.SetAbort();
		}
		catch (Exception ex) {
			TransactionUtil.SetAbort();
		}
	}
}

[TestFixture]
public class UnitTest : UnitTestBase {

	[Test]
	public void Test01() {
		Account account = new Account();
		account.Credit("a", 1000.00);
		account.Debt("a", 100);
		account.Credit("b", 100.00);
	}

	[Test]
	public void Test02() {
		TransferAgent agent = new TransferAgent();
		agent.Transfer("a", "b", 100.00);
	}

}

SUNW

SUNW pasues right at 4-4.5 support area. The selling has slowed down. I think it will rebound from current over sold condition.