Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 30 2019 14:49
    slashdotdash edited #169
  • Jan 30 2019 14:48
    Freyskeyd commented #249
  • Jan 30 2019 14:48
    Freyskeyd closed #249
  • Jan 30 2019 10:28
    slashdotdash commented #249
  • Jan 30 2019 09:08
    Freyskeyd commented #249
  • Jan 29 2019 11:37
    Freyskeyd commented #187
  • Jan 29 2019 11:34
    Freyskeyd synchronize #249
  • Jan 29 2019 10:50
    Freyskeyd synchronize #249
  • Jan 29 2019 10:16
    slashdotdash closed #231
  • Jan 29 2019 10:16
    slashdotdash commented #231
  • Jan 29 2019 09:48
    Freyskeyd commented #231
  • Jan 29 2019 09:10
    Freyskeyd synchronize #249
  • Jan 28 2019 15:49
    Freyskeyd edited #249
  • Jan 28 2019 15:32
    Freyskeyd synchronize #249
  • Jan 28 2019 15:04
    Freyskeyd opened #249
  • Jan 28 2019 11:20
    imetallica closed #119
  • Jan 28 2019 11:20
    imetallica commented #119
  • Jan 28 2019 10:40
    Freyskeyd commented #119
  • Jan 28 2019 10:40
    slashdotdash commented #184
  • Jan 28 2019 10:39
    Freyskeyd commented #52
Ben Smith
@slashdotdash
Soft delete would be ok as the events will remain.
Günter Glück
@gugl_twitter
Thanks. At the moment I look in the direction of using soft delete. From my understanding I would either copy and transform all events to a new events store or otherwise (only one type or stream) I would append the copied events and therefore change the order of events relative to the non-copied events. I will have a look at the esversioning book again though. My problem with soft delete would be that the original stream id and original stream version would not change as I guess they would still be linked “originally” to the original source that gets soft deleted. Have to do some experiments. Somehow I thought I would find more articles or discussion about that topic. Once I found a good solution for our case I will try to write a post or wiki article about that to put some learnings out there.
Bruno Castro
@brunohkbx

Hey everyone. I'm getting this error after I deployed my app on heroku:
Fri Apr 23 2021 12:58:18 Consistency timeout waiting for aggregate "9a0f98c8-f1c8-4883-86f2-615979315de9" at version 21 metadata

any idea of how to solve that?

Günter Glück
@gugl_twitter
Hi @brunohkbx It seems that the aggregate handled the command will but one of your event handler is not able to process the event. Are you sure that there is no error thrown by one of the event handlers involved?
Scott Ming
@scottming
If you deploy this application with two nodes, but subscribed to the same eventstrore, then you will also encounter this problem, do some configuration can solve it.
@brunohkbx
You can refer to the Commanded documentation on deployment
Ben Smith
@slashdotdash
@brunohkbx To use strong dispatch consistency in a multi-node deployment you either need to use distributed Erlang OR use Redis as the Commanded Application’s pubsub adapter
This is to ensure the event handler acknowlegdements are broadcast to all nodes in the cluster
Bruno Castro
@brunohkbx

Thanks. I've been trying to set up Phoenix.PubSub.Redis as the adapter. but no luck so far.
It works locally but on heroku its throwing this error everytime:

Mon Apr 26 2021 16:19:54 unable to establish initial redis connection. Attempting to reconnect... metadata
Mon Apr 26 2021 16:19:57 failed to publish broadcast due to closed redis connection metadata

Its coming from this process: CommandedApp.PhoenixPubSub.Tracker_shard0

Config:

pubsub: [
      phoenix_pubsub: [
        url: System.fetch_env!("REDIS_URL"),
        node_name: System.get_env("HEROKU_DYNO_ID", "default"),
        pool_size: String.to_integer(System.get_env("REDIS_POOL_SIZE", "10"))
      ]
    ]

Thanks in advance :smile:

Bruno Castro
@brunohkbx
I'm also starting another Phoenix.PubSub.Redis in the application. I don't know if its conflicting with commanded but it works locally.
  {Phoenix.PubSub,
   name: MyApp.PubSub,
   adapter: Phoenix.PubSub.Redis,
   url: redis_config[:url],
   node_name: redis_config[:node_name]},
