本文整理汇总了C#中BusConfiguration.UseTransport方法的典型用法代码示例。如果您正苦于以下问题:C# BusConfiguration.UseTransport方法的具体用法?C# BusConfiguration.UseTransport怎么用?C# BusConfiguration.UseTransport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusConfiguration
的用法示例。
在下文中一共展示了BusConfiguration.UseTransport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultiInstance
void MultiInstance(BusConfiguration busConfiguration)
{
#region sqlserver-multiinstance-upgrade [2.1,3.0)
var transport = busConfiguration.UseTransport<SqlServerTransport>();
// Option 1
transport
.UseSpecificConnectionInformation(
EndpointConnectionInfo.For("RemoteEndpoint")
.UseConnectionString("SomeConnectionString"),
EndpointConnectionInfo.For("AnotherEndpoint")
.UseConnectionString("SomeOtherConnectionString"));
// Option 2
transport
.UseSpecificConnectionInformation(x =>
{
if (x == "RemoteEndpoint")
{
var connectionInfo = ConnectionInfo.Create();
return connectionInfo.UseConnectionString("SomeConnectionString");
}
if (x == "AnotherEndpoint")
{
var connectionInfo = ConnectionInfo.Create();
return connectionInfo.UseConnectionString("SomeOtherConnectionString");
}
return null;
});
#endregion
}
示例2: Main
static void Main()
{
using (ReceiverDataContext ctx = new ReceiverDataContext())
{
ctx.Database.Initialize(true);
}
#region ReceiverConfiguration
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.UseTransport<SqlServerTransport>().UseSpecificConnectionInformation(
EndpointConnectionInfo.For("sender")
.UseConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=sender;Integrated Security=True"));
busConfiguration.UsePersistence<NHibernatePersistence>().RegisterManagedSessionInTheContainer();
busConfiguration.EnableOutbox();
#endregion
using (Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press <enter> to exit");
Console.ReadLine();
}
}
示例3: Main
static void Main( string[] args )
{
var config = new BusConfiguration();
config.UsePersistence<InMemoryPersistence>();
config.UseSerialization<JsonSerializer>();
config.UseTransport<RabbitMQTransport>()
.DisableCallbackReceiver();
config.Transactions()
.DisableDistributedTransactions();
config.EnableInstallers();
config.Conventions()
.DefiningCommandsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Commands" ) )
.DefiningEventsAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Events" ) )
.DefiningMessagesAs( t => t.Namespace != null && t.Namespace.EndsWith( ".Messages" ) );
using( var bus = Bus.Create( config ).Start() )
{
Logic.Run( setup =>
{
setup.DefineAction( ConsoleKey.P, "Publish sample event", () =>
{
bus.Publish<IMessagePublished>(e =>
{
e.ClientId = "client-id";
e.MessageId = "sample-message-id";
});
} );
} );
}
}
示例4: ConfigureBus
public static void ConfigureBus(IWindsorContainer container)
{
// Use NLog for logging
NServiceBus.Logging.LogManager.Use<NLogFactory>();
var configuration = new BusConfiguration();
// Only scan known Messages assemblies rather than all assemblies in 'bin' - faster startup time.
var messages = AppDomain.CurrentDomain.GetAssemblies()
.Where(a => a.GetName().Name.EndsWith(".Messages"));
configuration.AssembliesToScan(messages);
// Use NServiceBus Unobtrusive Mode
configuration.Conventions()
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith("Commands"))
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith("Events"))
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace == "Messages")
.DefiningDataBusPropertiesAs(p => p.Name.EndsWith("DataBus"))
.DefiningExpressMessagesAs(t => t.Name.EndsWith("Express"))
.DefiningTimeToBeReceivedAs(t => t.Name.EndsWith("Expires")
? TimeSpan.FromSeconds(30) : TimeSpan.MaxValue);
// Use existing Castle Windsor container
configuration.UseContainer<WindsorBuilder>(c => c.ExistingContainer(container));
// Use JSON for serialisation
configuration.UseSerialization<JsonSerializer>();
// Use MSMQ for transport
configuration.UseTransport<MsmqTransport>();
// Use InMemory persistence only
configuration.UsePersistence<InMemoryPersistence>();
configuration.EnableInstallers();
// Start the bus
var bus = Bus.Create(configuration);
bus.Start();
}
示例5: InitServiceBus
private void InitServiceBus(BusConfiguration config, IContainer container)
{
// Configure Logging
NServiceBus.Logging.LogManager.Use<Log4NetFactory>();
// Configure container
config.UseContainer<StructureMapBuilder>(c => c.ExistingContainer(container));
// Xml serialization makes for easy to read messages.
config.UseSerialization<JsonSerializer>();
//Define conventions
ConventionsBuilder conventions = config.Conventions();
conventions.DefiningCommandsAs(MessageTypeConventions.EndsWith("Command"));
conventions.DefiningEventsAs(MessageTypeConventions.EndsWith("Event"));
conventions.DefiningMessagesAs(MessageTypeConventions.EndsWith("Message"));
// Keep it simple by default
config.DisableFeature<SecondLevelRetries>();
config.DisableFeature<AutoSubscribe>();
config.DisableFeature<TimeoutManager>();
config.DisableFeature<DataBus>();
// Configure for MSMQ
config.UseTransport<MsmqTransport>();
config.Transactions().Enable();
config.PurgeOnStartup(false);
// Configure Saga Persistence
config.UsePersistence<InMemoryPersistence>();
}
示例6: Main
private static void Main()
{
var configuration = new BusConfiguration();
configuration.EndpointName("Samples.ASB.NativeIntegration");
configuration.ScaleOut().UseSingleBrokerQueue();
configuration.EnableInstallers();
configuration.UsePersistence<InMemoryPersistence>();
configuration.UseSerialization<JsonSerializer>();
BrokeredMessageBodyConversion.ExtractBody = brokeredMessage =>
{
using (var stream = new MemoryStream())
using (var body = brokeredMessage.GetBody<Stream>())
{
body.CopyTo(stream);
return stream.ToArray();
}
};
configuration.UseTransport<AzureServiceBusTransport>()
.ConnectionString(Environment.GetEnvironmentVariable("AzureServiceBus.ConnectionString"));
using (IBus bus = Bus.Create(configuration).Start())
{
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
示例7: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.SqlServer.NativeIntegration";
#region EndpointConfiguration
var busConfiguration = new BusConfiguration();
var transport = busConfiguration.UseTransport<SqlServerTransport>();
transport.ConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=samples;Integrated Security=True");
busConfiguration.EndpointName("Samples.SqlServer.NativeIntegration");
busConfiguration.UseSerialization<JsonSerializer>();
#endregion
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.EnableInstallers();
using (Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press enter to send a message");
Console.WriteLine("Press any other key to exit");
while (true)
{
var key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
return;
}
await PlaceOrder()
.ConfigureAwait(false);
}
}
}
示例8: Main
static void Main(string[] args)
{
Console.Title = "Complaint.Backend";
Console.WriteLine("Complaint Backend starting up...");
var configuration = new BusConfiguration();
configuration.Conventions()
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("SiriusCyberneticsCorp.InternalMessages"))
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("SiriusCyberneticsCorp.Contract"));
configuration.CustomConfigurationSource(new CustomConfigurationSource());
configuration.UseSerialization<JsonSerializer>();
configuration.UsePersistence<RavenDBPersistence>();
configuration.UseTransport<MsmqTransport>();
var bus = Bus.Create(configuration).Start();
Console.WriteLine("Press any key to shut down.");
Console.ReadLine();
Console.WriteLine("Complaint Backend shutting down...");
bus.Dispose();
}
示例9: Customize
public void Customize(BusConfiguration busConfiguration)
{
busConfiguration.UseTransport<MsmqTransport>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.UsePersistence<MsmqPersistence, StorageType.Subscriptions>();
busConfiguration.EnableInstallers();
}
示例10: Customize
public void Customize(BusConfiguration configuration)
{
XmlConfigurator.Configure();
configuration.UseContainer<NinjectBuilder>(k => k.ExistingKernel(CreateKernel()));
configuration.RegisterComponents(x => x.ConfigureComponent<IRepository>(
builder =>
{
return new Repository(() =>
{
var nh = builder.Build<NHibernateStorageContext>();
var e = new OrderContext((DbConnection)nh.Connection);
return e;
});
},
DependencyLifecycle.InstancePerUnitOfWork));
configuration.RegisterComponents(components => components.ConfigureComponent<UnitOfWork>(DependencyLifecycle.InstancePerUnitOfWork));
configuration.UsePersistence<NHibernatePersistence>();
configuration.UseTransport<MsmqTransport>();
configuration.UseDataBus<FileShareDataBus>().BasePath(Constants.NServiceBus_DataBusBasePath);
configuration.RijndaelEncryptionService();
configuration.Transactions();
configuration.EnableOutbox();
configuration.Conventions().OrderConventions();
//
}
示例11: Main
static void Main()
{
var builder = new ContainerBuilder();
builder.RegisterType<Program>();
var container = builder.Build();
var configuration = new BusConfiguration();
configuration.UseContainer<AutofacBuilder>(c => c.ExistingLifetimeScope(container));
configuration.UseTransport<AzureStorageQueueTransport>()
.ConnectionString("UseDevelopmentStorage=true");
configuration.UsePersistence<AzureStoragePersistence>();
configuration.UseSerialization<JsonSerializer>();
configuration.DisableFeature<Sagas>();
configuration.DisableFeature<TimeoutManager>();
configuration.Conventions().DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("NServiceBusDemo.Messages.Commands"));
configuration.Conventions().DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("NServiceBusDemo.Messages.Events"));
configuration.Conventions().DefiningMessagesAs(t => t.Namespace != null && t.Namespace.StartsWith("NServiceBusDemo.Messages.Responses"));
Bus.Create(configuration).Start();
using (var scope = container.BeginLifetimeScope())
{
scope.Resolve<Program>().Run();
}
}
示例12: StartBus
static void StartBus()
{
try
{
var myDocumentStore = new DocumentStore { ConnectionStringName = "EpiFlowDB" };
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("EpiFlow.Messages");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<RavenDBPersistence>()
.UseDocumentStoreForSubscriptions(myDocumentStore)
.UseDocumentStoreForSagas(myDocumentStore)
.UseDocumentStoreForTimeouts(myDocumentStore);
busConfiguration.UseTransport<RabbitMQTransport>();
busConfiguration.DefineCriticalErrorAction(OnCriticalError);
busConfiguration.Transactions().DisableDistributedTransactions();
if (Environment.UserInteractive && Debugger.IsAttached)
{
busConfiguration.EnableInstallers();
}
_bus = Bus.CreateSendOnly(busConfiguration);
}
catch (Exception exception)
{
OnCriticalError("Failed to start the bus.", exception);
}
}
示例13: OtherEndpointConnectionParamsPull
void OtherEndpointConnectionParamsPull(BusConfiguration busConfiguration)
{
#region sqlserver-multischema-config-pull 2.1
var transport = busConfiguration.UseTransport<SqlServerTransport>();
transport.UseSpecificConnectionInformation(queueName =>
{
if (queueName == "sales")
{
return ConnectionInfo.Create()
.UseSchema("salesSchema");
}
if (queueName == "billing")
{
return ConnectionInfo.Create()
.UseSchema("billingSchema");
}
if (queueName == "error")
{
return ConnectionInfo.Create()
.UseSchema("error");
}
return null;
});
#endregion
}
示例14: Main
static void Main(string[] args)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
DefaultFactory defaultFactory = LogManager.Use<DefaultFactory>();
defaultFactory.Level(LogLevel.Fatal);
var configuration = new BusConfiguration();
configuration.EndpointName("Chocolate.Facility.Producer");
configuration.UseTransport<MsmqTransport>();
configuration.UsePersistence<InMemoryPersistence>();
var bus = Bus.Create(configuration).Start();
stopWatch.Stop();
Console.WriteLine($"Initalizing the bus took { stopWatch.Elapsed.ToString("G")}");
stopWatch.Reset();
stopWatch.Start();
Syncher.SyncEvent.Wait();
stopWatch.Stop();
Console.WriteLine($"Receiving #{ Syncher.SyncEvent.InitialCount } of msgs over the bus took { stopWatch.Elapsed.ToString("G")}");
Console.ReadLine();
}
示例15: Main
static void Main()
{
Console.Title = "Samples.SqlServer.StoreAndForwardReceiver";
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.SqlServer.StoreAndForwardReceiver");
#region ReceiverConfiguration
busConfiguration.UseTransport<SqlServerTransport>()
.UseSpecificConnectionInformation(
EndpointConnectionInfo.For("Samples.SqlServer.StoreAndForwardSender")
.UseConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=sender;Integrated Security=True"));
busConfiguration.UsePersistence<NHibernatePersistence>();
#endregion
busConfiguration.DisableFeature<SecondLevelRetries>();
using (Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}