Instructor Inputs - Session 16 ppt

14 147 0
Instructor Inputs - Session 16 ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Instructor Inputs Session 16 ¤NIIT Instructor Inputs 16.3 This session includes Chapter 11 of the Student Guide. Slide 1 Slide 1 of 14Session 16 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 In this session, you will learn to: Appreciate message-based communication Implement Service Broker Objectives Begin the session by sharing the objectives with the students. In this session, the students will learn about the benefits of message-based communication. Further, they will learn how to implement message-based communication using the Service Broker feature of SQL Server 2005. Session Overview 16.4 Instructor Inputs ¤NIIT Slide 2 Slide 2 of 14Session 16 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 Flash presentation: Implementing Service Broker Introduction to Service Broker Use the given flash presentation to introduce message-based communication Service Broker to the students. Inputs for the Flash Presentation When showing the presentation you can use the following inputs to explain the concepts: Screen 1 This screen shows an analogy of a message-based communication. In a cargo service a service sends messages to another service. A service is represented by a user and a message is represented as a cargo parcel. A user sends a cargo parcel to the cargo office near his location. The cargo parcel processes the request to deliver the message to the other user. The first user can continue his work as he is assured that the message will be delivered. An acknowledgement can also be sent to the user telling that the request is processed. Screen 2 The screen displays the communication architecture. Mention that the Service Broker feature of SQL Server 2005 helps in implementing message-based communication. It shows how a message is sent and processed. The architecture shows various components that are included in communication. These ¤NIIT Instructor Inputs 16.5 components include message type, contract, service program, service, and a queue. Explain the importance of each component using the following points:  Message type: Specifies the type of messages that will be sent  Contract: Defines the agreement between two services. This agreement specifies that two services will communicate with each other. It also specifies the type of messages that will be sent or received.  Service program: Processes a request sent as a message.  Queue: Stores messages. When Service Broker receives a message for a service, Service Broker inserts the message into the queue for that service.  Service: Participates in a communication. Each service is associated with one queue. When a message arrives for a service, Service Broker places the message in the queue associated with that service. You can further explain that Microsoft SQL Server 2005 integrates Service Broker with the database engine. It helps the database developer to build reliable, scalable, and secure database. With Service Broker integrated with database engine, database developers can now add the features like asynchronous communication and reliable-query processing to the database. Slide 3 Slide 3 of 14Session 16 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 Is explained by the following diagram. Introduction to Service Broker Conversation Process Using this slide you can reiterate the communication process. 16.6 Instructor Inputs ¤NIIT Slide 4 Slide 4 of 14Session 16 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 Just a minute Which of the following objects processes a message from a queue? 1. Service 2. Service program 3. Contract Answer: 2. Service program Reiterate the concept taught by asking the given question. In the following topics, you will teach how to implement Service Broker in SQL Server. This involves creating different objects that are used to send or receive messages. Slide 5 Slide 5 of 14Session 16 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 Message: Is an entity that is exchanged between the Service Broker services Can contain a validation over the datatype that a message possesses Is of a specific message type Message Type: Can be created by using the CREATE MESSAGE TYPE command Syntax: CREATE MESSAGE TYPE message_type_name [ VALIDATION = { NONE | EMPTY | WELL_FORMED_XML | VALID_XML WITH SCHEMA COLLECTION schema_collection_name } ] [ ; ] Let’s see how… Creating Messages ¤NIIT Instructor Inputs 16.7 In this topic, you need to explain messages to the students. In addition, you also need to explain how to create a message. You can tell that a message the data that is communicated between two ends. A message is of a particular message type, if specified. Otherwise, the message type is of the DEFAULT message type. You can create a message type using the CREATE MESSAGE TYPE command. Explain the syntax of the command. Slide 6 Slide 6 of 14Session 16 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 Queue: Is an object that stores the messages Can be viewed like a pipeline for messages Is created by using the CREATE QUEUE command Syntax: CREATE QUEUE <object> [ WITH [ STATUS = { ON | OFF } [ , ] ] [ RETENTION = { ON | OFF } [ , ] ] [ ACTIVATION ( [ STATUS = { ON | OFF } , ] PROCEDURE_NAME = <procedure> , MAX_QUEUE_READERS = max_readers , EXECUTE AS { SELF | 'user_name' | OWNER } ) ] ] Let’s see how… Creating Queues In this topic, you need to explain queues to the students. Tell the students that a queue is represented as a table and a message acts as a row in the queue. The row contains the content of the message as well as information about the message type, the service targeted by the message, the contract that the message follows, the validation performed on the message, the conversation that the message is a part of, and information internal to the queue. An application uses the information in the message row to identify each message uniquely and process the message appropriately. Applications receive messages from the queue for the service. For each conversation, queues return messages in the order in which the sender sent the message. All the messages returned from a single receive operation are part of conversations that belong to one conversation group. Queues do not return messages in strict first-in-first-out order. Instead, they return messages for each conversation in the order in which the messages were sent. Explain the syntax of the CREATE QUEUE command. 16.8 Instructor Inputs ¤NIIT Slide 7 Slide 7 of 14Session 16 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 Contract: Is an agreement between two services that need to communicate with each other Specifies the type of message that will be used in a conversation Is created by using the CREATE CONTRACT command Syntax: CREATE CONTRACT contract_name [ AUTHORIZATION owner_name ] ( { { message_type_name | [ DEFAULT ] } SENT BY { INITIATOR | TARGET | ANY } } [ , n] ) [ ; ] Let’s see how… Creating Contracts In this topic, you need to explain what a contract is and how to implement it. You can tell that a contract specifies which message types can be used to accomplish the desired work. The contract also specifies which participant in the conversation can use each message type. Some message types can be sent by either participant; other message types are restricted to be sent only by the initiator or only by the target. Service Broker also includes a built-in contract named DEFAULT. The DEFAULT contract contains only the message type SENT BY ANY. If no contract is specified in the BEGIN DIALOG statement, Service Broker uses the DEFAULT contract. Explain the syntax of the CREATE CONTRACT command. ¤NIIT Instructor Inputs 16.9 Slide 8 Slide 8 of 14Session 16 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 Service: Is used by the Service Broker to deliver messages to the correct queue within a database Is used to route messages, to enforce the contract for a conversation, and to determine the remote security for a new conversation Is created by using the CREATE SERVICE command Syntax: CREATE SERVICE service_name [ AUTHORIZATION owner_name ] ON QUEUE [ schema_name. ]queue_name [ ( contract_name | [DEFAULT] [ , n ] ) ] [ ; ] Let’s see how… Creating Services In this topic, you need to explain what a service is and how it is implemented in SQL Server. A service is an end point of conversation. A conversation in Service Broker can contain two types of services: target and initiating. A target service represents an address that accepts requests for the tasks identified by the contracts that the service specifies. An initiating service represents a return address for a conversation with a target service. Each service uses a queue to store messages. Messages sent to the service are delivered to the queue. To create a service, you need to do the following tasks: 1. Create message types that define the data that can be sent back and forth. 2. Create a contract that identifies the message types that can be used, and which endpoint can send them, in order to accomplish a particular task. 3. Create an application to receive, process, and send messages as necessary to accomplish the given task. 4. Create a queue to store the incoming messages for the service. You may associate the queue with an activation stored procedure so that the broker automatically activates the stored procedure to process messages as messages arrive. 5. Create a service and associate it with the queue that will receive the messages for the service. 16.10 Instructor Inputs ¤NIIT Slide 9 Slide 9 of 14Session 16 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 Services communicate through a dialog. Conversation can begin using the BEGIN DIALOG command. Syntax: BEGIN DIALOG [ CONVERSATION ] @dialog_handle FROM SERVICE initiator_service_name TO SERVICE 'target_service_name'] [ ON CONTRACT contract_name ] Let’s see how… Beginning a Conversation In this topic, you need to explain how to begin a conversation process using the BEGIN DIALOG command. In addition you can tell that communication between two applications occurs through messages. As an application sends messages, Service Broker handles the details of locating a route for the service and transmitting the message to the target service. Service Broker communicates the status of a conversation to an application through messages. Service Broker indicates errors or the end of a conversation status. [...]... the CREATE SERVICE command A conversation can be started by using the BEGIN DIALOG command Messages can be sent by using the SEND ON CONVERSATION command Ver 1.0 NIIT Session 16 Slide 14 of 14 Instructor Inputs 16. 13 16. 14 Instructor Inputs NIIT ... in the SubTotal column of the table, should be added to the total yearly sales in the SalesDB database Ver 1.0 Session 16 Slide 11 of 14 At the end of this activity, the students will be able to implement asynchronous communication using Service Broker in the database NIIT Instructor Inputs 16. 11 Note For this activity, you need to create another database, named SalesDB To create this database, you... again attach the SalesDB database After attaching the database, you will notice that the sales amount will be added to the total yearly sales amount 16. 12 Instructor Inputs NIIT Slide 13 Querying and Managing Data Using SQL Server 2005 Summary In this session, you learned that: Service Broker provides a platform that allows the developers to create asynchronous and reliable query processing In Service... associated with a queue that acts as a container that stores messages A service program provides the required service to which a message is forwarded by the queue for processing Session 16 Ver 1.0 Slide 13 of 14 Summarize the session Slide 14 Querying and Managing Data Using SQL Server 2005 Summary (Contd.) When implementing Service Broker, you need to create message, queue, contract, service, and conversation... perform the following tasks: 1 2 3 4 Ver 1.0 Create a service program Create message types, contract, queues, and service objects Create a trigger on the SalesOrderHeader table Verify the functionality Session 16 Slide 12 of 14 You can also check that the transaction is committed even if the database is not available by detaching the database Next, you can execute the INSERT statement in the Sales.SalesOrderHeader... Messages are sent using the SEND ON CONVERSATION command Syntax: SEND ON CONVERSATION conversation_handle [ MESSAGE TYPE message_type_name ] [ ( message_body_expression ) ] [ ; ] Let’s see how… Ver 1.0 Session 16 Slide 10 of 14 In this topic, you will explain how messages are sent using the SEND ON CONVERSATION command Explain the syntax of the command Slide 11 Querying and Managing Data Using SQL Server . Instructor Inputs Session 16 ¤NIIT Instructor Inputs 16. 3 This session includes Chapter 11 of the Student Guide. Slide 1 Slide 1 of 1 4Session 16 Ver. 1.0 Querying and. message-based communication. Further, they will learn how to implement message-based communication using the Service Broker feature of SQL Server 2005. Session Overview 16. 4 Instructor Inputs. first-in-first-out order. Instead, they return messages for each conversation in the order in which the messages were sent. Explain the syntax of the CREATE QUEUE command. 16. 8 Instructor Inputs

Ngày đăng: 31/07/2014, 15:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan