Пример #1
0
    static async Task SendOrder(IBusSession busSession)
    {

        Console.WriteLine("Press enter to send a message");
        Console.WriteLine("Press any key to exit");

        while (true)
        {
            ConsoleKeyInfo key = Console.ReadKey();
            Console.WriteLine();

            if (key.Key != ConsoleKey.Enter)
            {
                break;
            }
            Guid id = Guid.NewGuid();

            PlaceOrder placeOrder = new PlaceOrder
            {
                Product = "New shoes",
                Id = id
            };
            await busSession.Send("Samples.StepByStep.Server", placeOrder);

            Console.WriteLine("Sent a new PlaceOrder message with id: {0}", id.ToString("N"));

        }

    }
Пример #2
0
    static async Task SendOrder(IBusSession busSession)
    {
        Console.WriteLine("Press enter to send a message");
        Console.WriteLine("Press any key to exit");

        while (true)
        {
            ConsoleKeyInfo key = Console.ReadKey();
            Console.WriteLine();

            if (key.Key != ConsoleKey.Enter)
            {
                break;
            }
            Guid id = Guid.NewGuid();

            PlaceOrder placeOrder = new PlaceOrder
            {
                Product = "New shoes",
                Id      = id
            };
            await busSession.Send("Samples.StepByStep.Server", placeOrder);

            Console.WriteLine("Sent a new PlaceOrder message with id: {0}", id.ToString("N"));
        }
    }
Пример #3
0
        /// <summary>
        /// Instantiates a message of <typeparamref name="T" /> and sends it.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="session">The instance of <see cref="IBusSession" /> to use for the action.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        /// <remarks>
        /// The message will be sent to the destination configured for <typeparamref name="T" />.
        /// </remarks>
        public static Task Send <T>(this IBusSession session, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            return(session.Send(messageConstructor, new SendOptions()));
        }
Пример #4
0
        /// <summary>
        /// Sends the provided message.
        /// </summary>
        /// <param name="session">The instance of <see cref="IBusSession" /> to use for the action.</param>
        /// <param name="message">The message to send.</param>
        public static Task Send(this IBusSession session, object message)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(message), message);

            return(session.Send(message, new SendOptions()));
        }
Пример #5
0
 // Shut down server before sending this message, after 30 seconds, the message will be moved to Transactional dead-letter messages queue.
 static async Task Expiration(IBusSession busSession)
 {
     await busSession.Send(new MessageThatExpires
              {
                  RequestId = new Guid()
              });
     Console.WriteLine("message with expiration was sent");
 }
    // Shut down server before sending this message, after 30 seconds, the message will be moved to Transactional dead-letter messages queue.
    static async Task Expiration(IBusSession busSession)
    {
        await busSession.Send(new MessageThatExpires
        {
            RequestId = new Guid()
        });

        Console.WriteLine("message with expiration was sent");
    }
Пример #7
0
 static async Task SendJsonMessage(IBusSession busSession)
 {
     MessageWithJson message = new MessageWithJson
     {
         SomeProperty = "Some content in a json message",
     };
     await busSession.Send("Samples.MultiSerializer.Receiver", message);
     Console.WriteLine("Json Message sent");
 }
Пример #8
0
        async Task SendInterface()
        {
            IBusSession busSession = null;

            #region BasicSendInterface
            await busSession.Send <IMyMessage>(m => m.MyProperty = "Hello world");

            #endregion
        }
Пример #9
0
    static async Task SendJsonMessage(IBusSession busSession)
    {
        MessageWithJson message = new MessageWithJson
        {
            SomeProperty = "Some content in a json message",
        };
        await busSession.Send("Samples.MultiSerializer.Receiver", message);

        Console.WriteLine("Json Message sent");
    }
Пример #10
0
        /// <summary>
        /// Instantiates a message of type T and sends it back to the current endpoint.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="session">Object being extended.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        public static Task SendLocal <T>(this IBusSession session, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            var options = new SendOptions();

            options.RouteToThisEndpoint();

            return(session.Send(messageConstructor, options));
        }