Bruno Castro
@brunohkbx
just in case someone wonders why the problem was about the runtime configuration. moving everything under the init/1 function fixed it.
Tomek Rybczyński
@rybex
Hello everyone :) Quick question. Is there any option to load manually all events event store? I have events list in a file and I would import all of them to my commanded app. I will be grateful for any hints
Günter Glück
@gugl_twitter
@rybex That recipe could be a good starting point for you: commanded/recipes#14
Tomek Rybczyński
@rybex
@gugl_twitter thx. I will try that :+1:
Jonathan Stiansen
@jonathanstiansen
Hey guys! probably a question that is painfully obvious for most people who understand the in's and out's of commanded - can you share bounded contexts across projects? How do you go about doing that? My initial thought is that it's just the router you'd need to add, and the rest is all in one sub context
Also does anyone use property based testing with commanded? Anything that stands in your way to doing so?
Ben Smith
@slashdotdash
@jonathanstiansen I’ve written an article outlining the various ways you can structure an Elixir application using Commanded: https://10consulting.com/2021/03/18/commanded-application-architecture/
The simplest is to have a single global Commanded Application and EventStore.
You can then define a Commanded router per context and include them in the top-level Commanded Application
defmodule MyApp.App do
  use Commanded.Application,
    otp_app: :my_app,
    event_store: [
      adapter: Commanded.EventStore.Adapters.EventStore,
      event_store: MyApp.EventStore
    ]

  router(MyApp.ContextA.Router)
  router(MyApp.ContextB.Router)
  router(MyApp.ContextC.Router)
  # … etc
end
Jonathan Stiansen
@jonathanstiansen
Nice. That makes sense, I'm thinking (probably incorrectly) about rails engines - and how across apps we may choose to compose different ES systems from the same domains
This seems like it could be a nice solution, the only thing I'd need to redo is the controller level stuff which is great! :-)
Giorgi Kavrelishvili
@grkek
@slashdotdash why is commanded so fucking slow with many
requests
and commands?
Ben Smith
@slashdotdash
@grkek Are you asking for my help, or venting your frustration?
Giorgi Kavrelishvili
@grkek
Both :D
How does one improve the performance of Commanded?
Ben Smith
@slashdotdash

It’s difficult to give guidance without knowing exactly what your domain is. Usually you want to design small, short lived aggregates with few events in their lifetime.

You can partition your application by service, context, tenant, etc. to improve performance by using a separate Commanded Application and EventStore for each. This will help to distribute load, processing, and event store read/writes.

I’ve written up the various architectural choices available.

https://10consulting.com/2021/03/18/commanded-application-architecture/

If you can identify a particular bottleneck in Commanded itself then that can be looked into.
Ben Smith
@slashdotdash
Dispatching commands with consistency: :strong will add latency if used due to blocking until the event(s) have been handled by any configured event handlers. The default event consistency is recommended for low latency.
Tomek Rybczyński
@rybex
@gugl_twitter Hi. Thanks for your previous tip. It helped a lot :) I have one more question. How to check Commanded.ProcessManagers.ProcessManager state? Do you have any example of how to load process manager state locally?
Günter Glück
@gugl_twitter
@rybex Glad it helped. For debugging purposes or something like that?
Tomek Rybczyński
@rybex
@gugl_twitter yes debugging only :)
Günter Glück
@gugl_twitter
@rybex I see. Unfortunately I never tried that but you could try to find a way to start/get the https://github.com/commanded/commanded/blob/master/lib/commanded/process_managers/process_manager_instance.ex you want to investigate state for and find a way to use the process_state function on it but it might be easier to use the telemetry for it. Maybe that is a useful pointer and the better way to go for it: test/process_managers/process_manager_telemetry_test.exs I think I would follow the telemetry path for debugging purposes.
narayan iyer
@iyerland
@slashdotdash When is an aggregate removed from memory (or persisted) and what is done to get it back in memory? Do you re-play all the events in the event_store to re-construct the aggregate?
Ben Smith
@slashdotdash

Aggregate instances persist in memory indefinitely unless you implement the Commanded.Aggregates.AggregateLifespan behaviour.

https://hexdocs.pm/commanded/Commanded.Aggregates.AggregateLifespan.html

An instance is started and its state is rebuilt from either a state snapshot + new events or all historical events on demand when a command is dispatched to it.

narayan iyer
@iyerland
Thanks @slashdotdash
Tomek Rybczyński
@rybex
@gugl_twitter Thx for your response :) I will try that
Marcelo Dominguez
@marpo60
Is it possible to add and remove middleware dynamically?
Ben Smith
@slashdotdash
Not currently as the middleware is configured at compile-time, so it is fixed
But I dont want to add that middleware in the production code, only on some tests.
Ben Smith
@slashdotdash
You could use a compile-time conditional to include the middleware only when the env is :test (configured in config/test.exs):
if Application.compile_env(:my_app, :env) == :test do
  middleware CommandAuditMiddleware
end
# config/test.exs
config :my_app, env: :test
Or use a similar environment check inside the middleware module / functions
Marcelo Dominguez
@marpo60
yeah, that would work.
Thanks Ben for the help and the fast reply!
Ben Smith
@slashdotdash
def before_dispatch(pipeline, env \\ Application.compile_env(:my_app, :env))
def before_dispatch(pipeline, :test) do
  # auditing

  pipeline
end
def before_dispatch(pipeline, _env), do: pipeline