/// <summary> /// Unregisters this Actor as a subscriber for messages of type <paramref name="messageType"/> with the <see cref="BrokerService"/>. /// </summary> /// <returns></returns> public async Task UnregisterMessageTypeAsync(ActorBase actor, Type messageType, bool flushQueue, Uri brokerServiceName = null) { if (messageType == null) { throw new ArgumentNullException(nameof(messageType)); } if (actor == null) { throw new ArgumentNullException(nameof(actor)); } if (brokerServiceName == null) { brokerServiceName = await PublisherServiceHelper.DiscoverBrokerServiceNameAsync(); if (brokerServiceName == null) { throw new InvalidOperationException("No brokerServiceName was provided or discovered in the current application."); } } var brokerService = await _brokerServiceLocator.GetBrokerServiceForMessageAsync(messageType.Name, brokerServiceName); await brokerService.UnregisterSubscriberAsync(ActorReference.Get(actor), messageType.FullName, flushQueue); }
/// <summary> /// Publish a message. /// </summary> /// <param name="actor"></param> /// <param name="message"></param> /// <param name="brokerServiceName">The name of the SF Service of type <see cref="BrokerService"/>.</param> /// <returns></returns> public async Task PublishMessageAsync(ActorBase actor, object message, Uri brokerServiceName = null) { if (actor == null) { throw new ArgumentNullException(nameof(actor)); } if (message == null) { throw new ArgumentNullException(nameof(message)); } if (brokerServiceName == null) { brokerServiceName = await PublisherServiceHelper.DiscoverBrokerServiceNameAsync(); if (brokerServiceName == null) { throw new InvalidOperationException("No brokerServiceName was provided or discovered in the current application."); } } var wrapper = MessageWrapper.CreateMessageWrapper(message); var brokerService = await _brokerServiceLocator.GetBrokerServiceForMessageAsync(message, brokerServiceName); await brokerService.PublishMessageAsync(wrapper); }
/// <summary> /// Unregisters this Actor as a subscriber for messages of type <paramref name="messageType"/> with the <see cref="BrokerService"/>. /// </summary> /// <returns></returns> public async Task UnregisterMessageTypeAsync(StatelessService service, Type messageType, bool flushQueue, Uri brokerServiceName = null) { if (service == null) { throw new ArgumentNullException(nameof(service)); } if (messageType == null) { throw new ArgumentNullException(nameof(messageType)); } if (brokerServiceName == null) { brokerServiceName = await PublisherServiceHelper.DiscoverBrokerServiceNameAsync(); if (brokerServiceName == null) { throw new InvalidOperationException( "No brokerServiceName was provided or discovered in the current application."); } } var brokerService = await _brokerServiceLocator.GetBrokerServiceForMessageAsync(messageType.Name, brokerServiceName); var serviceReference = CreateServiceReference(service.Context, GetServicePartition(service).PartitionInfo); await brokerService.UnregisterServiceSubscriberAsync(serviceReference, messageType.FullName, flushQueue); }
private async Task RegisterMessageTypeAsync(ServiceReference serviceReference, Type messageType, Uri brokerServiceName = null) { if (messageType == null) { throw new ArgumentNullException(nameof(messageType)); } if (brokerServiceName == null) { brokerServiceName = await PublisherServiceHelper.DiscoverBrokerServiceNameAsync(); if (brokerServiceName == null) { throw new InvalidOperationException("No brokerServiceName was provided or discovered in the current application."); } } var brokerService = await _brokerServiceLocator.GetBrokerServiceForMessageAsync(messageType.Name, brokerServiceName); await brokerService.RegisterServiceSubscriberAsync(serviceReference, messageType.FullName); }