Пример #11
0
        /// <summary>
        /// Sends the message back to the current endpoint.
        /// </summary>
        /// <param name="session">Object being extended.</param>
        /// <param name="message">The message to send.</param>
        public static Task SendLocal(this IBusSession session, object message)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(message), message);

            var options = new SendOptions();

            options.RouteToThisEndpoint();

            return(session.Send(message, options));
        }
    static async Task SendRequest(IBusSession busSession)
    {
        Guid requestId = Guid.NewGuid();

        await busSession.Send(new Request
        {
            RequestId = requestId
        });

        Console.WriteLine("Request sent id: " + requestId);
    }
Пример #13
0
    static async Task Express(IBusSession busSession)
    {
        Guid requestId = Guid.NewGuid();

        await busSession.Send(new RequestExpress
        {
            RequestId = requestId
        });

        Console.WriteLine("Request sent id: " + requestId);
    }
Пример #14
0
    static async Task SendMessageTooLargePayload(IBusSession busSession)
    {
        #region SendMessageTooLargePayload

        AnotherMessageWithLargePayload message = new AnotherMessageWithLargePayload
        {
            LargeBlob = new byte[1024 * 1024 * 5] //5MB
        };
        await busSession.Send("Samples.DataBus.Receiver", message);

        #endregion
    }
Пример #15
0
        /// <summary>
        /// Sends the message.
        /// </summary>
        /// <param name="session">The instance of <see cref="IBusSession" /> to use for the action.</param>
        /// <param name="destination">The address of the destination to which the message will be sent.</param>
        /// <param name="message">The message to send.</param>
        public static Task Send(this IBusSession session, string destination, object message)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNullAndEmpty(nameof(destination), destination);
            Guard.AgainstNull(nameof(message), message);

            var options = new SendOptions();

            options.SetDestination(destination);

            return(session.Send(message, options));
        }
Пример #16
0
    static async Task SendMessageTooLargePayload(IBusSession busSession)
    {
        #region SendMessageTooLargePayload

        AnotherMessageWithLargePayload message = new AnotherMessageWithLargePayload
        {
            LargeBlob = new byte[1024*1024*5] //5MB
        };
        await busSession.Send("Samples.DataBus.Receiver", message);

        #endregion
    }
Пример #17
0
        /// <summary>
        /// Instantiates a message of type T and sends it to the given destination.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="session">The instance of <see cref="IBusSession" /> to use for the action.</param>
        /// <param name="destination">The destination to which the message will be sent.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        public static Task Send <T>(this IBusSession session, string destination, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNullAndEmpty(nameof(destination), destination);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            var options = new SendOptions();

            options.SetDestination(destination);

            return(session.Send(messageConstructor, options));
        }
    static async Task SendCommand(IBusSession busSession)
    {
        Guid commandId = Guid.NewGuid();

        await busSession.Send(new MyCommand
        {
            CommandId       = commandId,
            EncryptedString = "Some sensitive information"
        });

        Console.WriteLine("Command sent id: " + commandId);
    }
Пример #19
0
    static async Task Data(IBusSession busSession)
    {
        Guid requestId = Guid.NewGuid();

        await busSession.Send(new LargeMessage
        {
            RequestId = requestId,
            LargeDataBus = new byte[1024*1024*5]
        });

        Console.WriteLine("Request sent id: " + requestId);
    }
    static async Task Data(IBusSession busSession)
    {
        Guid requestId = Guid.NewGuid();

        await busSession.Send(new LargeMessage
        {
            RequestId    = requestId,
            LargeDataBus = new byte[1024 * 1024 * 5]
        });

        Console.WriteLine("Request sent id: " + requestId);
    }
Пример #21
0
        async Task Send()
        {
            var busConfiguration = new BusConfiguration();

            #region BasicSend
            IEndpointInstance instance = await Endpoint.Start(busConfiguration);

            IBusSession busSession = instance.CreateBusSession();

            await busSession.Send(new MyMessage());

            #endregion
        }
