652
Part V: Enterprise Data Management
FROM SERVICE [InitiatorService]
TO SERVICE 'TargetService'
ON CONTRACT [HelloWorldContract]
WITH ENCRYPTION = OFF, LIFETIME = 1000 ;
SEND ON CONVERSATION @conversationHandle
MESSAGE TYPE [HelloWorldMessage]
(@message) ;
END CONVERSATION @conversationHandle ;
COMMIT TRANSACTION ;
A queue is an internal table, but all you can do is SELECT or RECEIVE. You can’t use any
other command such as UPDATE or DELETE. To view the messages in the target queue, select
from the queue as if it were a normal relational table:
USE AdventureWorks2012
GO
SELECT * FROM [TargetQueue] WITH(NOLOCK);
GO
Figure 25-3 shows the result of the query.
FIGURE 25-3
Query results of the TargetQueue table.
Receiving a Message
The receive command retrieves and removes the oldest message from the queue. Use
receive within a transaction so that if something goes wrong, the receive action can be
rolled back, and the message is still in the queue.
c25.indd 652c25.indd 652 7/31/2012 9:21:38 AM7/31/2012 9:21:38 AM
http://www.it-ebooks.info