Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 18 18:42
    jeremydmiller transferred #671
  • Sep 18 18:39
    jeremydmiller transferred #678
  • Sep 18 18:37
    jeremydmiller transferred #706
  • Sep 18 18:37
    jeremydmiller transferred #709
  • Sep 18 18:36
    jeremydmiller transferred #718
  • Sep 18 18:36
    jeremydmiller transferred #715
  • Sep 18 18:35
    jeremydmiller transferred #722
  • Sep 18 18:35
    jeremydmiller transferred #723
  • Sep 18 18:35
    jeremydmiller transferred #724
  • Sep 18 18:31
    jeremydmiller transferred #727
  • Sep 18 18:31
    jeremydmiller transferred #730
  • Sep 18 18:30
    jeremydmiller transferred #737
  • Sep 18 18:24
    jeremydmiller transferred #738
  • Sep 18 18:13
    jeremydmiller transferred #747
  • Sep 18 18:12
    jeremydmiller transferred #748
  • Sep 18 18:06
    jeremydmiller transferred #752
  • Sep 18 02:24

    jeremydmiller on master

    Forwarding to wolverine (compare)

  • Sep 16 17:12

    jeremydmiller on master

    spiking on endpoint configurati… (compare)

  • Sep 16 15:44
    jeremydmiller closed #670
  • Sep 16 15:44

    jeremydmiller on master

    Upgraded the interop tests to M… Light spiking on MassTransit se… Spiked out MassTransitJsonSeria… and 5 more (compare)

Willem Meints
@wmeints
await using var session = _documentStore.OpenSession();
session.Events.Append(aggregateRoot.Id, aggregateRoot.Version, aggregateRoot.PendingDomainEvents);
await session.SaveChangesAsync();
Jeremy D. Miller
@jeremydmiller
Oh, okay, yep, it's not automatically enrolled inside a Jasper outbox at that point.
Willem Meints
@wmeints
Is there another pattern that I need to use for this?
Jeremy D. Miller
@jeremydmiller
I have a couple hours set aside today just to work on Jasper docs, let me get something up
Willem Meints
@wmeints
I watched the webinar earlier this week, and there they used WriteAggregate.
Jeremy D. Miller
@jeremydmiller
So it's automatic if the session is used within a Jasper handler marked as [Transactional]
Willem Meints
@wmeints
I'll add that, easy enough to test.
Jeremy D. Miller
@jeremydmiller
In your case, you'd need to explicitly register the Marten session with a Jasper execution context
Willem Meints
@wmeints
Is it enough to grab the IExecutionContext as an extra parameter in my handler?
Jeremy D. Miller
@jeremydmiller
Yes.
Well hold, on. I'm trying to find you a sample from Jasper tests...
Willem Meints
@wmeints
ok
Jeremy D. Miller
@jeremydmiller
Here:
    public class ItemCreatedHandler
    {
        [Transactional]
        public static void Handle(ItemCreated created, IDocumentSession session,
            Envelope envelope)
        {
             // But instead, append events
             session.Store(created);
        }
    }
That would tell Jasper to wrap the document session with the current Jasper execution context & do all the outbox stuff for you. The forwarding and the outbox enrollment mostly happen in a Marten IDocumentSessionListener that gets smuggled in
Next let me find a code sample of making this work outside a Jasper handler......
    public class SampleController : ControllerBase
    {
        #region sample_using_outbox_with_marten_in_mvc_action
        public async Task<IActionResult> PostCreateUser(
            [FromBody] CreateUser user,
            [FromServices] IExecutionContext context,
            [FromServices] IDocumentSession session)
        {
            await context.EnlistInOutboxAsync(session);

            session.Store(new User {Name = user.Name});

            var @event = new UserCreated {UserName = user.Name};

            await context.PublishAsync(@event);

            await session.SaveChangesAsync();

            return Ok();
        }

        #endregion



    }
