Esempio n. 1
0
        public Task <ServerResponse> New(Action <QueueTarget> queue, Action <QueueBehavior> behavior,
                                         Action <VirtualHostTarget> virtualHost,
                                         CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var queueTargetImpl = new QueueTargetImpl();

            queue(queueTargetImpl);

            var behaviorImpl = new QueueBehaviorImpl();

            behavior(behaviorImpl);

            var virtualHostTargetImpl = new VirtualHostTargetImpl();

            virtualHost(virtualHostTargetImpl);

            string url = string.Format("api/queues/{0}/{1}", virtualHostTargetImpl.Target.SanitizeVirtualHostName(),
                                       queueTargetImpl.Target);

            LogInfo(string.IsNullOrEmpty(behaviorImpl.Node)
                        ? string.Format(
                        "Sent request to RabbitMQ server to create queue '{0}' on virtual host '{1}'.",
                        queueTargetImpl.Target,
                        virtualHostTargetImpl.Target)
                        : string.Format(
                        "Sent request to RabbitMQ server to create queue '{0}' on virtual host '{1}' on node '{2}'.",
                        queueTargetImpl.Target, virtualHostTargetImpl.Target, behaviorImpl.Node));

            return(base.Put(url, behaviorImpl, cancellationToken).Response <ServerResponse>(cancellationToken));
        }
Esempio n. 2
0
        public Task<ServerResponse> New(string queue, Action<QueueBehavior> args,
                                        CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var argsImpl = new QueueBehaviorImpl();
            args(argsImpl);

            string url = string.Format("api/queues/{0}/{1}", Init.VirtualHost.SanitizeVirtualHostName(), queue);

            LogInfo(string.IsNullOrEmpty(argsImpl.Node)
                        ? string.Format(
                            "Sent request to RabbitMQ server to create queue '{0}' on virtual host '{1}'.", queue,
                            Init.VirtualHost)
                        : string.Format(
                            "Sent request to RabbitMQ server to create queue '{0}' on virtual host '{1}' on node '{2}'.",
                            queue, Init.VirtualHost, argsImpl.Node));

            return base.Put(url, argsImpl, cancellationToken).Response<ServerResponse>(cancellationToken);
        }
Esempio n. 3
0
        public Task<ServerResponse> New(Action<QueueTarget> queue, Action<QueueBehavior> behavior,
                                        Action<VirtualHostTarget> virtualHost,
                                        CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var queueTargetImpl = new QueueTargetImpl();
            queue(queueTargetImpl);

            var behaviorImpl = new QueueBehaviorImpl();
            behavior(behaviorImpl);

            var virtualHostTargetImpl = new VirtualHostTargetImpl();
            virtualHost(virtualHostTargetImpl);

            string url = string.Format("api/queues/{0}/{1}", virtualHostTargetImpl.Target.SanitizeVirtualHostName(),
                                       queueTargetImpl.Target);

            LogInfo(string.IsNullOrEmpty(behaviorImpl.Node)
                        ? string.Format(
                            "Sent request to RabbitMQ server to create queue '{0}' on virtual host '{1}'.",
                            queueTargetImpl.Target,
                            virtualHostTargetImpl.Target)
                        : string.Format(
                            "Sent request to RabbitMQ server to create queue '{0}' on virtual host '{1}' on node '{2}'.",
                            queueTargetImpl.Target, virtualHostTargetImpl.Target, behaviorImpl.Node));

            return base.Put(url, behaviorImpl, cancellationToken).Response<ServerResponse>(cancellationToken);
        }