public void Handle(RequestDataMessage message)
        {
            //try to uncomment the line below to see the error handling in action
            // 1. nservicebus will retry the configured number of times configured in app.config
            // 2. the UoW will rollback
            // 3. When the max retries is reached the message will be given to the faultmanager (in memory in this case)
            //throw new Exception("Database connection lost");

            Logger.Info("==========================================================================");
            Logger.InfoFormat("Received request {0}.", message.DataId);
            Logger.InfoFormat("String received: {0}.", message.String);
            Logger.InfoFormat("Header 'Test' = {0}.", message.GetHeader("Test"));
            Logger.InfoFormat(Thread.CurrentPrincipal != null ? Thread.CurrentPrincipal.Identity.Name : string.Empty);

            var response = new DataResponseMessage
            {
                DataId = message.DataId,
                String = message.String
            };

            Bus.SetMessageHeader(response, "Test", Bus.GetMessageHeader(message, "Test"));
            response.SetHeader("1", "1");
            response.SetHeader("2", "2");

            Bus.Reply(response); //Try experimenting with sending multiple responses
        }
Example #2
0
    public async Task Handle(RequestDataMessage message, IMessageHandlerContext context)
    {
        log.Info($"Received request {message.DataId}.");

        var readEntity = UncommittedSession.Session.Get <Customer>(message.DataId);
        var entity     = Session.Get <Customer>(message.DataId);

        UncommittedSession.Session.Save(new Customer
        {
            Id   = Guid.NewGuid(),
            Name = "Ramon"
        });

        if (null == entity)
        {
        }
        #region DataResponseReply

        var response = new DataResponseMessage
        {
            DataId = entity?.Id,
            String = entity?.Name
        };

        await context.Reply(response)
        .ConfigureAwait(false);

        #endregion
    }
Example #3
0
        private void HandleDataResponse(MessageReceivedEventArgs args)
        {
            var message = (DataResponseMessage)args.Message;

            _responseMessageToBeSent.Employees = _responseMessageToBeSent.Employees.Concat(message.Employees).ToArray();
            if (message.IsLastKnownServerNode)
            {
                _mediatorConnector.SendMessage(_responseMessageToBeSent);
                _responseMessageToBeSent = null;
            }
        }
    public void Handle(RequestDataMessage message)
    {
        Console.WriteLine("==========================================================================");
        Console.WriteLine("Received request {0}.", message.DataId);
        Console.WriteLine("String received: {0}.", message.String);

        var response = new DataResponseMessage
        {
            DataId = message.DataId,
            String = message.String
        };

        Bus.Reply(response);
    }
Example #5
0
        public async Task Handle(RequestDataMessage message, IMessageHandlerContext context)
        {
            log.Info($"Received request {message.DataId}.");
            log.Info($"String received: {message.String}.");

            var response = new DataResponseMessage
            {
                Id     = Guid.NewGuid(),
                DataId = message.DataId,
                String = message.String,
            };

            await context.Reply(response)
            .ConfigureAwait(false);
        }
Example #6
0
    public async Task Handle(RequestDataMessage message, IMessageHandlerContext context)
    {
        log.Info($"Received request {message.DataId} from {message.Sender}.");

        string[] teamMembers = { "John", "Rishabh", "Paul", "Neel", "Rupesh", "Stacy", "Helen", "Viswa", "Prem", "Venkat", "Durga" };
        Random   rnd         = new Random();
        var      index       = rnd.Next(11);

        var response = new DataResponseMessage
        {
            DataId   = message.DataId,
            Receiver = $"Hello {message.Sender}. I am {teamMembers[index]}."
        };

        await context.Reply(response).ConfigureAwait(false);
    }
    public void Handle(RequestDataMessage message)
    {
        log.Info($"Received request {message.DataId}.");
        log.Info($"String received: {message.String}.");

        #region DataResponseReply

        var response = new DataResponseMessage
        {
            DataId = message.DataId,
            String = message.String
        };

        bus.Reply(response);

        #endregion
    }
