I'm trying to create a 'once-off' process which will pre-load my service with a bunch of data by raising the appropriate events in NServiceBus 5. However I'm struggling with how I might configure my 'fake' subscription so the events get published to the appropriate endpoint.
Here is my code to create my bus to send the messages:
var busConfiguration = new BusConfiguration();
busConfiguration.UseSerialization<XmlSerializer>();
busConfiguration.UseTransport<MsmqTransport>();
busConfiguration.UsePersistence<InMemoryPersistence>();
using (var bus = Bus.CreateSendOnly(busConfiguration))
{
bus.Publish(new MyEvent());
}
But I'm unsure of how to get access to the ISubscriptionStorage
for the InMemoryPersistence
. I'm guessing if I can get access, I can do something like:
var subscriptionStorage = GetSubscriptionStorage();
subscriptionStorage.Subscribe(new Address("MyQueueName", "MyMachineName"), new MessageType(typeof(MyEvent)));
Any ideas?