I'm trying to create a contract in sql for pushing messages out from sql onto nservicebus (msmq) queues although I'm getting the following error message when executing this code! any ideas why I get this?
Thanks,
james
CREATE CONTRACT [NServiceBusSendMessageContract]
(
[NServiceBusSendMessage] SENT BY ANY
)
Msg 15151, Level 16, State 1, Line 1
Cannot find the message type 'NServiceBusSendMessage', because it does not exist or you do not have permission.
Have you done this?
CREATE MESSAGE TYPE [NServiceBusSendMessage]
VALIDATION = WELL_FORMED_XML
Related
I'm trying to start a script in SQL Server 2014, but it can't find the object in question.
This is the query I am trying to initiate:
SELECT * FROM sys.dm_exec_input_buffer(##SPID, NULL);
Error message:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'sys.dm_exec_input_buffer'.
You need to be on at least Service Pack 2. If you're on an earlier service pack, it's time to patch.
Here's a link to Service Pack 3
Here's a link to the most recent update for SP3
Please apply both, in that order.
I am facing an issue while creating a Cordapp.
I have two types of states Policy State and Claim State and their respective contracts.
Now I am writing a Claim Flow in which a Policy state will be taken as input and a claim state should be produced as output.
But I am facing this error while doing so-
java.util.concurrent.ExecutionException: net.corda.core.contracts.TransactionVerificationException$ContractRejection: Contract verification failed: Required com.example.contract.PolicyContract.Commands.Create command, contract: com.example.contract.PolicyContract, transaction: B6F0A0B895B477153530F060B264FE85BAA8F29BA922A546BEC6300A255667C7
I am enclosing my Policy Contract, ClaimContract and ClaimFlow-
PolicyContract- https://ideone.com/giz7uX
ClaimContract-https://ideone.com/3GM4UF
ClaimFlow-https://ideone.com/BobTsy
The problem is the requireSingleCommand. When you create a transaction with input states, the command that the input state was included within another transaction will load here as well. To solve this use tx.commandsOfType<YourType>() or whatever the syntax is. This will not throw an exception.
The exception is due to single being called in requireSingleCommand.
When trying to change the user account to link with the NewMary login:
EXEC sp_change_users_login 'Update_One', 'Mary', 'NewMary'
go
I get the error 208:
Msg 208, Level 16, State 1, Procedure ChangeLogging_LogDDLCommands, Line 147
Invalid object name 'Utils.dbo.ChangeLogging_DDLCommands'.
I don't find any relevant information on ChangeLogging_DDLCommands, and I'm lost at how I do have to proceed from there.
Sounds like you have some kind of custom trigger, which is missing this object.
In SSMS:
Check server triggers under "Server Objects" > "Triggers"
Check individual database DDL triggers under "Programmability" -> "Database triggers"
I'm trying to learn the basics of Service Broker, and have created an application originally based on the SSMS template. However I can't send a message to my queue. It just says the message type is not part of the service contract.
The absolute bare minimum I need to recreate this is the following batch:
USE [test_db]
GO
CREATE MESSAGE TYPE [test_message]
AUTHORIZATION [dbo]
VALIDATION = WELL_FORMED_XML
GO
CREATE CONTRACT [test_contract]
AUTHORIZATION [dbo] (
[test_message] SENT BY ANY
)
GO
CREATE QUEUE [dbo].[test_queue]
WITH STATUS = ON
,RETENTION = OFF
--,ACTIVATION (
-- STATUS = ON
-- ,PROCEDURE_NAME = [dbo].[test_activator]
-- ,MAX_QUEUE_READERS = 1
-- ,EXECUTE AS N'dbo'
--)
ON [PRIMARY]
GO
CREATE SERVICE [test_service]
AUTHORIZATION [dbo]
ON QUEUE [dbo].[test_queue] (
[test_contract]
)
GO
BEGIN TRANSACTION
DECLARE #dialog_handle UNIQUEIDENTIFIER
BEGIN DIALOG #dialog_handle
FROM SERVICE test_service
TO SERVICE N'test_service';
SEND ON CONVERSATION #dialog_handle
MESSAGE TYPE test_message (N'<test />');
END CONVERSATION #dialog_handle;
COMMIT TRANSACTION
GO
...which yields:
Msg 8431, Level 16, State 1, Line 10
The message type 'test_message' is not part of the service contract.
I only need to be able to send asynchronous messages within the same database. There are no remote connections to consider, and I don't strictly even need to handle a reply.
I've checked and double-checked that the message type, contract, queue and service all exist and the properties of the contract says that the message type is included
What am I missing?
As Denis already answered, you're missing the ON CONTRACT test_contract.
If you omit it then the DEFAULT contract is used. Every database has a contract named DEFAULT which has one message type, also named DEFAULT. The DEFAULT contract is used when you omit any contract in BEGIN DIALOG and the DEFAULT message type is used when you omit the message type in SEND:
BEGIN DIALOG #dialog_handle
FROM SERVICE test_service
TO SERVICE N'test_service'; <-- will use the DEFAULT contract
SEND ON CONVERSATION #dialog_handle
(N'<test />'); <-- will use the DEFAULT message type
DEFAULT message type has no validation. The DEFAULT contract binds the DEFAULT message type to both initiator and target (both can send the message in this contract, ie. SENT BY ANY). Contract and message type names are always case sensitive, irrelevant of database collation, so the name DEFAULT is case sensitive.
Try this:
BEGIN DIALOG #dialog_handle
FROM SERVICE test_service
TO SERVICE N'test_service'
ON CONTRACT test_contract;
I am using the error function in quite a few of my functions and would like to propagate the error messages to the user. However, I obviously don't want to include information about where the error occured exactly; this information should only go to the log files.
For example, I have a class that manages the connection to a server. If the connection times out, it calls
error("Connection timed out!")
The error message is then caught by the calling code via pcall. However, the message contains not only the message I passed, but also the name of the file that caused the error and the line number:
common/net/enetclient.lua:21: Connection timed out!
The question is: Is there any way to only retrieve the error message itself, or do I have to do this manually like following:
local status, msg = pcall(someFunctionThatThrowsErrors)
if not status then
local file, msg = msg:match("(.-:%d+): (.+)")
print("Error: " .. msg)
end
Cheers,
From the documentation of the error function:
error (message [, level])
Terminates the last protected function called and returns message as the error message. Function error never returns.
Usually, error adds some information about the error position at the beginning of the message, if the message is a string. The level argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message.
From what is stated in the second paragraph, adding a level of 0 to the error call will result in the desired output:
error("Connection timed out!", 0)