Ejemplo n.º 1
0
        /// <summary>
        /// Attaches the azure service bus queue listener.
        /// </summary>
        /// <typeparam name="C"></typeparam>
        /// <param name="cpipe">The cpipe.</param>
        /// <param name="connectionName">Name of the connection.</param>
        /// <param name="serviceBusConnection">The service bus connection.</param>
        /// <param name="isDeadLetterListener">if set to <c>true</c> [is dead letter listener].</param>
        /// <param name="mappingChannelId">The mapping channel identifier.</param>
        /// <param name="priorityPartitions">The priority partitions.</param>
        /// <param name="resourceProfiles">The resource profiles.</param>
        /// <param name="onCreate">The on create.</param>
        /// <returns></returns>
        public static C AttachAzureServiceBusQueueListener <C>(this C cpipe
                                                               , string connectionName       = null
                                                               , string serviceBusConnection = null
                                                               , bool isDeadLetterListener   = false
                                                               , string mappingChannelId     = null
                                                               , IEnumerable <ListenerPartitionConfig> priorityPartitions = null
                                                               , IEnumerable <ResourceProfile> resourceProfiles           = null
                                                               , Action <AzureServiceBusQueueListener> onCreate           = null)
            where C : IPipelineChannelIncoming <IPipeline>
        {
            var     component = new AzureServiceBusQueueListener();
            Channel channel   = cpipe.ToChannel(ChannelDirection.Incoming);

            component.ConfigureAzureMessaging(
                channel.Id
                , priorityPartitions ?? channel.Partitions.Cast <ListenerPartitionConfig>()
                , resourceProfiles
                , connectionName ?? channel.Id
                , serviceBusConnection ?? cpipe.Pipeline.Configuration.ServiceBusConnection()
                );

            component.IsDeadLetterListener = isDeadLetterListener;

            onCreate?.Invoke(component);

            cpipe.AttachListener(component, setFromChannelProperties: false);

            return(cpipe);
        }
        /// <summary>
        /// This method returns a new listener.
        /// </summary>
        /// <returns>The queue listener.</returns>
        public override IListener GetListener()
        {
            var listener = new AzureServiceBusQueueListener();

            listener.Connection = Connection;

            return(listener);
        }
        /// <summary>
        /// Gets a listener agent for the bridge.
        /// </summary>
        /// <param name="properties">The service bus extended properties.</param>
        /// <returns>
        /// Returns the listener agent.
        /// </returns>
        public override IListener GetListener(AzureServiceBusExtendedProperties properties)
        {
            var listener = new AzureServiceBusQueueListener();

            listener.Connection = Connection;
            listener.EntityName = properties.EntityName;

            return(listener);
        }