本文整理汇总了C#中BusConfiguration.UseSerialization方法的典型用法代码示例。如果您正苦于以下问题:C# BusConfiguration.UseSerialization方法的具体用法?C# BusConfiguration.UseSerialization怎么用?C# BusConfiguration.UseSerialization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BusConfiguration
的用法示例。
在下文中一共展示了BusConfiguration.UseSerialization方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllTheSerialization
public void AllTheSerialization()
{
#region ConfigureSerialization
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.UseSerialization<BinarySerializer>();
busConfiguration.UseSerialization<BsonSerializer>();
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UseSerialization<XmlSerializer>();
#endregion
}
示例2: 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");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
if (key.Key != ConsoleKey.Enter)
{
return;
}
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"));
}
}
}
示例3: AsyncMain
static async Task AsyncMain()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.RavenDB.Client");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<InMemoryPersistence>();
IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);
Console.WriteLine("Press 'enter' to send a StartOrder messages");
Console.WriteLine("Press any other key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
break;
}
Guid orderId = Guid.NewGuid();
await endpoint.Send(new StartOrder
{
OrderId = orderId
});
Console.WriteLine("StartOrder Message sent with OrderId " + orderId);
}
await endpoint.Stop();
}
示例4: Main
static void Main()
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.DataBus.Sender");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UseDataBus<FileShareDataBus>().BasePath(BasePath);
busConfiguration.UsePersistence<InMemoryPersistence>();
busConfiguration.EnableInstallers();
using (IBus bus = Bus.Create(busConfiguration).Start())
{
Console.WriteLine("Press 'D' to send a databus large message");
Console.WriteLine("Press 'N' to send a normal large message exceed the size limit and throw");
Console.WriteLine("Press any other key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
if (key.Key == ConsoleKey.N)
{
SendMessageTooLargePayload(bus);
continue;
}
if (key.Key == ConsoleKey.D)
{
SendMessageLargePayload(bus);
continue;
}
return;
}
}
}
示例5: Main
static void Main()
{
var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName( "UserInterface" );
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.UsePersistence<NHibernatePersistence>();
busConfiguration.Conventions()
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Commands"))
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith(".Events"));
//TODO: talk about encryption of sensitive data
//.DefiningEncryptedPropertiesAs(t => t.Name.Equals("Password"));
if( Environment.UserInteractive && Debugger.IsAttached )
{
busConfiguration.EnableInstallers();
}
using( var bus = Bus.Create( busConfiguration ).Start() )
{
Console.ReadKey();
}
}
示例6: 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);
}
}
}
示例7: AsyncMain
static async Task AsyncMain()
{
using (new RavenHost())
{
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.RavenDBCustomSagaFinder");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.SendFailedMessagesTo("error");
DocumentStore documentStore = new DocumentStore
{
Url = "http://localhost:32076",
DefaultDatabase = "NServiceBus"
};
documentStore.RegisterListener(new UniqueConstraintsStoreListener());
documentStore.Initialize();
busConfiguration.UsePersistence<RavenDBPersistence>()
.DoNotSetupDatabasePermissions() //Only required to simplify the sample setup
.SetDefaultDocumentStore(documentStore);
IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);
await endpoint.SendLocal(new StartOrder
{
OrderId = "123"
});
Console.WriteLine("Press any key to exit");
Console.ReadKey();
await endpoint.Stop();
}
}
示例8: Run
public static void Run(
int maximumNumberOfTweetsPerCatchUp,
TimeSpan defaultTransactionTimeout,
string nserviceBusConnectionString,
string endpointName,
string consumerKey,
string consumerSecret,
string accessToken,
string accessTokenSecret)
{
var busConfiguration = new BusConfiguration();
busConfiguration.Transactions().DoNotWrapHandlersExecutionInATransactionScope();
busConfiguration.Transactions().DefaultTimeout(defaultTransactionTimeout);
busConfiguration.EndpointName(endpointName);
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<NHibernatePersistence>().ConnectionString(nserviceBusConnectionString);
busConfiguration.ApplyMessageConventions();
busConfiguration.RegisterComponents(c=>c.RegisterSingleton<ITweetService>(
new TweetService(maximumNumberOfTweetsPerCatchUp, consumerKey, consumerSecret, accessToken, accessTokenSecret)));
using (Bus.Create(busConfiguration).Start())
{
Console.ReadLine();
}
}
示例9: 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
}
}
示例10: 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();
}
}
示例11: 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"));
}
}
}
示例12: 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();
}
}
示例13: 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();
}
}
}
示例14: AsyncMain
static async Task AsyncMain()
{
#region ConfigureLogging
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Logging.Default");
//Note that no config is required in version 5 and higher since logging is enabled by default
#endregion
busConfiguration.SendFailedMessagesTo("error");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<InMemoryPersistence>();
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();
}
}
示例15: AsyncMain
static async Task AsyncMain()
{
#region logging
DefaultFactory defaultFactory = LogManager.Use<DefaultFactory>();
defaultFactory.Level(LogLevel.Fatal);
#endregion
BusConfiguration busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.Logging.Default");
busConfiguration.SendFailedMessagesTo("error");
busConfiguration.UseSerialization<JsonSerializer>();
busConfiguration.EnableInstallers();
busConfiguration.UsePersistence<InMemoryPersistence>();
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();
}
}