This article describes implementing real-time Salesforce notifications within an NServiceBus messaging environment. The solution enables near real-time synchronization of Salesforce data through outbound messages rather than polling.
Salesforce Setup
Generate contracts from Salesforce's Enterprise WSDL and configure outbound messages through the workflow system. Specifically, "outbound messages" trigger via workflow rules to push data when objects change.
Code Generation
Two distinct approaches apply here:
wsdl.exegenerates the Salesforce client (Enterprise WSDL)svcutil.exegenerates the receiving service contract (outbound message WSDL)
NServiceBus Integration
A WCF service receives notifications and converts them into NServiceBus commands. The ContactNotificationService class demonstrates handling batched notifications: the class uses dependency injection to receive a bus instance and routes messages through the messaging system.
Important Caveats
- Notifications attempt delivery for 24 hours before purging
- No guaranteed exactly-once delivery or ordering
- Deleted objects require special handling through logical deletes or trigger-based logging
- Requires compensating transactions and deduplication logic
Resources
The complete implementation is available at the SalesForce To NServiceBus GitHub repository.