本文整理汇总了C#中BusConfiguration.EndpointName方法的典型用法代码示例。如果您正苦于以下问题:C# BusConfiguration.EndpointName方法的具体用法?C# BusConfiguration.EndpointName怎么用?C# BusConfiguration.EndpointName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusConfiguration
的用法示例。
在下文中一共展示了BusConfiguration.EndpointName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
#region EndpointConfiguration
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.UseTransport<SqlServerTransport>()
.ConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=samples;Integrated Security=True");
busConfiguration.EndpointName("Samples.SqlServer.NativeIntegration");
busConfiguration.UseSerialization<JsonSerializer>();
#endregion
busConfiguration.UsePersistence<InMemoryPersistence>();
using (Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press enter to send a message");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
return;
}
PlaceOrder();
}
}
}
示例2: Main
static void Main()
{
Console.Title = "Samples.MongoDB.Client";
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.MongoDB.Client");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<InMemoryPersistence>();
using (var bus = Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press 'enter' to send a StartOrder messages");
Console.WriteLine("Press any other key to exit");
while (true)
{
var key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
return;
}
var orderId = Guid.NewGuid();
var startOrder = new StartOrder
{
OrderId = orderId
};
bus.Send("Samples.MongoDB.Server", startOrder);
Console.WriteLine($"StartOrder Message sent with OrderId {orderId}");
}
}
}
示例3: Application_Start
protected void Application_Start()
{
#region ApplicationStart
ContainerBuilder builder = new ContainerBuilder();
// Register your MVC controllers.
builder.RegisterControllers(typeof(MvcApplication).Assembly);
// Set the dependency resolver to be Autofac.
IContainer container = builder.Build();
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.MvcInjection.WebApplication");
// ExistingLifetimeScope() ensures that IBus is added to the container as well,
// allowing you to resolve IBus from your own components.
busConfiguration.UseContainer<AutofacBuilder>(c => c.ExistingLifetimeScope(container));
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.EnableInstallers();
bus = Bus.CreateSendOnly(busConfiguration);
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
#endregion
}
示例4: AsyncMain
static async Task AsyncMain()
{
#region ContainerConfiguration
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Unity");
UnityContainer container = new UnityContainer();
container.RegisterInstance(new MyService());
busConfiguration.UseContainer<UnityBuilder>(c => c.UseExistingContainer(container));
#endregion
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.EnableInstallers();
busConfiguration.SendFailedMessagesTo("error");
IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);
try
{
IBusSession busSession = endpoint.CreateBusSession();
await busSession.SendLocal(new MyMessage());
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpoint.Stop();
}
}
示例5: OnStart
protected override void OnStart(string[] args)
{
try
{
container = new Container(x => x.AddRegistry<DependencyRegistry>());
var myDocumentStore = new DocumentStore { ConnectionStringName = "EpiFlowDB" };
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("EpiFlow.Messages");
busConfiguration.UseContainer<StructureMapBuilder>(c => c.ExistingContainer(container));
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();
}
var startableBus = Bus.Create(busConfiguration);
bus = startableBus.Start();
}
catch (Exception exception)
{
OnCriticalError("Failed to start the bus.", exception);
}
}
示例6: Main
static void Main()
{
LogManager.Use<DefaultFactory>().Level(LogLevel.Error);
#region Program
Logger.WriteLine("Starting configuration");
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.StartupShutdown");
busConfiguration.EnableInstallers();
busConfiguration.EnableFeature<MyFeature>();
busConfiguration.UsePersistence<InMemoryPersistence>();
Logger.WriteLine("Calling Bus.Create");
using (IStartableBus bus = Bus.Create(busConfiguration))
{
Logger.WriteLine("Calling IStartableBus.Create");
bus.Start();
//simulate some bus activity
Thread.Sleep(500);
Logger.WriteLine("Bus is processing messages");
Logger.WriteLine("Calling IStartableBus.Dispose");
}
Logger.WriteLine("Finished");
#endregion
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
示例7: AsyncMain
static async Task AsyncMain()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.MessageMutators");
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.SendFailedMessagesTo("error");
#region ComponentRegistartion
busConfiguration.RegisterComponents(components =>
{
components.ConfigureComponent<ValidationMessageMutator>(DependencyLifecycle.InstancePerCall);
components.ConfigureComponent<TransportMessageCompressionMutator>(DependencyLifecycle.InstancePerCall);
});
#endregion
IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);
try
{
IBusSession busSession = endpoint.CreateBusSession();
await Runner.Run(busSession);
}
finally
{
await endpoint.Stop();
}
}
示例8: Main
static void Main()
{
Console.Title = "Samples.Logging.CommonLogging";
#region ConfigureLogging
Common.Logging.LogManager.Adapter = new ConsoleOutLoggerFactoryAdapter
{
Level = LogLevel.Info
};
NServiceBus.Logging.LogManager.Use<CommonLoggingFactory>();
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Logging.CommonLogging");
#endregion
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<InMemoryPersistence>();
using (var bus = Bus.Create(busConfiguration).Start())
{
var myMessage = new MyMessage();
bus.SendLocal(myMessage);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
示例9: AsyncMain
static async Task AsyncMain()
{
#region non-transactional
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.UseTransport<MsmqTransport>()
.Transactions(TransportTransactionMode.None);
#endregion
busConfiguration.EndpointName("Samples.MessageDurability.Sender");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.SendFailedMessagesTo("error");
IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);
try
{
IBusSession busSession = endpoint.CreateBusSession();
await busSession.Send("Samples.MessageDurability.Receiver", new MyMessage());
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpoint.Stop();
}
}
示例10: SetUp
public void SetUp()
{
Builder = new FuncBuilder();
InMemoryFaultManager = new NServiceBus.Faults.InMemory.FaultManager();
FakeReceiver = new FakeReceiver();
var configurationBuilder = new BusConfiguration();
configurationBuilder.EndpointName("xyz");
configurationBuilder.AssembliesToScan(new Assembly[0]);
Transport = new TransportReceiver(new TransactionSettings(true, TimeSpan.FromSeconds(30), IsolationLevel.ReadCommitted, 5, false, false), 1, 0, FakeReceiver, InMemoryFaultManager, new SettingsHolder(), configurationBuilder.BuildConfiguration());
RegisterTypes();
Builder.Register<IManageMessageFailures>(() => InMemoryFaultManager);
Builder.Register<TransportReceiver>(() => Transport);
//var configurer = new SatelliteConfigurer();
//configurer.Customize(configure);
var launcher = new SatelliteLauncher(Builder);
BeforeRun();
launcher.Start();
}
示例11: Main
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.FullDuplex.Client");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.EnableInstallers();
using (IBus bus = Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press 'Enter' to send a message.To exit, Ctrl + C");
#region ClientLoop
while (Console.ReadLine() != null)
{
Guid g = Guid.NewGuid();
Console.WriteLine("Requesting to get data by id: {0}", g.ToString("N"));
RequestDataMessage message = new RequestDataMessage
{
DataId = g,
String = "<node>it's my \"node\" & i like it<node>"
};
bus.Send("Samples.FullDuplex.Server", message);
}
#endregion
}
}
示例12: Init
public static void Init()
{
if (Bus != null)
return;
lock (SyncLock)
{
if (Bus != null)
return;
var cfg = new BusConfiguration();
cfg.EndpointName(MethodBase.GetCurrentMethod().DeclaringType.Namespace);
cfg.UseTransport<MsmqTransport>();
cfg.UsePersistence<InMemoryPersistence>();
cfg.EnableInstallers();
cfg.UseSerialization<JsonSerializer>();
cfg.Conventions()
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith(".Messages"))
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Commands"))
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Events"));
Bus = NServiceBus.Bus.Create(cfg).Start();
}
}
示例13: Main
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.FaultTolerance.Client");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<InMemoryPersistence>();
using (IBus bus = Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press 'Enter' to send a message.To exit, Ctrl + C");
while (Console.ReadLine() != null)
{
Guid id = Guid.NewGuid();
bus.Send("Samples.FaultTolerance.Server", new MyMessage
{
Id = id
});
Console.WriteLine("Sent a new message with id: {0}", id.ToString("N"));
}
}
}
示例14: Main
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.StepByStep.Server");
busConfiguration.UseSerialization<JsonSerializer>();
/*
* JSON
* XML
* Binary
*/
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<InMemoryPersistence>();
/*
* InMemory
* MSMQ
* RavenDB
* NHibernate
* Azure Storage
*/
using (IBus bus = Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
示例15: AsyncMain
static async Task AsyncMain()
{
#region ContainerConfiguration
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Castle");
WindsorContainer container = new WindsorContainer();
container.Register(Component.For<MyService>().Instance(new MyService()));
busConfiguration.UseContainer<WindsorBuilder>(c => c.ExistingContainer(container));
#endregion
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.SendFailedMessagesTo("error");
busConfiguration.EnableInstallers();
IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);
try
{
await endpoint.SendLocal(new MyMessage());
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpoint.Stop();
}
}