本文整理汇总了C#中IBus.SendLocal方法的典型用法代码示例。如果您正苦于以下问题:C# IBus.SendLocal方法的具体用法?C# IBus.SendLocal怎么用?C# IBus.SendLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBus
的用法示例。
在下文中一共展示了IBus.SendLocal方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run(IBus bus)
{
Console.WriteLine("Press 's' to send a valid message");
Console.WriteLine("Press 'e' to send a failed message");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
Console.WriteLine();
switch (key.Key)
{
case ConsoleKey.S:
#region SendingSmall
bus.SendLocal(new CreateProductCommand
{
ProductId = "XJ128",
ProductName = "Milk",
ListPrice = 4,
// 7MB. MSMQ should throw an exception, but it will not since the buffer will be compressed
// before it reaches MSMQ.
Image = new byte[1024 * 1024 * 7]
});
#endregion
break;
case ConsoleKey.E:
try
{
#region SendingLarge
bus.SendLocal(new CreateProductCommand
{
ProductId = "XJ128",
ProductName = "Really long product name",
ListPrice = 15,
// 7MB. MSMQ should throw an exception, but it will not since the buffer will be compressed
// before it reaches MSMQ.
Image = new byte[1024 * 1024 * 7]
});
#endregion
}
catch
{
//so the console keeps on running
}
break;
default:
{
return;
}
}
}
}
示例2: Start
static void Start(IBus bus)
{
Console.WriteLine("Press 'p' to Publish MyEvent");
Console.WriteLine("Press 's' to SendLocal MyMessage");
Console.WriteLine("Press any other key to exit");
while (true)
{
var key = Console.ReadKey();
Console.WriteLine();
var id = Guid.NewGuid();
if (key.Key == ConsoleKey.P)
{
var myEvent = new MyEvent
{
Id = id,
};
bus.Publish(myEvent);
Console.WriteLine("Published MyEvent with Id {0}.", id);
continue;
}
if (key.Key == ConsoleKey.S)
{
var eventMessage = new MyMessage
{
Id = id,
};
bus.SendLocal(eventMessage);
Console.WriteLine("Sent MyMessage with Id {0}.", id);
continue;
}
return;
}
}
示例3: Run
public static void Run(IBus bus)
{
Console.WriteLine("Press 's' to send a valid message, press 'e' to send a failed message. To exit, 'q'\n");
string cmd;
while ((cmd = Console.ReadKey().Key.ToString().ToLower()) != "q")
{
Console.WriteLine();
switch (cmd)
{
case "s":
#region SendingSmall
bus.SendLocal(new CreateProductCommand
{
ProductId = "XJ128",
ProductName = "Milk",
ListPrice = 4,
// 7MB. MSMQ should throw an exception, but it will not since the buffer will be compressed
// before it reaches MSMQ.
Image = new byte[1024*1024*7]
});
#endregion
break;
case "e":
try
{
#region SendingLarge
bus.SendLocal(new CreateProductCommand
{
ProductId = "XJ128",
ProductName = "Really long product name",
ListPrice = 15,
// 7MB. MSMQ should throw an exception, but it will not since the buffer will be compressed
// before it reaches MSMQ.
Image = new byte[1024*1024*7]
});
#endregion
}
catch
{
//so the console keeps on running
}
break;
}
}
}
示例4: SendMessage
static void SendMessage(IBus bus)
{
var message = new Message();
bus.SendLocal(message);
Console.WriteLine();
Console.WriteLine("Message sent");
}
示例5: SetMessageHeader
void SetMessageHeader(IBus bus)
{
#region 3to4SetMessageHeader
MyMessage myMessage = new MyMessage();
myMessage.SetHeader("SendingMessage", "ValueSendingMessage");
bus.SendLocal(myMessage);
#endregion
}
示例6: OnStart
protected override void OnStart(string[] args)
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.WindowsServiceAndConsole");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.EnableInstallers();
bus = Bus.Create(busConfiguration).Start();
// run any startup actions on the bus
bus.SendLocal(new MyMessage());
}
示例7: OnStart
protected override void OnStart(string[] args)
{
Configure configure = Configure.With();
configure.Log4Net();
configure.DefineEndpointName("Samples.WindowsServiceAndConsole");
configure.Log4Net();
configure.DefaultBuilder();
configure.Sagas();
configure.MsmqTransport();
configure.InMemorySagaPersister();
configure.RunTimeoutManagerWithInMemoryPersistence();
configure.InMemorySubscriptionStorage();
configure.JsonSerializer();
bus = configure.UnicastBus()
.CreateBus()
.Start(() => configure.ForInstallationOn<Windows>().Install());
// run any startup actions on the bus
bus.SendLocal(new MyMessage());
}
示例8: OnStart
protected override void OnStart(string[] args)
{
Configure.Serialization.Json();
Configure.Features.Enable<Sagas>();
var configure = Configure.With();
configure.Log4Net();
configure.DefineEndpointName("Samples.WindowsServiceAndConsole");
configure.DefaultBuilder();
configure.InMemorySagaPersister();
configure.UseInMemoryTimeoutPersister();
configure.InMemorySubscriptionStorage();
configure.UseTransport<Msmq>();
bus = configure.UnicastBus()
.CreateBus()
.Start(() => configure.ForInstallationOn<Windows>().Install());
// run any startup actions on the bus
var myMessage = new MyMessage();
bus.SendLocal(myMessage);
}
示例9: Run
public void Run(IBus bus)
{
log.Info("Sending Message.");
bus.SendLocal(new MyMessage());
}
示例10: OnStart
protected override void OnStart(string[] args)
{
#region logging
PatternLayout layout = new PatternLayout
{
ConversionPattern = "%d %-5p %c - %m%n"
};
layout.ActivateOptions();
ConsoleAppender appender = new ConsoleAppender
{
Layout = layout,
Threshold = Level.Info
};
appender.ActivateOptions();
BasicConfigurator.Configure(appender);
LogManager.Use<Log4NetFactory>();
#endregion
#region create-config
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.FirstEndpoint");
#endregion
#region container
ContainerBuilder builder = new ContainerBuilder();
//configure custom services
//builder.RegisterInstance(new MyService());
IContainer container = builder.Build();
busConfiguration.UseContainer<AutofacBuilder>(c => c.ExistingLifetimeScope(container));
#endregion
#region serialization
busConfiguration.UseSerialization<JsonSerializer>();
#endregion
#region transport
busConfiguration.UseTransport<MsmqTransport>();
#endregion
#region persistence
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Sagas>();
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Subscriptions>();
busConfiguration.UsePersistence<InMemoryPersistence, StorageType.Timeouts>();
#endregion
#region critical-errors
busConfiguration.DefineCriticalErrorAction((errorMessage, exception) =>
{
// Log the critical error
logger.Fatal(string.Format("CRITICAL: {0}", errorMessage), exception);
// Kill the process on a critical error
string output = string.Format("The following critical error was encountered by NServiceBus:\n{0}\nNServiceBus is shutting down.", errorMessage);
Environment.FailFast(output, exception);
});
#endregion
#region start-bus
busConfiguration.EnableInstallers();
bus = Bus.Create(busConfiguration).Start();
#endregion
bus.SendLocal(new MyMessage());
}
示例11: OnStart
protected override void OnStart(string[] args)
{
#region logging
PatternLayout layout = new PatternLayout
{
ConversionPattern = "%d %-5p %c - %m%n"
};
layout.ActivateOptions();
ConsoleAppender appender = new ConsoleAppender
{
Layout = layout,
Threshold = Level.Info
};
appender.ActivateOptions();
BasicConfigurator.Configure(appender);
SetLoggingLibrary.Log4Net();
#endregion
#region create-config
Configure configure = Configure.With();
configure.DefineEndpointName("Samples.FirstEndpoint");
#endregion
#region container
ContainerBuilder builder = new ContainerBuilder();
//configure custom services
//builder.RegisterInstance(new MyService());
IContainer container = builder.Build();
configure.AutofacBuilder(container);
#endregion
#region serialization
configure.JsonSerializer();
#endregion
#region transport
configure.MsmqTransport();
#endregion
#region sagas
configure.Sagas();
#endregion
#region persistence
configure.InMemorySagaPersister();
configure.UseInMemoryTimeoutPersister();
configure.InMemorySubscriptionStorage();
#endregion
#region critical-errors
Configure.Instance.DefineCriticalErrorAction(() =>
{
//Write log entry in version 3 since this is not done by default.
logger.Fatal("CRITICAL Error");
// Kill the process on a critical error
string output = "Critical error was encountered by NServiceBus:\nNServiceBus is shutting down.";
Environment.FailFast(output);
});
#endregion
#region start-bus
bus = configure.UnicastBus()
.CreateBus()
.Start(() => configure.ForInstallationOn<Windows>().Install());
#endregion
bus.SendLocal(new MyMessage());
}
示例12: OnStart
protected override void OnStart(string[] args)
{
#region logging
PatternLayout layout = new PatternLayout
{
ConversionPattern = "%d %-5p %c - %m%n"
};
layout.ActivateOptions();
ConsoleAppender appender = new ConsoleAppender
{
Layout = layout,
Threshold = Level.Info
};
appender.ActivateOptions();
BasicConfigurator.Configure(appender);
SetLoggingLibrary.Log4Net();
#endregion
#region create-config
Configure configure = Configure.With();
#endregion
#region endpoint-name
configure.DefineEndpointName("Samples.FirstEndpoint");
#endregion
#region container
ContainerBuilder builder = new ContainerBuilder();
//configure your custom services
//builder.RegisterInstance(new MyService());
IContainer container = builder.Build();
configure.AutofacBuilder(container);
#endregion
#region serialization
Configure.Serialization.Json();
#endregion
#region transport
configure.UseTransport<Msmq>();
#endregion
#region sagas
Configure.Features.Enable<Sagas>();
#endregion
#region persistence
configure.InMemorySagaPersister();
configure.UseInMemoryTimeoutPersister();
configure.InMemorySubscriptionStorage();
#endregion
#region critical-errors
Configure.Instance.DefineCriticalErrorAction((errorMessage, exception) =>
{
// Log the critical error
logger.Fatal(string.Format("CRITICAL: {0}", errorMessage), exception);
// Kill the process on a critical error
string output = string.Format("The following critical error was encountered by NServiceBus:\n{0}\nNServiceBus is shutting down.", errorMessage);
Environment.FailFast(output, exception);
});
#endregion
#region start-bus
bus = configure.UnicastBus()
.CreateBus()
.Start(() => configure.ForInstallationOn<Windows>().Install());
#endregion
bus.SendLocal(new MyMessage());
}
示例13: Run
public void Run(IBus bus)
{
log.Info("Sending Message.");
var myMessage = new MyMessage();
bus.SendLocal(myMessage);
}