本文整理汇总了C#中MessagingFactory类的典型用法代码示例。如果您正苦于以下问题:C# MessagingFactory类的具体用法?C# MessagingFactory怎么用?C# MessagingFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessagingFactory类属于命名空间,在下文中一共展示了MessagingFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: given_a_messaging_factory
public void given_a_messaging_factory()
{
mf = TestConfigFactory.CreateMessagingFactory();
var nm = TestConfigFactory.CreateNamespaceManager(mf);
nm.TopicExists("my.topic.here").ShouldBeFalse();
}
开发者ID:haf,项目名称:MassTransit-AzureServiceBus,代码行数:7,代码来源:When_getting_client_for_non_existent_topic.cs
示例2: BrokeredTransport
public BrokeredTransport(string connectionString, string inputQueueName)
{
this.connectionString = connectionString;
this.inputQueueName = inputQueueName;
this.factory = MessagingFactory.CreateFromConnectionString(connectionString);
this.queues = new ConcurrentDictionary<string, QueueClient>();
}
示例3: ResponseMessagePump
internal ResponseMessagePump(MessagingFactory messagingFactory, string replyQueueName, RequestResponseCorrelator requestResponseCorrelator, ILogger logger, int batchSize)
: base(logger, batchSize)
{
_messagingFactory = messagingFactory;
_replyQueueName = replyQueueName;
_requestResponseCorrelator = requestResponseCorrelator;
}
示例4: ServiceBusConnection
public ServiceBusConnection(ServiceBusScaleoutConfiguration configuration, TraceSource traceSource)
{
_trace = traceSource;
_connectionString = configuration.BuildConnectionString();
try
{
_namespaceManager = NamespaceManager.CreateFromConnectionString(_connectionString);
_factory = MessagingFactory.CreateFromConnectionString(_connectionString);
if (configuration.RetryPolicy != null)
{
_factory.RetryPolicy = configuration.RetryPolicy;
}
else
{
_factory.RetryPolicy = RetryExponential.Default;
}
}
catch (ConfigurationErrorsException)
{
_trace.TraceError("The configured Service Bus connection string contains an invalid property. Check the exception details for more information.");
throw;
}
_backoffTime = configuration.BackoffTime;
_idleSubscriptionTimeout = configuration.IdleSubscriptionTimeout;
_configuration = configuration;
}
示例5: OpenAsync
public async Task<string> OpenAsync(CancellationToken cancellationToken)
{
var builder = new ServiceBusConnectionStringBuilder(_connectionString)
{
TransportType = TransportType.Amqp
};
_messagingFactory = MessagingFactory.CreateFromConnectionString(builder.ToString());
_eventHubClient = _messagingFactory.CreateEventHubClient(_eventHubName);
_consumerGroup = !string.IsNullOrEmpty(_consumerGroupName)
? _eventHubClient.GetConsumerGroup(_consumerGroupName)
: _eventHubClient.GetDefaultConsumerGroup();
_eventProcessorFactory = new EventProcessorFactory();
_leaseRepository = new ReliableStateLeaseRepository(_reliableStateManager);
_checkpointManager = new CheckpointManager(_leaseRepository);
var allocatedPartitions = await new EventHubPartitionPartitionAllocationStrategy(_serviceName, _partitionId)
.AllocateAsync(_eventHubClient, new FabricClient());
foreach (var partition in allocatedPartitions)
{
var lease = await _leaseRepository.GetOrCreateAsync(_connectionString, _consumerGroupName, _eventHubName, partition);
await _consumerGroup.RegisterProcessorFactoryAsync(lease, _checkpointManager, _eventProcessorFactory);
}
return string.Concat(_eventHubName, " @ ", _connectionString);
}
示例6: RequestMessagePump
public RequestMessagePump(MessagingFactory messagingFactory, IRequestBroker requestBroker, Type messageType, ILogger logger)
: base(logger)
{
_messagingFactory = messagingFactory;
_requestBroker = requestBroker;
_messageType = messageType;
}
示例7: AzureMessageConsumer
protected static void AzureMessageConsumer(MessagingFactory f)
{
//use the already created messaging factory to create a msg receiver
MessageReceiver testQueueReceiver = f.CreateMessageReceiver("colors");
while (true)
{
using (BrokeredMessage retrievedMessage = testQueueReceiver.Receive())
{
try
{
string msgResult = retrievedMessage.GetBody<string>();
//call SP to insert the data into the proper table
InsertSQL(msgResult);
Console.WriteLine("Message received: " + msgResult);
retrievedMessage.Complete();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
retrievedMessage.Abandon();
}
}
}
}
示例8: Init
public async void Init(MessageReceived messageReceivedHandler) {
this.random = new Random();
//ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect;
// Tcp mode does not work when I run in a VM (VirtualBox) and the host
// is using a wireless connection. Hard coding to Http.
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;
string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
this.factory = MessagingFactory.CreateFromConnectionString(connectionString);
this.namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.TopicExists(topicName)) {
namespaceManager.CreateTopic(topicName);
}
this.subscriptionName = Guid.NewGuid().ToString();
// Not needed really, it's a GUID...
if (!namespaceManager.SubscriptionExists(topicName, subscriptionName)) {
namespaceManager.CreateSubscription(topicName, subscriptionName);
}
this.topicClient = factory.CreateTopicClient(topicName);
this.subClient = factory.CreateSubscriptionClient(topicName, subscriptionName);
while (true) {
await ReceiveMessageTaskAsync(messageReceivedHandler);
}
}
示例9: DurableMessageSender
public DurableMessageSender(MessagingFactory messagingFactory, string serviceBusQueueOrTopicName)
{
this.messagingFactory = messagingFactory;
this.sbusEntityName = serviceBusQueueOrTopicName;
// Create a Service Bus queue client to send messages to the Service Bus queue.
this.messageSender = this.messagingFactory.CreateMessageSender(this.sbusEntityName);
// Create MSMQ queue if it doesn't exit. If it does, open the existing MSMQ queue.
this.msmqQueueName = MsmqHelper.CreateMsmqQueueName(this.sbusEntityName, "SEND");
this.msmqQueue = MsmqHelper.GetMsmqQueue(this.msmqQueueName);
// Create MSMQ deadletter queue if it doesn't exit. If it does, open the existing MSMQ deadletter queue.
this.msmqDeadletterQueueName = MsmqHelper.CreateMsmqQueueName(this.sbusEntityName, "SEND_DEADLETTER");
this.msmqDeadletterQueue = MsmqHelper.GetMsmqQueue(this.msmqDeadletterQueueName);
// Initialize wait time after durable client experienced a transient error.
timerWaitTimeInMilliseconds = minTimerWaitTimeInMilliseconds;
// FOR TESTING PURPOSE ONLY.
this.faultInjector = new FaultInjector(enableFaultInjection);
// Start receiving messages from the MSMQ queue.
MsmqPeekBegin();
}
示例10: Connect
public void Connect()
{
Disconnect();
_log.DebugFormat("Connecting '{0}'", _endpointAddress);
if (_messagingFactory == null)
_messagingFactory = _endpointAddress.MessagingFactoryFactory();
// check if it's a queue or a subscription to subscribe either the queue or the subscription?
if (_endpointAddress.QueueDescription != null)
{
_messageSender = _endpointAddress.CreateQueue()
.ContinueWith(t =>
{
t.Wait();
return
_messagingFactory.TryCreateMessageSender(
_endpointAddress.QueueDescription, _prefetchCount)
.Result;
})
.Result;
}
else
{
_messageSender = _messagingFactory.TryCreateMessageSender(_endpointAddress.TopicDescription)
.Result;
}
if (_messageSender == null)
throw new TransportException(_endpointAddress.Uri,
"The create message sender on messaging factory returned null.");
}
示例11: ServiceBusListener
public ServiceBusListener(MessagingFactory messagingFactory, string entityPath, ServiceBusTriggerExecutor triggerExecutor)
{
_messagingFactory = messagingFactory;
_entityPath = entityPath;
_triggerExecutor = triggerExecutor;
_cancellationTokenSource = new CancellationTokenSource();
}
示例12: ReliableClientBase
public ReliableClientBase(string sbNamespace, TokenProvider tokenProvider, string path, RetryPolicy<ServiceBusTransientErrorDetectionStrategy> policy)
{
mRetryPolicy = policy;
Uri address = ServiceBusEnvironment.CreateServiceUri("sb", sbNamespace, string.Empty);
mNamespaceManager = new NamespaceManager(address, tokenProvider);
mMessagingFactory = MessagingFactory.Create(address, tokenProvider);
}
示例13: MulticastRequestMessagePump
public MulticastRequestMessagePump(MessagingFactory messagingFactory, IMulticastRequestBroker multicastRequestBroker, Type requestType, string applicationSharedSubscriptionName, ILogger logger, int batchSize) : base(logger, batchSize)
{
_messagingFactory = messagingFactory;
_multicastRequestBroker = multicastRequestBroker;
_requestType = requestType;
_applicationSharedSubscriptionName = applicationSharedSubscriptionName;
}
示例14: ReceiveAllMessagesFromSubscripions
static void ReceiveAllMessagesFromSubscripions(MessagingFactory messagingFactory)
{
// Receive message from 3 subscriptions.
Program.ReceiveAllMessageFromSubscription(messagingFactory, Conts.SubAllMessages);
Program.ReceiveAllMessageFromSubscription(messagingFactory, Conts.YoungHorses);
Program.ReceiveAllMessageFromSubscription(messagingFactory, Conts.OldHorses);
}
示例15: CommandMessagePump
public CommandMessagePump(MessagingFactory messagingFactory, ICommandBroker commandBroker, Type messageType, ILogger logger)
: base(logger)
{
_messagingFactory = messagingFactory;
_commandBroker = commandBroker;
_messageType = messageType;
}