Beispiel #1
0
        internal static async Task <(IReceivingRawEndpoint, StateStore)> SetupEndpoint(Action <Guid, Message, Message[]> messageProcessed)
        {
            var storageTable = await PrepareStorageTable();

            var stateStore     = new StateStore(storageTable);
            var handlerInvoker = new HandlerInvoker(stateStore);

            var endpointConfiguration = RawEndpointConfiguration.Create(
                endpointName: EndpointName,
                onMessage: async(c, d) =>
            {
                var message = Serializer.Deserialize(c.Body, c.Headers);

                var outputMessages = await handlerInvoker.Process(message);

                var runId = Guid.Parse(c.Headers["Message.RunId"]);

                messageProcessed(runId, message, outputMessages);

                await d.Send(outputMessages, runId);
            },
                poisonMessageQueue: "error");

            endpointConfiguration.UseTransport <LearningTransport>()
            .Transactions(TransportTransactionMode.ReceiveOnly);

            var defaultFactory = LogManager.Use <DefaultFactory>();

            defaultFactory.Level(LogLevel.Debug);

            var endpoint = await RawEndpoint.Start(endpointConfiguration);

            return(endpoint, stateStore);
        }
Beispiel #2
0
 public HandlerInvoker(StateStore stateStore)
 {
     this.stateStore = stateStore;
 }