Advertisement
Advertisement

More Related Content

More from Fwdays(20)

Advertisement

"Making tomorrow's code look like today's", Adam Ralph

  1. SUM=90
  2. BATCH JOB
  3. WITH ct AS ( SELECT id = cid, total = SUM(value) FROM orders WHERE date > … GROUP BY cid ) UPDATE c SET c.Discount = 10 FROM customers AS c INNER JOIN ct ON c.id = ct.id WHERE ct.total > …; USE tempdb; GO DECLARE @x TABLE (ID int, Value int); DECLARE @y TABLE (ID int, Value int); INSERT @x VALUES (1, 10), (2, 20); INSERT @y VALUES (1, 100),(2, 200); WITH cte AS (SELECT * FROM @x) UPDATE cte -- cte is not referenced by the alias. SET Value = y.Value FROM cte AS x -- cte is assigned an alias. INNER JOIN @y AS y ON y.ID = x.ID; SELECT * FROM @x; GO USE tempdb; GO -- UPDATE statement with CTE references that are correctly matched. DECLARE @x TABLE (ID int, Value int); DECLARE @y TABLE (ID int, Value int); INSERT @x VALUES (1, 10), (2, 20); INSERT @y VALUES (1, 100),(2, 200); WITH cte AS (SELECT * FROM @x) UPDATE x -- cte is referenced by the alias. SET Value = y.Value FROM cte AS x -- cte is assigned an alias. INNER JOIN @y AS y ON y.ID = x.ID; SELECT * FROM @x; GO USE AdventureWorks2012; GO IF OBJECT_ID ('dbo.Table1', 'U') IS NOT NULL DROP TABLE dbo.Table1; GO IF OBJECT_ID ('dbo.Table2', 'U') IS NOT NULL DROP TABLE dbo.Table2; GO CREATE TABLE dbo.Table1 (c1 int PRIMARY KEY NOT NULL, c2 int NOT NULL); GO CREATE TABLE dbo.Table2 (d1 int PRIMARY KEY NOT NULL, d2 int NOT NULL); GO INSERT INTO dbo.Table1 VALUES (1, 10); INSERT INTO dbo.Table2 VALUES (1, 20), (2, 30); GO DECLARE abc CURSOR LOCAL FOR SELECT c1, c2 FROM dbo.Table1; OPEN abc;
  4. 1 week Sum(o => o.Total) t
  5. += o1.Total -= o1.Total 1 week += o2.Total -= o2.Total 1 week += o3.Total -= o3.Total 1 week WeekTotal WeekTotal t
  6. SAGA docs.particular.net/nservicebus/sagas/
  7. += o1.Total -= o1.Total 1 week += o2.Total -= o2.Total 1 week += o3.Total -= o3.Total 1 week WeekTotal WeekTotal t
  8. SHOW ME THE CODE
  9. DB BUS SAGA class Discounting : Saga<Discounting.Data> { public async Task Handle( SubmitOrder order) { ... } ... } Persist er dispatch message queue request timeout persist timeout delay persist saga poll
  10. AMAZON SQS 600 s 900 2,800 s 100 s 900 900 (1,900) (1,000) (100)
  11. RABBITMQ 600 s 900 s 1,500 s 2,800 s
  12. RABBITMQ
  13. RABBITMQ 42 seconds 1010102 seconds 4210 seconds
  14. RABBITMQ 1 1 0 0 1 0 32 s 16 s 8 s 4 s 2 s 1 s (4210)
  15. RABBITMQ 28 queues 228 seconds 268,435,456 seconds 8.5 years
  16. WT=90
  17. DB queue BUS SAGA class OrderProcessPolicy : Saga<OrderProcess> { public async Task Handle(SubmitOrder order) { // ... } public async Task Handle(Cancel { // .. } public async Task Timeout(BuyersRemorse state) { // ... } } Persi ster create saga dispatch message send messages persist saga BUS SAGA class OrderProcessPolicy : Saga<OrderProcess> { public async Task Handle(SubmitOrder order) { // ... } public async Task Handle(Cancel { // .. } public async Task Timeout(BuyersRemorse state) { // ... } } Persi ster create saga dispatch message send messages persist saga persist saga CustomerId = 1337 persist saga CustomerId = 1337 message(s) sent message(s) not sent message(s) sent
  18. BATCH JOB particular.net/blog/death-to-the-batch-job
  19. Automated pattern matching Daily reports saga notification business events
  20. go.particular.net/netfwdays
  21. go.particular.net/ netfwdays CODE THE FUTURE, NOW
Advertisement