My project is based on GAE/J and utilizing the recent launched PULL queue, but I think the question can also be applied to Python.
Basically, when I put a task into the PULL queue, I need to set some params of the task for the later consumer to pick it up.
I have implemented in the params setting in both ways:
1) By using param()
:
TaskOptions taskOptions = TaskOptions.Builder.
withMethod(TaskOptions.Method.PULL);
taskOptions.param("param", paramValue);
taskOptions.param("param2", paramValue2);
2) By using payload()
:
TaskOptions taskOptions = TaskOptions.Builder.
withMethod(TaskOptions.Method.PULL);
taskOptions.payload("payloadValue");
Both approaches are working, however, what I would like to know is what's the differences between the two, and which way should be the preferred way in terms of efficiency or convenience.
I can see that by using param()
, it is easy to set multiple parameters and also easy to retrieve the parameters for the consumer.
But for one parameter cases, then payload may come in more handy as it saves the code to catch Exceptions throwing out when the consumer extract parameters.
However, I would be happy to know any more differences between these two apart from what I have menitoned.