Wiring up ActiveMessaging and SQS today - ran into an issue - thought I’d document it in case anyone else comes across it.
Starting up the poller I kept getting a nil pointer at this line -
plugins/activemessaging/lib/activemessaging/adapters/asqs.rb:64:in `subscribe’: You have a nil object when you didn’t expect it! (NoMethodError)
Which I tracked here:
if @subscriptions.has_key? queue.name
Which is part of this method:
# queue_name string, headers hash
# for sqs, make sure queue exists, if not create, then add to list of polled queues
def subscribe queue_name, message_headers={}
# look at the existing queues, create any that are missing
queue = get_or_create_queue queue_name
if @subscriptions.has_key? queue.name #<=exception here!
@subscriptions[queue.name].add
else
@subscriptions[queue.name] = Subscription.new(queue.name, message_headers)
end
end
The issue turned out to be the @request_expires configuration variable by default is set to 10 milliseconds, and the requests were timing out. So I upped it and things are working great.
What makes this a gotcha is another default configuration setting @reliable is set to true. This means most of the errors encountered will be eaten! So I didn’t get a HTTPBadRequest error - I got this nil pointer. So - when setting this up for the first time, my recommendation would be to set @reliable to false. In fact, its not a bad idea for the ActiveMessaging plug-in in general.