Exemplo n.º 1
0
        public static IAsyncResult BeginSendRequest <TRequest>(this IEndpoint endpoint, TRequest message, IServiceBus bus,
                                                               AsyncCallback callback, object state, Action <IInlineRequestConfigurator <TRequest> > configureCallback)
            where TRequest : class
        {
            var configurator = new InlineRequestConfigurator <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));
        }
Exemplo n.º 2
0
        public static bool PublishRequest <TRequest>(this IServiceBus bus, TRequest message,
                                                     Action <IInlineRequestConfigurator <TRequest> > configureCallback)
            where TRequest : class
        {
            var configurator = new InlineRequestConfigurator <TRequest>(message);

            configureCallback(configurator);

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

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

            return(request.Wait());
        }