本文整理汇总了C#中MyMessage类的典型用法代码示例。如果您正苦于以下问题:C# MyMessage类的具体用法?C# MyMessage怎么用?C# MyMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyMessage类属于命名空间,在下文中一共展示了MyMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.Logging.CustomFactory";
#region ConfigureLogging
var loggerDefinition = LogManager.Use<ConsoleLoggerDefinition>();
// optionally set the log level in code or read from app.config
loggerDefinition.Level(LogLevel.Info);
// logging configuration should occur prior to endpoint configuration
var endpointConfiguration = new EndpointConfiguration("Samples.Logging.CustomFactory");
#endregion
endpointConfiguration.SendFailedMessagesTo("error");
endpointConfiguration.UseSerialization<JsonSerializer>();
endpointConfiguration.EnableInstallers();
endpointConfiguration.UsePersistence<InMemoryPersistence>();
var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
try
{
var myMessage = new MyMessage();
await endpointInstance.SendLocal(myMessage)
.ConfigureAwait(false);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpointInstance.Stop()
.ConfigureAwait(false);
}
}
示例2: Main
static void Main()
{
LogManager.Use<DefaultFactory>()
.Level(LogLevel.Warn);
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.ErrorHandling.WithSLR");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.EnableInstallers();
using (IBus bus = Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press enter to send a message that will throw an exception.");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
if (key.Key != ConsoleKey.Enter)
{
return;
}
MyMessage m = new MyMessage
{
Id = Guid.NewGuid()
};
bus.SendLocal(m);
}
}
}
示例3: Main
static void Main()
{
Console.Title = "Samples.Spring";
Configure.Serialization.Json();
#region ContainerConfiguration
var configure = Configure.With();
configure.Log4Net();
configure.DefineEndpointName("Samples.Spring");
var applicationContext = new GenericApplicationContext();
applicationContext.ObjectFactory.RegisterSingleton("MyService", new MyService());
configure.SpringFrameworkBuilder(applicationContext);
#endregion
configure.InMemorySagaPersister();
configure.UseInMemoryTimeoutPersister();
configure.InMemorySubscriptionStorage();
configure.UseTransport<Msmq>();
using (var startableBus = configure.UnicastBus().CreateBus())
{
var bus = startableBus.Start(() => configure.ForInstallationOn<Windows>().Install());
var myMessage = new MyMessage();
bus.SendLocal(myMessage);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
示例4: Main
static void Main()
{
Console.Title = "Samples.Logging.SerilogCustom";
#region ConfigureSerilog
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.File("logFile.txt")
.CreateLogger();
#endregion
#region UseConfig
LogManager.Use<SerilogFactory>();
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Logging.SerilogCustom");
#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();
}
}
示例5: AsyncMain
static async Task AsyncMain()
{
LogManager.Use<DefaultFactory>()
.Level(LogLevel.Warn);
#region DisableSLR
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.ErrorHandling.WithoutSLR");
busConfiguration.DisableFeature<SecondLevelRetries>();
#endregion
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.EnableInstallers();
busConfiguration.SendFailedMessagesTo("error");
using (IBus bus = await Bus.Create(busConfiguration).StartAsync())
{
Console.WriteLine("Press enter to send a message that will throw an exception.");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
if (key.Key != ConsoleKey.Enter)
{
return;
}
MyMessage m = new MyMessage
{
Id = Guid.NewGuid()
};
await bus.SendLocalAsync(m);
}
}
}
示例6: Main
static void Main()
{
Console.Title = "Samples.Castle";
#region ContainerConfiguration
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Castle");
var 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.EnableInstallers();
using (var bus = Bus.Create(busConfiguration).Start())
{
var myMessage = new MyMessage();
bus.SendLocal(myMessage);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
示例7: SendMessage
public void SendMessage(int number)
{
MyMessage msg = new MyMessage();
msg.number = number;
myClient.Send(MyMsgType.CustomMsgType, msg);
}
示例8: Start
static async Task Start()
{
Console.Title = "Samples.Ninject";
#region ContainerConfiguration
var endpointConfiguration = new EndpointConfiguration("Samples.Ninject");
endpointConfiguration.SendFailedMessagesTo("error");
var kernel = new StandardKernel();
kernel.Bind<MyService>().ToConstant(new MyService());
endpointConfiguration.UseContainer<NinjectBuilder>(c => c.ExistingKernel(kernel));
#endregion
endpointConfiguration.UseSerialization<JsonSerializer>();
endpointConfiguration.UsePersistence<InMemoryPersistence>();
endpointConfiguration.EnableInstallers();
var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
try
{
var myMessage = new MyMessage();
await endpointInstance.SendLocal(myMessage)
.ConfigureAwait(false);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpointInstance.Stop()
.ConfigureAwait(false);
}
}
示例9: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.Unity";
#region ContainerConfiguration
var endpointConfiguration = new EndpointConfiguration("Samples.Unity");
var container = new UnityContainer();
container.RegisterInstance(new MyService());
endpointConfiguration.UseContainer<UnityBuilder>(c => c.UseExistingContainer(container));
#endregion
endpointConfiguration.UseSerialization<JsonSerializer>();
endpointConfiguration.UsePersistence<InMemoryPersistence>();
endpointConfiguration.EnableInstallers();
endpointConfiguration.SendFailedMessagesTo("error");
var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
try
{
var myMessage = new MyMessage();
await endpointInstance.SendLocal(myMessage)
.ConfigureAwait(false);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpointInstance.Stop()
.ConfigureAwait(false);
}
}
示例10: Main
static void Main()
{
Console.Title = "Samples.ErrorHandling.WithSLR";
Configure.Serialization.Json();
Configure configure = Configure.With();
configure.Log4Net();
configure.DefineEndpointName("Samples.ErrorHandling.WithSLR");
configure.DefaultBuilder();
configure.InMemorySagaPersister();
configure.UseInMemoryTimeoutPersister();
configure.InMemorySubscriptionStorage();
configure.UseTransport<Msmq>();
using (IStartableBus startableBus = configure.UnicastBus().CreateBus())
{
IBus bus = startableBus
.Start(() => configure.ForInstallationOn<Windows>().Install());
Console.WriteLine("Press enter to send a message that will throw an exception.");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
if (key.Key != ConsoleKey.Enter)
{
return;
}
MyMessage m = new MyMessage
{
Id = Guid.NewGuid()
};
bus.SendLocal(m);
}
}
}
示例11: Main
static void Main()
{
LogManager.Use<DefaultFactory>()
.Level(LogLevel.Warn);
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.ErrorHandling.WithoutSLR");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.DisableFeature<SecondLevelRetries>();
busConfiguration.EnableInstallers();
using (IBus bus = Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press any key to send a message that will throw an exception.");
Console.WriteLine("To exit, press Ctrl + C");
while (true)
{
Console.ReadLine();
MyMessage m = new MyMessage
{
Id = Guid.NewGuid()
};
bus.SendLocal(m);
}
}
}
示例12: Main
static void Main()
{
Console.Title = "Samples.Logging.CustomFactory";
#region ConfigureLogging
var loggerDefinition = LogManager.Use<ConsoleLoggerDefinition>();
// optionally set the log level in code or read from app.config
loggerDefinition.Level(LogLevel.Info);
// logging configuration should occur prior to endpoint configuration
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Logging.CustomFactory");
#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();
}
}
示例13: Main
static void Main()
{
Console.Title = "Samples.Castle";
Configure.Serialization.Json();
#region ContainerConfiguration
var configure = Configure.With();
configure.Log4Net();
configure.DefineEndpointName("Samples.Castle");
var container = new WindsorContainer();
container.Register(Component.For<MyService>().Instance(new MyService()));
configure.CastleWindsorBuilder(container);
#endregion
configure.InMemorySagaPersister();
configure.UseInMemoryTimeoutPersister();
configure.InMemorySubscriptionStorage();
configure.UseTransport<Msmq>();
using (var startableBus = configure.UnicastBus().CreateBus())
{
var bus = startableBus.Start(() => configure.ForInstallationOn<Windows>().Install());
var myMessage = new MyMessage();
bus.SendLocal(myMessage);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
示例14: Main
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Headers");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.RegisterComponents(components =>
{
components.ConfigureComponent<MutateIncomingMessages>(DependencyLifecycle.InstancePerCall);
components.ConfigureComponent<MutateIncomingTransportMessages>(DependencyLifecycle.InstancePerCall);
components.ConfigureComponent<MutateOutgoingMessages>(DependencyLifecycle.InstancePerCall);
components.ConfigureComponent<MutateOutgoingTransportMessages>(DependencyLifecycle.InstancePerCall);
});
#region global-all-outgoing
busConfiguration.AddHeaderToAllOutgoingMessages("AllOutgoing", "ValueAllOutgoing");
IStartableBus startableBus = Bus.Create(busConfiguration);
using (IBus bus = startableBus.Start())
{
#endregion
#region sending
MyMessage myMessage = new MyMessage();
bus.SendLocal(myMessage);
#endregion
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
示例15: Should_run_a_batch_nicely
public void Should_run_a_batch_nicely()
{
const int batchSize = 10000;
var callbackCount = 0;
var stopwatch = new Stopwatch();
stopwatch.Start();
using (var channel = bus.OpenPublishChannel(x => x.WithPublisherConfirms()))
{
for (int i = 0; i < batchSize; i++)
{
var message = new MyMessage {Text = string.Format("Hello Message {0}", i)};
channel.Publish(message, x =>
x.OnSuccess(() => {
callbackCount++;
})
.OnFailure(() =>
{
callbackCount++;
}));
}
// wait until all the publications have been acknowleged.
while (callbackCount < batchSize)
{
if (stopwatch.Elapsed.Seconds > 10)
{
throw new ApplicationException("Aborted batch with timeout");
}
Thread.Sleep(10);
}
}
}