コード例 #1
0
 public string Route(Type messageType, QueueOrTopic queueOrTopic, IPathFactory pathFactory)
 {
     switch (queueOrTopic)
     {
         case QueueOrTopic.Queue:
             return pathFactory.QueuePathFor(messageType);
         case QueueOrTopic.Topic:
             return pathFactory.TopicPathFor(messageType);
         default:
             throw new Exception("Cannot build a route for the message type '{0}'.".FormatWith(messageType.FullName));
     }
 }
コード例 #2
0
        public string Route(Type messageType, QueueOrTopic queueOrTopic)
        {
            switch (queueOrTopic)
            {
            case QueueOrTopic.Queue:
                return(PathFactory.QueuePathFor(messageType));

            case QueueOrTopic.Topic:
                return(PathFactory.TopicPathFor(messageType));

            default:
                throw new Exception("Cannot build a route for the message type '{0}'.".FormatWith(messageType.FullName));
            }
        }
コード例 #3
0
        public string Route(Type messageType, QueueOrTopic queueOrTopic)
        {
            var convention = messageType.GetCustomAttributes(false).FirstOrDefault((a => a is NamingConventionAttribute)) as NamingConventionAttribute;
            var name = convention != null ? convention.Name : null;
            var skipPrefix = convention != null ? convention.SkipPrefix : false;

            switch (queueOrTopic)
            {
                case QueueOrTopic.Queue:
                    return string.IsNullOrEmpty(name) ? PathFactory.QueuePathFor(messageType) : PathFactory.QueuePathFor(name, skipPrefix);
                case QueueOrTopic.Topic:
                    return string.IsNullOrEmpty(name) ? PathFactory.TopicPathFor(messageType) : PathFactory.TopicPathFor(name, skipPrefix);
                default:
                    throw new Exception("Cannot build a route for the message type '{0}'.".FormatWith(messageType.FullName));
            }
        }
コード例 #4
0
        public string Route(Type messageType, QueueOrTopic queueOrTopic)
        {
            switch (queueOrTopic)
            {
                case QueueOrTopic.Queue:
                    if (typeof (IBusCommand).IsAssignableFrom(messageType))
                    {
                        return _singleCommandQueuePath ?? _fallbackRouter.Route(messageType, queueOrTopic);
                    }

                    break;
                case QueueOrTopic.Topic:
                    break;
            }

            return _fallbackRouter.Route(messageType, queueOrTopic);
        }
コード例 #5
0
        public string Route(Type messageType, QueueOrTopic queueOrTopic, IPathFactory pathFactory)
        {
            switch (queueOrTopic)
            {
                case QueueOrTopic.Queue:
                    if (typeof(IBusCommand).IsAssignableFrom(messageType))
                    {
                        return _singleCommandQueuePath ?? _fallbackRouter.Route(messageType, queueOrTopic, pathFactory);
                    }

                    if (messageType.IsClosedTypeOf(typeof(IBusRequest<,>)))
                    {
                        return _singleRequestQueuePath ?? _fallbackRouter.Route(messageType, queueOrTopic, pathFactory);
                    }

                    break;
                case QueueOrTopic.Topic:
                    break;
            }

            return _fallbackRouter.Route(messageType, queueOrTopic, pathFactory);
        }
コード例 #6
0
        public string Route(Type messageType, QueueOrTopic queueOrTopic)
        {
            switch (queueOrTopic)
            {
            case QueueOrTopic.Queue:
                if (typeof(IBusCommand).IsAssignableFrom(messageType))
                {
                    return(_singleCommandQueuePath ?? _fallbackRouter.Route(messageType, queueOrTopic));
                }

                if (messageType.IsClosedTypeOf(typeof(IBusRequest <,>)))
                {
                    return(_singleRequestQueuePath ?? _fallbackRouter.Route(messageType, queueOrTopic));
                }

                break;

            case QueueOrTopic.Topic:
                break;
            }

            return(_fallbackRouter.Route(messageType, queueOrTopic));
        }
コード例 #7
0
 public async Task <SendResult> SendMessage(string entityPath, string data = "foobar", BodySerializationType serializationType = BodySerializationType.String, bool createEntity = true, QueueOrTopic queueOrTopic = QueueOrTopic.Queue, Encoding encoding = null, string contentType = null, Dictionary <string, string> properties = null)
 {
     encoding = encoding ?? Encoding.UTF8;
     entitiesToDelete.Add(new EntitySpec {
         EntityType = queueOrTopic, Name = entityPath
     });
     return(await ServiceBus.Send(new SendInput
     {
         QueueOrTopicName = entityPath,
         ConnectionString = _connectionString,
         Data = data,
         Properties = properties?.Select(kvp => new MessageProperty {
             Name = kvp.Key, Value = kvp.Value
         }).ToArray() ?? new MessageProperty[] {}
     }, new SendOptions
     {
         CreateQueueOrTopicIfItDoesNotExist = createEntity,
         BodySerializationType = serializationType,
         DestinationType = queueOrTopic,
         TimeoutSeconds = 60,
         ContentType = contentType ?? $"plain/text;charset={encoding.BodyName}"
     }).ConfigureAwait(false));
 }