Willem Meints
@wmeints
Check, thanks for looking it up.
Jeremy D. Miller
@jeremydmiller
So if you wanted this to work inside an MVC controller maybe w/o writing a Jasper handler.
Willem Meints
@wmeints
Trying the first solution now. as I have handlers.
Jeremy D. Miller
@jeremydmiller
Docs today maybe:) And very happy to get feedback on usability, especially outside of Jasper handler usage
Willem Meints
@wmeints
The first solution doesn't work for me. But I've a debugger handy here, so I'll take a look what happens with my code in combination with the event forwarding.
Jeremy D. Miller
@jeremydmiller
Okay
It should be happening in an IDocumentSessionListener firing within a call to IDocumentSession.SaveChangesAsync() that happens after the Handle() call is made.
Willem Meints
@wmeints
Okay, good to know. I'm going to take a peek.
Jeremy D. Miller
@jeremydmiller
And you can fire off handlers directly with ICommandBus.InvokeAsync() anytime for async testing. The "send" to rabbit mq isn't necessarily synchronous though
Willem Meints
@wmeints
I'm not getting anything, not even after a minute. So I don't think my code is working yet. I can see that the FlushOutgoingMessageOnCommit listener is registered. So that's a good start.
Jeremy D. Miller
@jeremydmiller
I'd suspect the routing logic that determines which events should be published and to where
Willem Meints
@wmeints
I think so to. The publishing logic works as expected. I can see two envelopes and no exceptions.
Jeremy D. Miller
@jeremydmiller
So the routing determination is working if there are Envelopes created, so now I just don't know
Willem Meints
@wmeints
It looks like it. Going to follow this one a bit further to see where exactly it goes weird.
Got an exception :-)
fail: Jasper.Runtime.JasperRuntime[201]
      Failed to send outgoing envelopes batch to rabbitmq://exchange/events
      System.NullReferenceException: Object reference not set to an instance of an object.
         at Jasper.Runtime.Routing.TopicRouting.DetermineTopicName(Envelope envelope)
         at Jasper.RabbitMQ.Internal.RabbitMqSender.SendAsync(Envelope envelope)
         at Jasper.Transports.Sending.SendingAgent.sendWithExplicitHandlingAsync(Envelope envelope)
Oh wait, that's my mistake. Set the virtual host to /.
Willem Meints
@wmeints
Okay, so this is not related to the event forwarding. I also had the persistent outbox in the configuration. Removed it, and now the events are getting forwarded to rabbitmq. With the persistent outbox, I don't see anything in the database, and nothing gets published.
Willem Meints
@wmeints
Found it! I was using ToRabbitTopics in my configuration. But that wasn't working. I'm now using ToRabbitExchange and now the persistent outbox works, and I'm getting events published to my other service.
Jeremy D. Miller
@jeremydmiller
Okay. I saw the exception up above. Guess the next thing is hardening that
Or at least getting a better error message
Willem Meints
@wmeints
Yeah, I think that's nice to have there. Thanks for your help though, it got me thinking in the right direction :-)
Jeremy D. Miller
@jeremydmiller
Thank you for taking it out for a spin!
Willem Meints
@wmeints
So far, I'm impressed by how well it works without docs :P Many frameworks are a mess without good docs.
Jeremy D. Miller
@jeremydmiller
That's good, but it's time to get caught up on docs:)
Hoped to have that before my talk the other night, but life had other plans for me
Willem Meints
@wmeints
It happens. It's open source, so I'm not expecting that people spend they're entire free time on it.
Jeremy D. Miller
@jeremydmiller
Jasper development is happening in earnest again. Here's new documentation on the error handling capabilities in Jasper 2: https://github.com/JasperFx/jasper/blob/master/docs/guide/messages/error-handling.md
Jay Zahiri
@jay-zahiri
Hi! I'm completely new to Jasper so sorry if this question has an obvious answer. Could I use Jasper (with MartenDB) as an event bus only and keep MediatR for CQRS and GCP Pubsub for messaging? Basically, I want to tap into Jaspers outbox/inbox pattern for event – if that makes sense
Jeremy D. Miller
@jeremydmiller
Jasper is a superset of what little MediatR actually does, and the outbox isn't exposed outside of using Jasper. And there's not yet a GCP transport in Jasper. That's a whole lot of "maybe down the line"
Jeremy D. Miller
@jeremydmiller
Jeremy D. Miller
@jeremydmiller
Haven’t updated the website yet, but will soon
Jeremy D. Miller
@jeremydmiller
Hey folks, Jasper has been renamed and relocated to “Wolverine” —> https://gitter.im/JasperFx/Wolverine?utm_source=share-link&utm_medium=link&utm_campaign=share-link