Re-send records missing in a Connec! ready application

It may happen that a Connec! ready application did not receive notifications from Connec! about records updates. This may be coming from the application having a slow down, connectivity issue or any other random problem.

Using Splunk, you can query the Connec! logs to find notifications that have timed out when receiving notifications:

Query
index="prd-connec-web" "group_id=pbw.mcube.co" "action=notify-message-timeout" Organizations

Returning the following logs:

Response
E, [2015-08-07T02:30:09.907000 #10650] ERROR -- : channel_id=org-fc8y, group_id=pbw.mcube.co, url=http://pbw.mcube.co/maestrano/data/subscribe.php, stack=cube, action=notify-message-timeout, request={"timeout":10,"body":"{\"entity\":\"Organizations\",\"id\":\"faff7411-5b66-0132-a23e-22000aac819e\"}"}
E, [2015-08-06T15:05:51.794000 #6389] ERROR -- : channel_id=org-fc8y, group_id=pbw.mcube.co, url=http://pbw.mcube.co/maestrano/data/subscribe.php, stack=cube, action=notify-message-timeout, request={"timeout":10,"body":"{\"recipient_id\":\"pbw.mcube.co\",\"object\":\"Organizations\",\"object_id\":\"a86840a1-5b62-0132-93c3-22000aac819e\",\"entity\":\"Organizations\",\"id\":\"a86840a1-5b62-0132-93c3-22000aac819e\"}"}

When you have identified a period of time where the application was not responsive, you can then SSH onto a Connec! instance and run the following script

# ChannelID and GroupID of the application to send notifications to
channel_id = 'org-fc8y'
group_id = 'pbw.mcube.co'

# Load the application instance (should be a cube)
a = MnoAppInstance.find_by_uid group_id

# Use the correct Entity type you need to update (Organization, Person, Account, Invoice...)
# And set the time period where Entities have been updated and the application did not receive notifications
Entity::Organization.on_channel(channel_id).where(:updated_at.gt => Time.parse('2015-07-01'), :updated_at.lt => Time.parse('2015-07-02')).each do |o|
  a.notify([{entity: 'Organization', id: o.id}])
end

It is probably a good idea as well to check the application logs and verify the notifications are coming through.