Exemplo n.º 1
0
        /// <summary>
        /// Creates new Horse MQ Builder
        /// </summary>
        public static HorseMqBuilder Create()
        {
            HorseMqBuilder builder = new HorseMqBuilder();

            builder.Server = new HorseMq();
            return(builder);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets Horse MQ Options
        /// </summary>
        public static HorseMqBuilder AddOptions(this HorseMqBuilder builder, Action <HorseMqOptions> options)
        {
            if (builder.Server.Options == null)
            {
                builder.Server.Options = new HorseMqOptions();
            }

            options(builder.Server.Options);
            return(builder);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Uses Horse.Mq Messaging Queue server
        /// </summary>
        public static HorseMq UseHorseMq(this HorseServer server, Action <HorseMqBuilder> cfg)
        {
            HorseMq           mq      = new HorseMq();
            HmqNetworkHandler handler = new HmqNetworkHandler(mq);

            mq.Server = server;

            mq.NodeManager.ConnectionHandler = new NodeConnectionHandler(mq.NodeManager, handler);
            server.UseHmq(handler);

            if (mq.NodeManager != null)
            {
                mq.NodeManager.SubscribeStartStop(server);
            }

            HorseMqBuilder builder = new HorseMqBuilder();

            builder.Server = mq;

            cfg(builder);
            return(mq);
        }
Exemplo n.º 4
0
 public static HorseMqBuilder UseServerMessageHandler(this HorseMqBuilder builder, IServerMessageHandler messageHandler)
 {
     return(AddServerMessageHandler(builder, messageHandler));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Uses server type message event handler
 /// </summary>
 public static HorseMqBuilder AddServerMessageHandler <TServerMessageHandler>(this HorseMqBuilder builder)
     where TServerMessageHandler : IServerMessageHandler, new()
 {
     builder.Server.AddMessageHandler(new TServerMessageHandler());
     return(builder);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Adds error handler
 /// </summary>
 public static HorseMqBuilder AddErrorHandler(this HorseMqBuilder builder, IErrorHandler errorHandler)
 {
     builder.Server.AddErrorHandler(errorHandler);
     return(builder);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Uses Custom Message Id Generator.
 /// Default is DefaultUniqueIdGenerator.
 /// </summary>
 public static HorseMqBuilder UseMessageIdGenerator(this HorseMqBuilder builder, IUniqueIdGenerator generator)
 {
     builder.Server.MessageIdGenerator = generator;
     return(builder);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Implements non-durable basic delivery handler
 /// </summary>
 public static HorseMqBuilder UseJustAllowDeliveryHandler(this HorseMqBuilder builder)
 {
     builder.Server.DeliveryHandlerFactory = d => Task.FromResult <IMessageDeliveryHandler>(new JustAllowDeliveryHandler());
     return(builder);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Adds queue event handler
 /// </summary>
 public static HorseMqBuilder AddQueueEventHandler <TQueueAuthenticator>(this HorseMqBuilder builder)
     where TQueueAuthenticator : IQueueEventHandler, new()
 {
     builder.Server.AddQueueEventHandler(new TQueueAuthenticator());
     return(builder);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Activates admin operations and uses admin authorization
 /// </summary>
 public static HorseMqBuilder AddAdminAuthorization(this HorseMqBuilder builder, IAdminAuthorization authorization)
 {
     builder.Server.AddAdminAuthorization(authorization);
     return(builder);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Activates admin operations and uses admin authorization
 /// </summary>
 public static HorseMqBuilder AddAdminAuthorization <TAdminAuthorization>(this HorseMqBuilder builder)
     where TAdminAuthorization : IAdminAuthorization, new()
 {
     builder.Server.AddAdminAuthorization(new TAdminAuthorization());
     return(builder);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Uses queue authentication
 /// </summary>
 public static HorseMqBuilder AddQueueAuthentication(this HorseMqBuilder builder, IQueueAuthenticator authenticator)
 {
     builder.Server.AddQueueAuthenticator(authenticator);
     return(builder);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Uses client authorization
 /// </summary>
 public static HorseMqBuilder AddClientAuthorization <TClientAuthorization>(this HorseMqBuilder builder)
     where TClientAuthorization : IClientAuthorization, new()
 {
     builder.Server.AddClientAuthorization(new TClientAuthorization());
     return(builder);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Uses client authentication
 /// </summary>
 public static HorseMqBuilder AddClientAuthenticator(this HorseMqBuilder builder, IClientAuthenticator authenticator)
 {
     builder.Server.AddClientAuthenticator(authenticator);
     return(builder);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Uses client authentication
 /// </summary>
 public static HorseMqBuilder AddClientAuthenticator <TClientAuthenticator>(this HorseMqBuilder builder)
     where TClientAuthenticator : IClientAuthenticator, new()
 {
     builder.Server.AddClientAuthenticator(new TClientAuthenticator());
     return(builder);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Uses a custom server message handler
 /// </summary>
 public static HorseMqBuilder AddServerMessageHandler(this HorseMqBuilder builder, IServerMessageHandler messageHandler)
 {
     builder.Server.AddMessageHandler(messageHandler);
     return(builder);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Implements a message delivery handler factory
 /// </summary>
 public static HorseMqBuilder UseDeliveryHandler(this HorseMqBuilder builder, Func <DeliveryHandlerBuilder, Task <IMessageDeliveryHandler> > deliveryHandler)
 {
     builder.Server.DeliveryHandlerFactory = deliveryHandler;
     return(builder);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Adds queue event handler
 /// </summary>
 public static HorseMqBuilder AddQueueEventHandler(this HorseMqBuilder builder, IQueueEventHandler queueEventHandler)
 {
     builder.Server.AddQueueEventHandler(queueEventHandler);
     return(builder);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Implements non-durable basic delivery handler with ack
 /// </summary>
 /// <param name="builder">Horse MQ Builder</param>
 /// <param name="producerAck">Decision, when producer will receive acknowledge (or confirm)</param>
 /// <param name="consumerAckFail">Decision, what will be done if consumer sends nack or doesn't send ack in time</param>
 public static HorseMqBuilder UseAckDeliveryHandler(this HorseMqBuilder builder, AcknowledgeWhen producerAck, PutBackDecision consumerAckFail)
 {
     builder.Server.DeliveryHandlerFactory = d => Task.FromResult <IMessageDeliveryHandler>(new AckDeliveryHandler(producerAck, consumerAckFail));
     return(builder);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Adds client event handler
 /// </summary>
 public static HorseMqBuilder AddClientHandler <TClientHandler>(this HorseMqBuilder builder)
     where TClientHandler : IClientHandler, new()
 {
     builder.Server.AddClientHandler(new TClientHandler());
     return(builder);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Sets Horse MQ Options
 /// </summary>
 public static HorseMqBuilder AddOptions(this HorseMqBuilder builder, HorseMqOptions options)
 {
     builder.Server.Options = options;
     return(builder);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Adds client event handler
 /// </summary>
 public static HorseMqBuilder AddClientHandler(this HorseMqBuilder builder, IClientHandler clientHandler)
 {
     builder.Server.AddClientHandler(clientHandler);
     return(builder);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Uses Custom Client Id Generator.
 /// Default is DefaultUniqueIdGenerator.
 /// </summary>
 public static HorseMqBuilder UseClientIdGenerator <TUniqueIdGenerator>(this HorseMqBuilder builder)
     where TUniqueIdGenerator : IUniqueIdGenerator, new()
 {
     builder.Server.ClientIdGenerator = new TUniqueIdGenerator();
     return(builder);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Adds error handler
 /// </summary>
 public static HorseMqBuilder AddErrorHandler <TErrorHandler>(this HorseMqBuilder builder)
     where TErrorHandler : IErrorHandler, new()
 {
     builder.Server.AddErrorHandler(new TErrorHandler());
     return(builder);
 }