本文整理汇总了C#中EndpointConfiguration.EnableOutbox方法的典型用法代码示例。如果您正苦于以下问题:C# EndpointConfiguration.EnableOutbox方法的具体用法?C# EndpointConfiguration.EnableOutbox怎么用?C# EndpointConfiguration.EnableOutbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndpointConfiguration
的用法示例。
在下文中一共展示了EndpointConfiguration.EnableOutbox方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Usage
Usage(EndpointConfiguration endpointConfiguration)
{
#region OutboxEnablineInCode
endpointConfiguration.EnableOutbox();
#endregion
}
示例2: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.SQLNHibernateOutboxEF.Receiver";
using (ReceiverDataContext ctx = new ReceiverDataContext())
{
ctx.Database.Initialize(true);
}
Configuration hibernateConfig = new Configuration();
hibernateConfig.DataBaseIntegration(x =>
{
x.ConnectionStringName = "NServiceBus/Persistence";
x.Dialect<MsSql2012Dialect>();
});
hibernateConfig.SetProperty("default_schema", "receiver");
EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.SQLNHibernateOutboxEF.Receiver");
endpointConfiguration.UseSerialization<JsonSerializer>();
#region ReceiverConfiguration
endpointConfiguration
.UseTransport<SqlServerTransport>()
.DefaultSchema("receiver")
.UseSpecificSchema(queueName =>
{
if (queueName.Equals("error", StringComparison.OrdinalIgnoreCase) || queueName.Equals("audit", StringComparison.OrdinalIgnoreCase))
{
return "dbo";
}
if (queueName.Equals("Samples.SQLNHibernateOutboxEF.Sender", StringComparison.OrdinalIgnoreCase))
{
return "sender";
}
return null;
});
endpointConfiguration
.UsePersistence<NHibernatePersistence>();
endpointConfiguration.EnableOutbox();
#endregion
IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
try
{
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpoint.Stop();
}
}
示例3: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.SQLNHibernateOutbox.Receiver";
#region NHibernate
var hibernateConfig = new Configuration();
hibernateConfig.DataBaseIntegration(x =>
{
x.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True";
x.Dialect<MsSql2012Dialect>();
});
var mapper = new ModelMapper();
mapper.AddMapping<OrderMap>();
hibernateConfig.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
#endregion
new SchemaExport(hibernateConfig).Execute(false, true, false);
var endpointConfiguration = new EndpointConfiguration("Samples.SQLNHibernateOutbox.Receiver");
endpointConfiguration.UseSerialization<JsonSerializer>();
#region ReceiverConfiguration
var transport = endpointConfiguration.UseTransport<SqlServerTransport>();
transport.ConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True");
var persistence = endpointConfiguration.UsePersistence<NHibernatePersistence>();
persistence.UseConfiguration(hibernateConfig);
endpointConfiguration.EnableOutbox();
#endregion
#region RetriesConfiguration
endpointConfiguration.DisableFeature<FirstLevelRetries>();
endpointConfiguration.DisableFeature<SecondLevelRetries>();
#endregion
endpointConfiguration.SendFailedMessagesTo("error");
endpointConfiguration.AuditProcessedMessagesTo("audit");
var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
try
{
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpointInstance.Stop()
.ConfigureAwait(false);
}
}
示例4: Usage
public Usage()
{
#region OutboxEnablineInCode
EndpointConfiguration configuration = new EndpointConfiguration();
configuration.EnableOutbox();
#endregion
}
示例5: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.MultiTenant.Sender";
const string letters = "ABCDEFGHIJKLMNOPQRSTUVXYZ";
var random = new Random();
var endpointConfiguration = new EndpointConfiguration("Samples.MultiTenant.Sender");
endpointConfiguration.UseSerialization<JsonSerializer>();
endpointConfiguration.SendFailedMessagesTo("error");
endpointConfiguration.UsePersistence<NHibernatePersistence>();
endpointConfiguration.EnableOutbox();
var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
try
{
Console.WriteLine("Press A or B to publish a message (A and B are tenant IDs)");
var acceptableInput = new List<char> { 'A', 'B' };
while (true)
{
var key = Console.ReadKey();
Console.WriteLine();
var uppercaseKey = char.ToUpperInvariant(key.KeyChar);
if (acceptableInput.Contains(uppercaseKey))
{
var orderId = new string(Enumerable.Range(0, 4).Select(x => letters[random.Next(letters.Length)]).ToArray());
var message = new OrderSubmitted
{
OrderId = orderId,
Value = random.Next(100)
};
var options = new PublishOptions();
options.SetHeader("TenantId", uppercaseKey.ToString());
await endpointInstance.Publish(message, options)
.ConfigureAwait(false);
}
else
{
Console.WriteLine($"[{uppercaseKey}] is not a valid tenant identifier.");
}
}
}
finally
{
await endpointInstance.Stop()
.ConfigureAwait(false);
}
}
示例6: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.SQLNHibernateOutbox.Sender";
const string letters = "ABCDEFGHIJKLMNOPQRSTUVXYZ";
Random random = new Random();
EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.SQLNHibernateOutbox.Sender");
endpointConfiguration.UseSerialization<JsonSerializer>();
#region SenderConfiguration
endpointConfiguration
.UseTransport<SqlServerTransport>()
.ConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True");
endpointConfiguration
.UsePersistence<NHibernatePersistence>()
.ConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True");
endpointConfiguration.EnableOutbox();
#endregion
endpointConfiguration.DisableFeature<FirstLevelRetries>();
endpointConfiguration.DisableFeature<SecondLevelRetries>();
endpointConfiguration.SendFailedMessagesTo("error");
endpointConfiguration.AuditProcessedMessagesTo("audit");
IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
try
{
Console.WriteLine("Press enter to publish a message");
Console.WriteLine("Press any key to exit");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
Console.WriteLine();
if (key.Key != ConsoleKey.Enter)
{
return;
}
string orderId = new string(Enumerable.Range(0, 4).Select(x => letters[random.Next(letters.Length)]).ToArray());
await endpoint.Publish(new OrderSubmitted
{
OrderId = orderId,
Value = random.Next(100)
});
}
}
finally
{
await endpoint.Stop();
}
}