Пример #22
0
    static async Task SendMessageLargePayload(IBusSession busSession)
    {
        #region SendMessageLargePayload

        MessageWithLargePayload message = new MessageWithLargePayload
        {
            SomeProperty = "This message contains a large blob that will be sent on the data bus",
            LargeBlob    = new DataBusProperty <byte[]>(new byte[1024 * 1024 * 5]) //5MB
        };
        await busSession.Send("Samples.DataBus.Receiver", message);

        #endregion

        Console.WriteLine("Message sent, the payload is stored in: " + BasePath);
    }
Пример #23
0
    static async Task SendMessageLargePayload(IBusSession busSession)
    {
        #region SendMessageLargePayload

        MessageWithLargePayload message = new MessageWithLargePayload
        {
            SomeProperty = "This message contains a large blob that will be sent on the data bus",
            LargeBlob = new DataBusProperty<byte[]>(new byte[1024*1024*5]) //5MB
        };
        await busSession.Send("Samples.DataBus.Receiver", message);

        #endregion

        Console.WriteLine("Message sent, the payload is stored in: " + BasePath);
    }
        public async Task SendDelayedMessage()
        {
            IBusSession            busSession     = null;
            IMessageHandlerContext handlerContext = null;

            #region delayed-delivery-datetime
            SendOptions options = new SendOptions();
            options.DoNotDeliverBefore(new DateTime(2016, 12, 25));

            await handlerContext.Send(new MessageToBeSentLater(), options);

            // OR
            await busSession.Send(new MessageToBeSentLater(), options);

            #endregion
        }
Пример #25
0
    static async Task SendMessageWithFileStream(IBusSession busSession)
    {
        #region send-message-with-file-stream

        MessageWithStream message = new MessageWithStream
        {
            SomeProperty = "This message contains a stream",
            StreamProperty = File.OpenRead("FileToSend.txt")
        };
        await busSession.Send("Samples.PipelineStream.Receiver", message);

        #endregion

        Console.WriteLine();
        Console.WriteLine("Message with file stream sent");
    }
Пример #26
0
    static async Task SendMessageWithFileStream(IBusSession busSession)
    {
        #region send-message-with-file-stream

        MessageWithStream message = new MessageWithStream
        {
            SomeProperty   = "This message contains a stream",
            StreamProperty = File.OpenRead("FileToSend.txt")
        };
        await busSession.Send("Samples.PipelineStream.Receiver", message);

        #endregion

        Console.WriteLine();
        Console.WriteLine("Message with file stream sent");
    }
Пример #27
0
        public async Task SendDelayedMessage()
        {
            IBusSession            busSession     = null;
            IMessageHandlerContext handlerContext = null;

            #region delayed-delivery-timespan
            SendOptions options = new SendOptions();

            options.DelayDeliveryWith(TimeSpan.FromMinutes(30));

            await handlerContext.Send(new MessageToBeSentLater(), options);

            // OR
            await busSession.Send(new MessageToBeSentLater(), options);

            #endregion
        }
Пример #28
0
    static async Task SendMessageWithHttpStream(IBusSession busSession)
    {
        #region send-message-with-http-stream

        using (WebClient webClient = new WebClient())
        {
            MessageWithStream message = new MessageWithStream
            {
                SomeProperty   = "This message contains a stream",
                StreamProperty = webClient.OpenRead("http://www.particular.net")
            };
            await busSession.Send("Samples.PipelineStream.Receiver", message);
        }

        #endregion

        Console.WriteLine();
        Console.WriteLine("Message with http stream sent");
    }
Пример #29
0
    static async Task SendCommand(IBusSession busSession)
    {
        Guid commandId = Guid.NewGuid();

        await busSession.Send(new MyCommand
                 {
                     CommandId = commandId,
                     EncryptedString = "Some sensitive information"
                 });

        Console.WriteLine("Command sent id: " + commandId);
    }
Пример #30
0
    static async Task SendMessageWithHttpStream(IBusSession busSession)
    {
        #region send-message-with-http-stream

        using (WebClient webClient = new WebClient())
        {
            MessageWithStream message = new MessageWithStream
            {
                SomeProperty = "This message contains a stream",
                StreamProperty = webClient.OpenRead("http://www.particular.net")
            };
            await busSession.Send("Samples.PipelineStream.Receiver", message);
        }

        #endregion

        Console.WriteLine();
        Console.WriteLine("Message with http stream sent");
    }