Exemple #1
0
        public static IAsyncResult BeginSendRequest <TRequest>(this IEndpoint endpoint, TRequest message, IServiceBus bus,
                                                               AsyncCallback callback, object state, Action <InlineRequestConfigurator <TRequest> > configureCallback)
            where TRequest : class
        {
            var configurator = new InlineRequestConfiguratorImpl <TRequest>(message);

            configureCallback(configurator);
            IAsyncRequest <TRequest> request = configurator.Build(bus);

            endpoint.Send(message, context => configurator.ApplyContext(context, bus.Endpoint.Address.Uri));

            return(request.BeginAsync(callback, state));
        }
Exemple #2
0
        public static bool PublishRequest <TRequest>(this IServiceBus bus, TRequest message,
                                                     Action <InlineRequestConfigurator <TRequest> > configureCallback)
            where TRequest : class
        {
            var configurator = new InlineRequestConfiguratorImpl <TRequest>(message);

            configureCallback(configurator);

            IAsyncRequest <TRequest> request = configurator.Build(bus);

            bus.Publish(message, context => configurator.ApplyContext(context, bus.Endpoint.Address.Uri));

            return(request.Wait());
        }
        public static bool SendRequest <TRequest>(this IEndpoint endpoint, TRequest message, IServiceBus bus,
                                                  Action <InlineRequestConfigurator <TRequest> > configureCallback,
                                                  Action <ISendContext <TRequest> > contextCallback = null)
            where TRequest : class
        {
            var configurator = new InlineRequestConfiguratorImpl <TRequest>(message);

            configureCallback(configurator);

            IAsyncRequest <TRequest> request = configurator.Build(bus);

            endpoint.Send(message, context =>
            {
                configurator.ApplyContext(context, bus.Endpoint.Address.Uri);
                if (contextCallback != null)
                {
                    contextCallback(context);
                }
            });

            return(request.Wait());
        }
        public static IAsyncResult BeginPublishRequest <TRequest>(this IServiceBus bus, TRequest message,
                                                                  AsyncCallback callback, object state,
                                                                  Action <InlineRequestConfigurator <TRequest> > configureCallback,
                                                                  Action <IPublishContext <TRequest> > contextCallback = null)
            where TRequest : class
        {
            var configurator = new InlineRequestConfiguratorImpl <TRequest>(message);

            configureCallback(configurator);

            IAsyncRequest <TRequest> request = configurator.Build(bus);

            bus.Publish(message, context =>
            {
                configurator.ApplyContext(context, bus.Endpoint.Address.Uri);
                if (contextCallback != null)
                {
                    contextCallback(context);
                }
            });

            return(request.BeginAsync(callback, state));
        }