Publish a message to Dovetail Carrier to invoke a custom action
To recap how we got here:
- Dovetail Task Manager Overview – What it is, how it works, etc.
- Creating custom tasks for Dovetail Task Manager – How to create a custom task action, namely a Get Stock Quote action
- Invoking custom actions in Dovetail Carrier without using Task Manager – How to call a custom action using Rulemanager to publish a message to Carrier
Now, lets look at calling a custom action within Carrier by pushing a message onto Carrier’s queue, without using Rulemanager.
We’ll use the same action created in the previous post – namely GetStockQuote.
For this example, we’re creating a custom executable – publish.exe
This exe will simply take the message content as an input parameter, and publish that message to Carrier.
Here’s an overview of the code:
- Create a settings class will be used to configure the MSMQ address that Dovetail Carrier is watching.
- Configure StructureMap to build our settings
- Configure MassTransit
- Define the message class – Dovetail Carrier is configured to listen messages that typed against the Dovetail.Carrier.Messages.ICarrierMessageinterface. This interface simply defines a public property named Data that is a string
- Retrieve the proper endpoint from the cache we configured in StructureMap and use that to send a message.
- Configure our container, get an instance of our publisher, and send a message
I’m not going to go into the specific C# code details here.
But don’t worry, you don’t even need to write any of this code. We’ve already written the code, and we’ve made it all freely available on Github: http://dovetailsoftware.github.io/carrier-customizations/
Publish a message
Now that we’ve created an executable, we can use it to publish a message to Carrier.
Simply call publish.exe and pass in the desired message:
Review Carrier logs
Looking at the Carrier logs, we can see where it received the message, and then logged the result of the web service call:
Dovetail.Carrier.Core.RuleManager.RuleManagerConsumer – (null) Carrier message received: type=GetStockQuote\r\nsymbol=GOOG
Dovetail.Carrier.Core.RuleManager.RuleManagerConsumer – (null) Resolved message data for: Dovetail.TaskManagerExamples.MessageExample.GetStockQuote
Dovetail.TaskManagerExamples.MessageExample.GetStockQuoteConsumer – (null) Alphabet Inc. is at 718.359985
All of the code for this example is available on Github: http://dovetailsoftware.github.io/carrier-customizations/
So we can see that we were able to use the publish.exe to publish a message to Carrier, and then Carrier invoked some custom code.
And again, this is all completely independent of Dovetail Task Manager and Dovetail Rulemanager.
Like I mentioned in a previous post, with custom code, actions can do whatever you want. In this example, we interfaced into another system (to get the stock quote).
What else could we do? How about:
- When a contact is created in SalesForce, create the same contact in Dovetail
- When an order has been processed in the ordering system, install the site part in Dovetail
- When an alert has been received from the Network Monitoring System, create a case in Dovetail and auto-dispatch it to a queue
- When a response is received from a customer satisfaction survey, update the case with the survey response details
Really, the sky’s the limit here. We’ve opened up a whole new avenue for integrations.
Plus, we’ve demonstrated how to get Carrier to do something from an outside process (in this case, a custom executable).
You could re-use this same code within your own custom web service, or within your own executable.
We also have some stuff in the works that will make it even easier to call on APIs from the Dovetail SDK Toolkits from a message. More on that in the near future.
Even with supposedly “legacy” systems such as Clarify, we’re showing companies how they can use modern technologies and contemporary enterprise integration patterns to make the most of corporate systems.