Example #8
0
        public async Task Handle(RequestDataMessage message, IMessageHandlerContext context)
        {
            Console.WriteLine($"Received request {message.DataId}.");
            Console.WriteLine($"String received: {message.String}.");

            #region DataResponseReply

            var response = new DataResponseMessage
            {
                DataId = message.DataId,
                String = message.String
            };

            await context.Reply(response);

            #endregion
        }
    public void Handle(RequestDataMessage message)
    {
        Console.WriteLine("Received request {0}.", message.DataId);
        Console.WriteLine("String received: {0}.", message.String);

        #region DataResponseReply

        DataResponseMessage response = new DataResponseMessage
        {
            DataId = message.DataId,
            String = message.String
        };

        bus.Reply(response);

        #endregion
    }
Example #10
0
    public void Handle(RequestDataMessage message)
    {
        log.InfoFormat("Received request {0}.", message.DataId);
        log.InfoFormat("String received: {0}.", message.String);

        #region DataResponseReply

        DataResponseMessage response = new DataResponseMessage
        {
            DataId = message.DataId,
            String = message.String
        };

        bus.Reply(response);

        #endregion
    }
    public async Task Handle(RequestDataMessage message, IMessageHandlerContext context)
    {
        log.InfoFormat("Received request {0}.", message.DataId);
        log.InfoFormat("String received: {0}.", message.String);

        #region DataResponseReply

        DataResponseMessage response = new DataResponseMessage
        {
            DataId = message.DataId,
            String = message.String
        };

        await context.Reply(response);

        #endregion
    }
    public async Task Handle(RequestDataMessage message, IMessageHandlerContext context)
    {
        log.Info($"Received request {message.DataId}.");
        log.Info($"String received: {message.String}.");

        #region DataResponseReply

        var response = new DataResponseMessage
        {
            DataId = message.DataId,
            String = configValue + " " + message.String
        };

        await context.Reply(response)
        .ConfigureAwait(false);

        #endregion
    }
Example #13
0
    static void Handle(RequestDataMessage message, IBus client)
    {
        //try to uncomment the line below to see the error handling in action
        // * lightrwail will retry the configured number of times
        // * when the max retries is reached the message will be given to the faultmanager (in memory in this case)
        //throw new Exception("Database connection lost");

        Console.WriteLine("Received request {0}.", message.DataId);
        Console.WriteLine("String received: {0}.", message.String);

        DataResponseMessage response = new DataResponseMessage
        {
            DataId = message.DataId,
            String = message.String
        };

        client.OutgoingHeaders["MyCustomHeader"] = Guid.NewGuid().ToString();

        client.Send(response, client.CurrentMessageContext[StandardHeaders.ReplyToAddress]);
    }
Example #14
0
    static void Handle(RequestDataMessage message, IBus client)
    {
        //try to uncomment the line below to see the error handling in action
        // * lightrwail will retry the configured number of times
        // * when the max retries is reached the message will be given to the faultmanager (in memory in this case)
        //throw new Exception("Database connection lost");

        Console.WriteLine("Received request {0}.", message.DataId);
        Console.WriteLine("String received: {0}.", message.String);

        DataResponseMessage response = new DataResponseMessage
        {
            DataId = message.DataId,
            String = message.String
        };

        client.OutgoingHeaders["MyCustomHeader"] = Guid.NewGuid().ToString();

        client.Send(response, client.CurrentMessageContext[StandardHeaders.ReplyToAddress]);
    }
Example #15
0
        private void HandleDataRequest(MessageReceivedEventArgs args)
        {
            var message = (DataRequestMessage)args.Message;

            _responseMessageToBeSent = new DataResponseMessage
            {
                Employees = _dataManager.GetEmployees(message.Filters)
            };

            if (message.IsFromAServerNode || _knowedServerNodesConnectors.Count == 0)
            {
                _responseMessageToBeSent.IsLastKnownServerNode = message.IsLastKnownServerNode;
                args.Connector.SendMessage(_responseMessageToBeSent);
            }
            else
            {
                _mediatorConnector = args.Connector;
                SendGetDataMessageToKnownServerNodes(message);
            }
        }
Example #16
0
 static void Handle(DataResponseMessage message)
 {
     Console.WriteLine("Response received with description: {0}", message.String);
 }
Example #17
0
 static void Handle(DataResponseMessage message)
 {
     Console.WriteLine("Response received with description: {0}", message.String);
 }