예제 #1
0
        public override MessageContext ReceiveOnTopic(MessageContext inputcontext, IMessageAdapter adapter)
        {
            var entity = EntityNameHelper.FormatSubscriptionPath(inputcontext.ToReplyPath, inputcontext.ToReplySubscription);

            var client = new SessionClient(inputcontext.ToReplyConnectionString, entity);

            var messagesession = client.AcceptMessageSessionAsync(inputcontext.ReplyToRequestId).GetAwaiter().GetResult();

            var message = inputcontext.ToReplyTimeOut != 0 ? messagesession.ReceiveAsync(TimeSpan.FromSeconds(inputcontext.ToReplyTimeOut)).GetAwaiter().GetResult() : messagesession.ReceiveAsync().GetAwaiter().GetResult();

            MessageContext outputcontext = null;

            if (message != null)
            {
                outputcontext = adapter.Read(message, inputcontext.ResultType);

                messagesession.CompleteAsync(message.SystemProperties.LockToken);
            }

            messagesession.CloseAsync().GetAwaiter().GetResult();

            client.CloseAsync().GetAwaiter().GetResult();

            return(outputcontext);
        }
예제 #2
0
        public override MessageContext ReceiveOnTopic(MessageContext inputcontext, IMessageAdapter adapter)
        {
            var client = SubscriptionClient.CreateFromConnectionString(inputcontext.ToReplyConnectionString, inputcontext.ToReplyPath, inputcontext.ToReplySubscription);

            var messagesession = client.AcceptMessageSession(inputcontext.ReplyToRequestId);

            var message = inputcontext.ToReplyTimeOut != 0 ? messagesession.Receive(TimeSpan.FromSeconds(inputcontext.ToReplyTimeOut)) : messagesession.Receive();

            MessageContext outputcontext = null;

            if (message != null)
            {
                outputcontext = adapter.Read(message, inputcontext.ResultType);

                message.Complete();
            }

            messagesession.Close();

            client.Close();

            return(outputcontext);
        }
예제 #3
0
        public override MessageContext ReceiveOnQueue(Channel channel, MessageContext context, IMessageAdapter adapter)
        {
            var client = new SessionClient(channel.ToReplyConnectionString, channel.ToReplyPath);

            var messagesession = client.AcceptMessageSessionAsync(context.Identity.ReplyToRequestId).GetAwaiter().GetResult();

            var message = channel.ToReplyTimeOut != 0 ? messagesession.ReceiveAsync(TimeSpan.FromSeconds(channel.ToReplyTimeOut)).GetAwaiter().GetResult() : messagesession.ReceiveAsync().GetAwaiter().GetResult();

            MessageContext outputcontext = null;

            if (message != null)
            {
                outputcontext = adapter.Read(message, context.ResultType, context.EndPoint.UseClaimCheck);

                messagesession.CompleteAsync(message.SystemProperties.LockToken);
            }

            messagesession.CloseAsync().GetAwaiter().GetResult();

            client.CloseAsync().GetAwaiter().GetResult();

            return(outputcontext);
        }
예제 #4
0
        public override MessageContext ReceiveOnQueue(Channel channel, MessageContext context, IMessageAdapter adapter)
        {
            var client = QueueClient.CreateFromConnectionString(channel.ToReplyConnectionString, channel.ToReplyPath);

            var messagesession = client.AcceptMessageSession(context.Identity.ReplyToRequestId);

            var message = channel.ToReplyTimeOut != 0 ? messagesession.Receive(TimeSpan.FromSeconds(channel.ToReplyTimeOut)) : messagesession.Receive();

            MessageContext outputcontext = null;

            if (message != null)
            {
                outputcontext = adapter.Read(message, context.ResultType, context.EndPoint.UseClaimCheck);

                message.Complete();
            }

            messagesession.Close();

            client.Close();

            return(outputcontext);
        }