本文整理汇总了C#中QueueDescription类的典型用法代码示例。如果您正苦于以下问题:C# QueueDescription类的具体用法?C# QueueDescription怎么用?C# QueueDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueueDescription类属于命名空间,在下文中一共展示了QueueDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
MefLoader.Initialize();
// Create the queue if it does not exist already
string connectionString = CloudConfigurationManager.GetSetting("ServiceBus");
string queueName = ConfigurationsSelector.GetSetting("Customer.Queue");
NamespaceManager namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
QueueDescription queueDescription = new QueueDescription(queueName)
{
MaxSizeInMegabytes = 1024,
DefaultMessageTimeToLive = TimeSpan.FromMinutes(10),
EnablePartitioning = false, //I want to ensure the messages will processed in the right order
EnableDeadLetteringOnMessageExpiration = true,
LockDuration = TimeSpan.FromMinutes(5)
};
if (!namespaceManager.QueueExists(queueName))
namespaceManager.CreateQueue(queueDescription);
// Initialize the connection to Service Bus Queue
_client = QueueClient.CreateFromConnectionString(connectionString, queueName);
return base.OnStart();
}
示例2: Create
public QueueClient Create(Address address)
{
var queueName = address.Queue;
try
{
if (!NamespaceClient.QueueExists(queueName))
{
var description = new QueueDescription(queueName)
{
LockDuration = LockDuration,
MaxSizeInMegabytes = MaxSizeInMegabytes,
RequiresDuplicateDetection = RequiresDuplicateDetection,
RequiresSession = RequiresSession,
DefaultMessageTimeToLive = DefaultMessageTimeToLive,
EnableDeadLetteringOnMessageExpiration = EnableDeadLetteringOnMessageExpiration,
DuplicateDetectionHistoryTimeWindow = DuplicateDetectionHistoryTimeWindow,
MaxDeliveryCount = MaxDeliveryCount,
EnableBatchedOperations = EnableBatchedOperations
};
NamespaceClient.CreateQueue(description);
}
}
catch (MessagingEntityAlreadyExistsException)
{
// the queue already exists or another node beat us to it, which is ok
}
var client = Factory.CreateQueueClient(queueName, ReceiveMode.PeekLock);
client.PrefetchCount = 100; // todo make configurable
return client;
}
开发者ID:modulexcite,项目名称:NServiceBus.WindowsServiceBus,代码行数:32,代码来源:WindowsServicebusQueueClientCreator.cs
示例3: QueueShouldExistAsync
private async static Task QueueShouldExistAsync(NamespaceManager ns, QueueDescription queueDescription)
{
if (!await ns.QueueExistsAsync(queueDescription.Path))
{
throw new MessagingEntityNotFoundException("Queue: " + queueDescription.Path);
}
}
示例4: Newsletter
public ActionResult Newsletter(string email)
{
var nm = NamespaceManager.CreateFromConnectionString(ConnectionString);
QueueDescription qd = new QueueDescription(qname);
qd.MaxSizeInMegabytes = 2048;
qd.DefaultMessageTimeToLive = new TimeSpan(0, 5, 0);
if (!nm.QueueExists(qname))
{
nm.CreateQueue(qd);
}
//Send to the queue
QueueClient qc = QueueClient.CreateFromConnectionString(ConnectionString, qname);
// Create amessage with email property
var bm = new BrokeredMessage();
bm.Properties["email"] = email;
qc.Send(bm);
ViewBag.email = email;
return View();
}
示例5: QueueMessage
private static void QueueMessage(string messageType, VirtualMachine virtualMachine)
{
if (VirtualMachine.IsValid(virtualMachine) == false)
{
throw new ArgumentException("Invalid virtual machine.", "virtualMachine");
}
var connectionString = CloudConfigurationManager.GetSetting("ServiceBus.ConnectionString");
var queueName = CloudConfigurationManager.GetSetting("QueueName");
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.QueueExists(queueName))
{
var queue = new QueueDescription(queueName)
{
DefaultMessageTimeToLive = new TimeSpan(7, 0, 0, 0)
};
namespaceManager.CreateQueue(queue);
}
var message = PrepareMessage(messageType, virtualMachine);
var client = QueueClient.CreateFromConnectionString(connectionString, queueName);
client.Send(message);
}
示例6: LoadConfig
public void LoadConfig()
{
Trace.TraceInformation("Initializing and configuring Azure service bus queue");
string connectionString =
CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
var namespaceManager =
NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.QueueExists(QueueName))
{
namespaceManager.CreateQueue(QueueName);
}
// Configure Queue Settings
QueueDescription qd = new QueueDescription(QueueName)
{
MaxSizeInMegabytes = 5120,
DefaultMessageTimeToLive = new TimeSpan(0, 1, 0)
};
WorkHistoryDataTable = new DataSetMobile.WorkHistoryDataTable();
WorkHistoryTableAdapter = new WorkHistoryTableAdapter();
Trace.TraceInformation("Creating queue client from service bus connection string");
MobleQueueClient =
QueueClient.CreateFromConnectionString(connectionString, QueueName);
}
示例7: Main
static void Main(string[] args)
{
NamespaceManager manager = NamespaceManager.Create(); // Automatycznie bierze informacje z App.config
//Wolę na początku - wygodniej "zaczynamy" zawsze od zera
manager.DeleteTopic("obliczenia"); //Kasuje temat i subskrypcje
manager.DeleteQueue("wynik");
//Tworzenie Topics - tematu
TopicDescription td = new TopicDescription("obliczenia");
//Nie przewidujemy dużego ruchu nie wymagamy partycjonowania
td.EnablePartitioning = false;
//Wymagamy wykrywania duplikatów - by klient 2 razy nie wysłał tego samego polecenia
td.RequiresDuplicateDetection = true;
//Nie pozwalamy na tematy tylko w pamięci; chcemy żeby klient był pewien że wysłał wiadomość = wiadomość zostanie przetworzona
td.EnableExpress = false;
manager.CreateTopic(td); //Tworzenie tematu
//Suma i średnia będzie wyliczana gdy opowiednia własciwość zostanie zdefiniowana
manager.CreateSubscription("obliczenia", "suma", new SqlFilter("suma=1"));
manager.CreateSubscription("obliczenia", "srednia", new SqlFilter("srednia=1"));
//Ale zawsze będą liczone elementy w komunikacie
manager.CreateSubscription("obliczenia", "liczba");
QueueDescription qd = new QueueDescription("wynik");
qd.RequiresSession = true;
manager.CreateQueue(qd);
}
示例8: GetQueuePath
public string GetQueuePath(QueueDescription queueDescription)
{
IEnumerable<string> segments = new[] {_settings.ServiceUri.AbsolutePath.Trim('/'), queueDescription.Path.Trim('/')}
.Where(x => x.Length > 0);
return string.Join("/", segments);
}
示例9: Consumer
public Consumer()
{
Console.Write("Your Service Namespace: ");
string serviceNamespace = Console.ReadLine();
Console.Write("Your Issuer Name: ");
string issuerName = Console.ReadLine();
Console.Write("Your Issuer Secret: ");
string issuerSecret = Console.ReadLine();
// Configure queue settings.
this.queueDescription = new QueueDescription(MyQueuePath);
// Setting Max Size and TTL for demonstration purpose
// but can be changed per user discretion to suite their system needs.
// Refer service bus documentation to understand the limitations.
// Setting Queue max size to 1GB where as default Max Size is 5GB.
this.queueDescription.MaxSizeInMegabytes = 1024;
// Setting message TTL to 5 days where as default TTL is 14 days.
this.queueDescription.DefaultMessageTimeToLive = TimeSpan.FromDays(5);
// Create management credentials.
this.credential = new TransportClientEndpointBehavior()
{
TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret)
};
// Create the URI for the queue.
this.namespaceUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, String.Empty);
Console.WriteLine("Service Bus Namespace Uri address '{0}'", this.namespaceUri.AbsoluteUri);
}
示例10: GetQueryStringOptions
static IEnumerable<string> GetQueryStringOptions(QueueDescription settings)
{
if (settings.EnableExpress)
yield return "express=true";
if (settings.AutoDeleteOnIdle > TimeSpan.Zero)
yield return $"autodelete={settings.AutoDeleteOnIdle.TotalSeconds}";
}
示例11: Connect
public void Connect(string connectionString, string queueName, QueueDescription queueDescription = null)
{
this.VerifyQueue(connectionString, queueName, queueDescription);
this.serviceBus.Connect(connectionString, queueName);
this.AddServiceBusSubscription();
}
示例12: Equals
public bool Equals(QueueDescription other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;
return Equals(other.Path, Path);
}
示例13: GetInputAddress
public static Uri GetInputAddress(this ServiceBusHostSettings hostSettings, QueueDescription queueDescription)
{
var builder = new UriBuilder(hostSettings.ServiceUri);
builder.Path += queueDescription.Path;
builder.Query += string.Join("&", GetQueryStringOptions(queueDescription));
return builder.Uri;
}
示例14: CreateQueue_WhenUserDoesNotHaveManagePermission_UnauthorizedAccessExceptionIsThrown
public void CreateQueue_WhenUserDoesNotHaveManagePermission_UnauthorizedAccessExceptionIsThrown()
{
string queueName = Guid.NewGuid().ToString();
var queue = new QueueDescription(queueName);
NamespaceManager nsManager = GetNamespaceManagerWithCustomCredentials(TestUsers.User1);
Assert.Throws<UnauthorizedAccessException>(() => nsManager.CreateQueue(queue));
}
示例15: EnsureQueueAsync
public async static Task<QueueClient> EnsureQueueAsync(this MessagingFactory factory, QueueDescription queueDescription, ReceiveMode mode = ReceiveMode.PeekLock)
{
await new NamespaceManager(factory.Address, factory.GetSettings().TokenProvider)
.TryCreateEntity(
mgr => QueueCreateAsync(mgr, queueDescription),
mgr => QueueShouldExistAsync(mgr, queueDescription));
return factory.CreateQueueClient(queueDescription.Path, mode);
}