mardi 5 mai 2015

AWS Elasticache use with Periodic Tasks

I am trying to use ElastiCache with a Spring app that is supposed to be deployed as a worker application in a worker environment on AWS.

The app has a a cron job which should run every 5 minutes and update some data on ElastiCache. The cron.yaml is defined as:

version: 1
cron:
 - name: "memcache-dataset-update-job"
   url: "/runcron"
   schedule: "0/5 * * * *"

"/runcron" calls the following method:

@RequestMapping(method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public void updateDataSet(){

    try {
        dataSet = initializeNewDataSet();

        memcached = new MemcachedClient(new BinaryConnectionFactory(ClientMode.Dynamic), 
                AddrUtil.getAddresses(memcacheConfigEndpoint));
        // Store a value (async) for one hour
        memcached.set(dataSetKey, 1800, dataSetObject);
    }

My question: 1. Should the request mapping be for http POST? 2. Do I need to define permissions in the IAM worker role to allow my app access to ElastiCache. If yes, how? I could not find any help here on AWS docs.




Aucun commentaire:

Enregistrer un commentaire