Module: IngestionEventPublisher

Defined in:
lib/apl-library/ingestion_event_publisher.rb

Constant Summary collapse

INGESTOR_APP_NAME =
"shovel"

Instance Method Summary collapse

Instance Method Details

#publish_ingestion_event(entity_name, entity_type, entity_id, client_ref_id, status, bu_id, exchange_name, ingestion_comment) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/apl-library/ingestion_event_publisher.rb', line 7

def publish_ingestion_event entity_name, entity_type, entity_id, client_ref_id, status, bu_id, exchange_name, ingestion_comment
  ingestion_rules = IngestionRule.where(:bu_id => bu_id, :entity_type => entity_type,  :status => status)
  return unless ingestion_rules.blank?
  headers = {'X_BU_ID' => bu_id}
  context = {:clientRefId => client_ref_id, :type => entity_type.underscore}
  publish_ingestion_event_generic entity_name, entity_id, headers, context, exchange_name
end

#publish_ingestion_event_generic(entity_name, group_id, headers, context, exchange_name = nil) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/apl-library/ingestion_event_publisher.rb', line 15

def publish_ingestion_event_generic entity_name, group_id, headers, context, exchange_name=nil
  exchange_name = exchange_name.blank? ? "#{SERVICE_NAME}_shovel_#{DEPLOY_ENV}" : exchange_name
  payload = {:entity_name => entity_name, :group_id => group_id, :headers => headers.to_json.to_s, :context => context.to_json.to_s}
  args = {:request_uri => "#{SupplyChain.get_url(INGESTOR_APP_NAME)}/events", :http_method => 'POST',
          :payload => payload.to_json, :exchange_name => exchange_name, :group_id => group_id}
  ScCore::MessageBus.send("shovel event for #{entity_name}", args, :async => true)
end