35
WCF SQL SERVER ADAPTER Implementing Polling and Event-Driven Consumers { by Juan I. Arriaga } 1 Twin Cities Connected Systems User Group (Nov.17th, 2011) | eWorldTree.com

WCF SQL SERVER ADAPTER Implementing Polling and Event-Driven Consumers { by Juan I. Arriaga } 1 Twin Cities Connected Systems User Group (Nov.17th, 2011)

Embed Size (px)

Citation preview

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

WCF SQL SERVER ADAPTERImplementing Polling and Event-Driven Consumers { by Juan I. Arriaga }

1

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Agenda• Overview of the WCF SQL Adapter• BizTalk examples• A case study of using the WCF SQL Adapter

outside of BizTalk• Questions & answers

2

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

OVERVIEWWCF SQL SERVER ADAPTER

3

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Classic SQL Adapter vs. WCF SQL Adapter

• The classic SQL adapter does not support SQL Query Notification; the WCF SQL Adapter does.

• For other differences, refer to:

Thiago Almeida’s blog post at http://connectedthoughts.wordpress.com/2011/01/18/wcf-sql-versus-the-old-sql-adapter/

Richard Seroter’s SOA Patterns with BizTalk Server 2009 (Chapter 9) .

4

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Polling Consumer

5Source: http://www.eaipatterns.com/PollingConsumer.html by Gregor Hohpe and Bobby Wolf.

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Event-Driven Consumer

6Source http://www.eaipatterns.com/EventDrivenConsumer.html by Gregor Hohpe and Bobby Wolf.

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Query Notification vs. Polling

7

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

BIZTALK EXAMPLESPolling Consumer

WCF SQL SERVER ADAPTER

8

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

WCF SQL Adapter Installation

Download & install:

• WCF LOB Adapter SDK SP2

• Microsoft BizTalk Adapter for SQL Server (WCF SQL Adapter)

NOTE:(1) The WCF SQL adapter is also available as part of the BizTalk Adapter Pack.(2) A BizTalk license is required.

9

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Consume Adapter Service

Configure Adapter

10

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Consume Adapter Service

Configure Binding

11

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Consume Adapter Service

Typed Polling Contract

12

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Consume Adapter Service

Generated Items

13

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

BizTalk Admin ConsoleWcfReceiveLocation for polling

14

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

BizTalk Admin ConsoleSimple send port to trace polling data

15

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Sample of Typed Polling Data

16

|

eW

orl

dTr

ee.c

om

Time to build the example from scratch!

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

BIZTALK EXAMPLESEvent-Driven Consumer

WCF SQL SERVER ADAPTER

17

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

SQL Service Broker Verification

• To verify whether Service Broker is enabled or not:

SELECT is_broker_enabled FROM sys.databases WHERE name = ‘MyDB’;

• To enable Service Broker functionality (if needed):

ALTER DATABASE [MyDB] SET ENABLE_BROKER;or

ALTER DATABASE [MyDB] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;

18

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Consume Adapter Service

Configure Adapter

19

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Consume Adapter Service

Configure Binding

20

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Consume Adapter Service

Notification Service Contract

21

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Consume Adapter Service

Generated Items

22

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

BizTalk Admin ConsoleWcfReceiveLocation for notifications

23

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

BizTalk Admin ConsoleSimple send port to trace notifications

24

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Sample of Notifications

25

|

eW

orl

dTr

ee.c

om

Time to build the example from scratch!

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

CUSTOMER CASE STUDY

WCF SQL SERVER ADAPTER OUTSIDE OF BIZTALK

26

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

WCF SQL Adapter Outside BizTalk

27

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Console Service SampleAdd Adapter Service Reference – Generated Items

|

eW

orl

dTr

ee.c

om

28

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Console Service DemoSnippet from NotificationAction class

|

eW

orl

dTr

ee.c

om

29

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Console Service DemoSnippet from Main Routine

|

eW

orl

dTr

ee.c

om

30

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Console Service DemoChanges to SqlAdapterBindingService

|

eW

orl

dTr

ee.c

om

31

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Console Service DemoListener Started Notification

|

eW

orl

dTr

ee.c

om

32

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Console Service DemoInsert Notification

|

eW

orl

dTr

ee.c

om

33

And after the service is stopped…

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

Caveats & Gotchas • The adapter only receives one notification if the

SQL statement (e.g. INSERT) affects more than one row.

• Consider the use of the NotifyOnListenerStart event to retrieve pending records after a network communication breakdown.

• Double check the requirements and restrictions for SELECT statements in a query notification.

34

|

eW

orl

dTr

ee.c

om

Twin

Cit

ies

Connect

ed S

yst

em

s U

ser

Gro

up (

Nov.

17

th,

20

11

)

eWorldTree, LLCBranch out your information network ™. Link to eWorldTree™.

35

Q&AThank You! |

eW

orl

dTr

ee.c

om