ssbdiagnose Utility
The ssbdiagnose utility reports issues in Service Broker conversations or the configuration of Service Broker services. Configuration checks can be made for either two services or a single service. Issues are reported either in the command prompt window as human-readable text, or as formatted XML that can be redirected to a file or another program.
ssbdiangose
[ [ -XML ]
[ -LEVEL { ERROR | WARNING | INFO } ]
[-IGNORE error_id ] [ ...n]
[ <baseconnectionoptions> ]
{ <configurationreport> | <runtimereport> }
]
| -?
<configurationreport> ::=
CONFIGURATION
{ [ FROM SERVICE service_name
[ <fromconnectionoptions> ]
[ MIRROR <mirrorconnectionoptions> ]
]
[ TO SERVICE service_name[, broker_id ]
[ <toconnectionoptions> ]
[ MIRROR <mirrorconnectionoptions> ]
]
}
ON CONTRACT contract_name
[ ENCRYPTION { ON | OFF | ANONYMOUS } ]
<runtime_report> ::=
RUNTIME
[-SHOWEVENTS ]
[ -NEW
[ -ID { conversation_handle
| conversation_group_id
| conversation_id
}
] [ ...n]
]
[ -TIMEOUT timeout_interval ]
[ <runtimeconnectionoptions> ]
<baseconnectionoptions> ::=
<connectionoptions>
<fromconnectionoptions> ::=
<connectionoptions>
<toconnectionoptions> ::=
<connectionoptions>
<mirrorconnectionoptions> ::=
<connectionoptions>
<runtimeconnectionoptions> ::=
[ CONNECT TO <connectionoptions> ] [ ...n]
<connectionoptions> ::=
[ –E | { -U login_id [ -P password ] } ]
[ -S server_name[\instance_name] ]
[ -d database_name ]
[ -l login_timeout ]
Use ssbdiagnose to do the following:
Confirm that there are no configuration errors in a newly configured Service Broker application.
Confirm that there are no configuration errors after changing the configuration of an existing Service Broker application.
Confirm that there are no configuration errors after a Service Broker database is detached and then reattached to a new instance of the Database Engine.
Research whether there are configuration errors when messages are not successfully transmitted between services.
Get a report of any errors that occur in a set of Service Broker conversation elements.
For information about the errors returned by ssbdiagnose, see Errors and Events Reference (Service Broker).
Configuration Reporting
To correctly analyze the configuration used by a conversation, run a ssbdiagnose configuration report that uses the same options that are used by the conversation. If you specify a lower level of options for ssbdiagnose than are used by the conversation, ssbdiagnose might not report conditions that are required by the conversation. If you specify a higher level of options for ssbdiagnose, it might report items that are not required by the conversation. For example, a conversation between two services in the same database can be run with ENCPRYPTION OFF. If you run ssbdiagnose to validate the configuration between the two services, but use the default ENCRYPTION ON setting, ssbdiagnose reports that the database is missing a master key. A master key is not required for the conversation.
The ssbdiagnose configuration report analyzes only one Service Broker service or a single pair of services every time it is run. To report on multiple pairs of Service Broker services, build a .cmd command file that calls ssbdiagnose multiple times.
Runtime Reporting
When -RUNTIME is specified, ssbdiagnose searches all databases specified in runtimeconnectionoptions and baseconnectionoptions to build a list of Service Broker IDs. The full list of IDs built depends on what is specified for -NEW and -ID:
If neither -NEW or -ID are specified, the list includes all conversations for all databases specified in the connection options.
If -NEW is specified, ssbdiagnose includes the elements for the first conversation that starts after ssbdiagnose is run. This includes the conversation ID and the conversation handles for both the target and initiator conversation endpoints.
If -ID is specified with a conversation handle, only that handle is included in the list.
If -ID is specified with a conversation ID, the conversation ID and the handles for both of its conversation endpoints are added to the list.
If -ID is specified with a conversation group ID, all the conversation IDs and conversation handles in that group are added to the list.
The list does not include elements from databases that are not covered by the connection options. For example, assume that you use -ID to specify a conversation ID, but only provide a runtimeconnectionoptions clause for the initiator database and not the target database. ssbdiagnose will not include the target conversation handle in its list of IDs, only the conversation ID and the initiator conversation handle.
ssbdiagnose monitors the SQL Server Profiler events from the databases covered by runtimeconnectionoptions and baseconnectionoptions. It searches for Service Broker events that indicate an error was encountered by one or more of the Service Broker IDs in the runtime list. ssbdiagnose also searches for system-level Service Broker error events not specifically associated with any conversation group.
If ssbdiagnose finds conversation errors, the utility will attempt to report on the root cause of the events by also running a configuration report. ssbdiagnose uses the metadata in the databases to try to determine the instances, Service Broker IDs, databases, services, and contracts used by the conversation. It then runs a configuration report using all available information.
By default, ssbdiagnose does not report error events. It only reports the underlying issues found during the configuration check. This minimizes the amount of information reported and helps you focus on the underlying configuration issues. You can specify -SHOWEVENTS to see the error events encountered by ssbdiagnose.
Issues Reported by ssbdiagnose
ssbdiagnose reports three classes of issues. In the XML output file, each class of issue is reported as a separate type of the Issue element. The three types of issues reported by ssbdiagnose are as follows:
sqlcmd Environment Variables
The ssbdiagnose utility supports the SQLCMDSERVER, SQLCMDUSER, SQLCMDPASSWORD, and SQLCMDLOGINTIMOUT environment variables that are also used by the sqlcmd utility. You can set the environment variables either by using the command prompt SET command, or by using the setvar command in Transact-SQL scripts that you run by using sqlcmd. For more information about how to use setvar in sqlcmd, see Using sqlcmd with Scripting Variables.
This section contains examples of using ssbdiagnose at a command prompt.
A. Checking the Configuration of Two Services in the Same Database
The following example shows how to request a configuration report when the following are true;
The initiator and target service are in the same database.
The database is in the default instance of the Database Engine.
The instances is on the same computer on which ssbdiagnose is run.
The ssbdiagnose utility reports the configuration that uses the DEFAULT contract because ON CONTRACT is not specified.
ssbdiagnose -E -d MyDatabase CONFIGURATION FROM SERVICE /test/initiator TO SERVICE /test/target
B. Checking the Configuration of Two Services on Separate Computers That Use One Login
The following example shows how to request a configuration report when the initiator and target service are on separate computers, but can be accessed by using the same Windows Authentication login.
ssbdiagnose -E CONFIGURATION FROM SERVICE /text/initiator -S InitiatorComputer -d InitiatorDatabase TO SERVICE /test/target -S TargetComputer -d TargetDatabase ON CONTRACT TestContract
C. Checking the Configuration of Two Services on Separate Computers That Use Separate Logins
The following example shows how to request a configuration report when the initiator and target service are on separate computers, and separate SQL Server Authentication logins are required for each instance of the Database Engine.
ssbdiagnose CONFIGURATION FROM SERVICE /text/initiator -S InitiatorComputer -U InitiatorLogin -p !wEx23Dvb -d InitiatorDatabase TO SERVICE /test/target -S TargetComputer -U TargetLogin -p ER!49jiy -d TargetDatabase ON CONTRACT TestContract
D. Checking Mirrored Service Configurations on Separate Computers With Anonymous Encryption
The following example shows how to request a configuration report when the initiator and target service are on separate computers and the initiator is mirrored to a named instance. The report also verifies that the services are configured to use anonymous encryption.
ssbdiagnose -E CONFIGURATION FROM SERVICE /text/initiator -S InitiatorComputer -d InitiatorDatabase MIRROR -S MirrorComputer/MirrorInstance TO SERVICE /test/target -S TargetComputer –d TargetDatabase ON CONTRACT TestContract ENCRYPTION ANONYMOUS
E. Checking the Configuration of Two Contracts
The following example shows how to build a command file that requests configuration reports when the following are true:
The initiator and target service are in the same database.
The database is in the default instance of the Database Engine.
The instance is on the same computer on which ssbdiagnose is run.
Each time ssbdiagnose is run it reports the configuration for a different contract between the same services.
ssbdiagnose -E -d MyDatabase CONFIGURATION FROM SERVICE /test/initiator TO SERVICE /test/target ON CONTRACT PayRaiseContract ssbdiagnose -E -d MyDatabase CONFIGURATION FROM SERVICE /test/initiator TO SERVICE /test/target ON CONTRACT PromotionContract
F. Monitor the status of a specific conversation on the local computer with a time out
The following example shows how to monitor a specific conversation where the initiator and target services are in the same database in the default instance of the same computer that is running ssbdiagnose. The time-out interval is set to 20 seconds.
ssbdiagnose -E -d TestDatabase RUNTIME -ID D68D77A9-B1CF-41BF-A5CE-279ABCAB140D -TIMEOUT 20
G. Monitor the status of a conversation that spans two computers
The following example shows how to monitor a specific conversation where the initiator and target services are on separate computers.
ssbdiagnose RUNTIME -ID D68D77A9-B1CF-41BF-A5CE-279ABCAB140D -TIMEOUT 10 CONNECT TO -E -S InitiatorComputer/InitiatorInstance -d InitiatorDatabase CONNECT TO -E -S TargetComputer/TargetInstance -d TargetDatabase
H. Monitor the status of a conversation in two databases in the same instance
The following example shows how to monitor a specific conversation where the initiator and target services are in separate databases in the same instance of the Database Engine. The example uses the baseconnectionoptions to specify the instance and login information, and two CONNECT TO clauses to specify the databases. -SHOWEVENTS is specified so that all runtime events are included in the report output.
ssbdiagnose -E -S TestComputer/DevTestInstance RUNTIME -SHOWEVENTS -ID 5094d4a7-e38c-4c37-da37-1d58b1cb8455 -TIMEOUT 10 CONNECT TO -d InitiatorDatabase CONNECT TO -d TargetDatabase
I. Monitor the status of two conversations between two databases
The following example shows how to monitor two conversations where the initiator and target services are in separate databases in the same instance of the Database Engine. The example uses the baseconnectionoptions to specify the instance and login information, and two CONNECT TO clauses to specify the databases.
ssbdiagnose -E -S TestComputer/DevTestInstance RUNTIME -ID 5094d4a7-e38c-4c37-da37-1d58b1cb8455 -ID 9b293be9-226b-4e22-e169-1d2c2c15be86 -TIMEOUT 10 CONNECT TO -d InitiatorDatabase CONNECT TO -d TargetDatabase
J. Monitor the status of all conversations between two databases
The following example shows how to monitor all the conversation between two databases in the same instance of the Database Engine. The example uses the baseconnectionoptions to specify the instance and login information, and two CONNECT TO clauses to specify the databases.
ssbdiagnose -E -S TestComputer/DevTestInstance RUNTIME -TIMEOUT 10 CONNECT TO -d InitiatorDatabase CONNECT TO -d TargetDatabase
K. Ignore Specific Errors
The following example shows how to ignore known errors (303 and 304) in how activation is currently configured in a test system.
ssbdiagnose -IGNORE 303 -IGNORE 304 -E -d TestDatabase CONFIGURATION FROM SERVICE /test/initiator TO SERVICE /test/target ON CONTRACT TextContract
L. Redirecting ssbdiagnose XML Output
The following example shows how to request that ssbdiagnose generate its output as an XML file that is redirected to a file. The TestDiag.xml file can then be opened by an application to analyze or report ssbdiagnose XML files. Or, you can view it from a general XML editor such as XML Notepad.
ssbdiagnose -XML -E -d MyDatabase CONFIGURATION FROM SERVICE /test/initiator TO SERVICE /test/target > c:\MyDiagnostics\TestDiag.xml
M. Using an Environment Variable
The following example first sets the SQLCMDSERVER environment variable to hold the server name, and then runs ssbdiagnose without specifying -S.
SET SQLCMDSERVER=MyComputer ssbdiagnose -XML -E -d MyDatabase CONFIGURATION FROM SERVICE /test/initiator TO SERVICE /test/target
Security Note