Coder Social home page Coder Social logo

Comments (5)

andrzejkrzywda avatar andrzejkrzywda commented on August 19, 2024

We have this file https://github.com/RailsEventStore/ecommerce/blob/master/ecommerce/crm/lib/crm.rb which registers the command handler for a command. Is it missing in your code?

from ecommerce.

Ariharan2002 avatar Ariharan2002 commented on August 19, 2024

But i required that too,
require "infra"
require_relative "crm/commands/promote_customer_to_vip"
require_relative "crm/commands/register_customer"
require_relative "crm/commands/assign_customer_to_order"

require_relative "crm/events/customer_promoted_to_vip"
require_relative "crm/events/customer_registered"
require_relative "crm/events/customer_assigned_to_order.rb"

require_relative "crm/customer_service"
require_relative "crm/customer"
require_relative "crm/order_service"
require_relative "crm/order"

module Crm
class Configuration

def call(event_store, command_bus)
  command_bus.register(RegisterCustomer, OnRegistration.new(event_store))
end

end
end
Is there any requirement needed for command handler registration

from ecommerce.

andrzejkrzywda avatar andrzejkrzywda commented on August 19, 2024

Can you show the code where you call this Configuration class?

from ecommerce.

Ariharan2002 avatar Ariharan2002 commented on August 19, 2024

lib/configuration.rb

frozen_string_literal: true

require_relative '../../bloggie/configuration'
require_relative '../../infra/lib/infra'
require_relative '../app/read_models/Topics/register_topic'

require_relative '../app/read_models/Topics/update_topic'

class Configuration
def call(event_store, command_bus)
enable_res_infra_event_linking(event_store)

enable_topic_read_model(event_store)
Bloggie::Configuration.new.call(event_store, command_bus)

end

private

def enable_res_infra_event_linking(event_store)
[
RailsEventStore::LinkByEventType.new,
RailsEventStore::LinkByCorrelationId.new,
RailsEventStore::LinkByCausationId.new
].each { |h| event_store.subscribe_to_all_events(h) }
end

def enable_topic_read_model(event_store)
Topics::Configuration.new.call(event_store)
end
end

bloggie/configuration.rb

frozen_string_literal: true

require_relative 'TopicSupport/lib/topic_support'
require_relative '../rails_application/app/read_models/Topics/register_topic'
require_relative '../rails_application/app/read_models/Topics/update_topic'
module Bloggie
class Configuration

def initialize
  super
end

def call(event_store, command_bus)
  configure_bounded_contexts
end

def configure_bounded_contexts
  event_store = Rails.configuration.event_store
  command_bus = Rails.configuration.command_bus

  [TopicSupport::Configuration.new].each { |c| c.call(event_store, command_bus) }
end

end
end

i made some mistakes in call then i fixed now its working,
Thank you @andrzejkrzywda

from ecommerce.

andrzejkrzywda avatar andrzejkrzywda commented on August 19, 2024

Cool, I'm glad it works now.

Feel free to ask in case of other questions.

from ecommerce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.