public static void Handle(ItemCreated created, IDocumentSession session,
                           Jasper.Messaging.Tracking.MessageTracker tracker,
                           Envelope envelope)
 {
     session.Store(created);
     tracker.Record(created, envelope);
 }
示例#2
0
        public override void SetUp()
        {
            theTracker = new Jasper.Messaging.Tracking.MessageTracker();

            var receiverPort = PortFinder.FindPort(3340);
            var senderPort   = PortFinder.FindPort(3370);

            var publishingUri = $"tcp://localhost:{receiverPort}/durable";


            var senderRegistry = new JasperRegistry();

            senderRegistry.Handlers
            .DisableConventionalDiscovery()
            .IncludeType <CascadeReceiver>()
            .IncludeType <ScheduledMessageHandler>();
            senderRegistry.Services.AddSingleton(theTracker);


            senderRegistry.Publish.Message <TriggerMessage>().To(publishingUri);
            senderRegistry.Publish.Message <ItemCreated>().To(publishingUri);
            senderRegistry.Publish.Message <Question>().To(publishingUri);
            senderRegistry.Publish.Message <ScheduledMessage>().To(publishingUri);


            senderRegistry.Transports.DurableListenerAt(senderPort);

            configureSender(senderRegistry);

            theSender = JasperHost.For(senderRegistry);
            theSender.RebuildMessageStorage();


            var receiverRegistry = new JasperRegistry();

            receiverRegistry.Handlers.DisableConventionalDiscovery()
            .IncludeType <TTriggerHandler>()
            .IncludeType <TItemCreatedHandler>()
            .IncludeType <QuestionHandler>()
            .IncludeType <ScheduledMessageHandler>();

            receiverRegistry.Transports.DurableListenerAt(receiverPort);

            receiverRegistry.Handlers.Worker("items").IsDurable()
            .HandlesMessage <ItemCreated>();

            receiverRegistry.Services.AddSingleton(theTracker);

            configureReceiver(receiverRegistry);


            theReceiver = JasperHost.For(receiverRegistry);
            theReceiver.RebuildMessageStorage();


            initializeStorage(theSender, theReceiver);
        }
        public static async Task Handle(
            ItemCreated created,
            NpgsqlTransaction tx, // the current transaction
            Jasper.Messaging.Tracking.MessageTracker tracker,
            Envelope envelope)
        {
            // Using some extension method helpers inside of Jasper here
            await tx.CreateCommand("insert into receiver.item_created (id, name) values (@id, @name)")
            .With("id", created.Id)
            .With("name", created.Name)
            .ExecuteNonQueryAsync();

            tracker.Record(created, envelope);
        }
        public static async Task Handle(
            ItemCreated created,
            SqlConnection conn, // the connection for the container scope
            SqlTransaction tx,  // the current transaction
            Jasper.Messaging.Tracking.MessageTracker tracker,
            Envelope envelope)
        {
            await conn.CreateCommand(tx, "insert into receiver.item_created (id, name) values (@id, @name)")
            .With("id", created.Id)
            .With("name", created.Name)
            .ExecuteNonQueryAsync();

            tracker.Record(created, envelope);
        }
示例#5
0
 public void Handle(CascadedMessage message, Jasper.Messaging.Tracking.MessageTracker tracker, Envelope envelope)
 {
     tracker.Record(message, envelope);
 }