コード例 #1
0
ファイル: Program.cs プロジェクト: cdnico/docs.particular.net
    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");
 }
コード例 #6
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");
    }
コード例 #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));
        }
コード例 #12
0
    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
ファイル: Program.cs プロジェクト: cdnico/docs.particular.net
    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));
        }
コード例 #18
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);
    }
コード例 #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);
    }
コード例 #20
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);
    }
コード例 #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
ファイル: Program.cs プロジェクト: cdnico/docs.particular.net
    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);
    }
コード例 #24
0
        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");
    }