Add Parameters to Google Cloud Tasks - java

I want to add a parameter to the Cloud Tasks that can then be retrieved from the Task handler using:
request.getParameter("paramName");
Previously in App Engine Standard I would do the following:
TaskOptions options = TaskOptions.Builder.withUrl(backURL)
.param("paramName", "value")
.method(Method.POST);
How do I accomplish the same using the Cloud Tasks java client library. It seems like in the AppEngineHttpRequest builder there should be a setParameter option but that doesn't exist.
AppEngineHttpRequest request = AppEngineHttpRequest.newBuilder()
.setRelativeUri(backURL)
.setHttpMethod(HttpMethod.POST)
.build();

Looking at the article called HTTP Target tasks we see an example of building a task in Java. Within the configuration, we see two primary setters .. namely body and url. I am thinking that what you are wanting to set are request query parameters. If this were a plain request it would be:
https://somehost.com/somepath?someParam=someValue
If this holds, then it is likely that if you want to pass in query parameters with your task, you would add them to the uri used to invoke the task handler.

Related

OpenStack Projects List HTTP request ignoring pagination "limit=" parameter

I am trying to retrieve a list of projects from the OpenStack API, and would like to use pagination in order to retrieve n projects at a time.
In the OpenStack documentation, it states that I can append "/?limit=n" to the URL and up to n results will be fetched accordingly.
However, when executing the GET request to the URL as follows:
https://identity-3.eu-de-1.cloud.sap/v3/auth/projects/?limit=1
I still get ALL projects. I can't seem to understand what I am missing.
NOTE: the request itself works and returns results as needed, but simply ignores the limit parameter (this is not an authentication issue).
I think it does not all OpenStack API provide limit parameter
In keystone API doc, there is no limit parameter in Request parameter descriptions for /v3/auth/projects API
keystone-project-API-doc
Other services like cinder volume list, it provides limit parameter in doc
cinder-volume-API-doc

Handle request in Google App Engine Task Queue

We are building analytics tool which collect events from web site and mobile apps. We want to process the request with Task queue in Google App engine. When i refer the doc in Google Developers site
Queue queue = QueueFactory.getDefaultQueue();
queue.add(withUrl("/analytics").param("id", String.valueOf(id)));
It has option to give only param. But how do i pass entire HTTP request to task queue and process them?
I assume the main problem here is how to pass all the request parameters and the request body to the task.
Unfortunately there is no simple "relay" or "redirect" method to move your request to the task queue (but it would be nice). You have to use the Queue.add(TaskOptions taskOptions) method to add your task.
The recommended way to instantiate a TaskOptions object is to statically import TaskOptions.Builder.* and invoke a static creation method followed by an instance mutator (if needed).
And use one of the following (or any other payload() methods):
TaskOptions.payload(byte[] payload);
TaskOptions.payload(byte[] payload, String contentType);
TaskOptions.payload(String payload);
to set the content of the request. You can get the payload by reading it from the request.getInputStream().
The request parameters (if they are part of the URL and not the result of a form POST for example) you have to manually copy each with e.g. TaskOptions.param(String name, String value).

JMeter HTTP POST based on HTTP GET

I am using JMeter to do some testing.
I have to do a HTTP GET on a URL like www.acme.com/documents/next.
This shall return me a document ID, then i need to do a POST based on that document ID like
www.acme.com/document/{document_id}. This document ID shall be the one returned by the previous GET request.
I will need to run this in many threads, so if there needs to be a variable used to store the result of the GET, it should be stored in something like a ThreadLocal because each one will get a unique id when it called the GET method.
You should use postprocessor to extract variable. Your test plan will look like this:
Thread Group
- GET request to /documents/next
--- Regular Expression Extractor (with reference name=variable)
- POST request to /document/${variable}

How to set TimeToLive Parameter in ActiveMQ via AJAX?

I have a question about ActiveMQ and the AJAX Interface concerning the life span of a message. In the AMQ web interface, I can set a TimeToLive Value for a message in milliseconds.
I've already found out, that I can use this parameter via REST:
curl -vd body="test" "http://localhost:8161/demo/message/TESTQUEUE?type=queue&JMSTimeToLive=500&JMSPersistent=-1"
This example message will live 500ms
But how can I use the AMQ Ajax Interface to set those parameters?
The JavaScript function to send a message provides only two parameters
amq.sendMessage(myDestination,myMessage);
Info: http://activemq.apache.org/ajax.html
myDestination is unfortunately not an URL, it's something like this "queue://"
Thanks four your help
Regards
Rolf
The current implementation of the AJAX client does not offer the possibility to send a message with a time to live.
The time to leave of the message is basically set in the message property (headers), via the property "JMSExpiration"
Currently if you go through the amq.js code, you see there is no API that allows you to define the headers or Time to Live.
It should be relatively easy to add this feature to the client. Check the code, you could probably just hardcode the TTL for your application. At the end, it just does a post command in the same way that you do your REST call.

JMeter: Load testing of a HTTP POST followed by a HTTP GET

I am evaluating performance of my transport library and it will be helpful if I get suggestions on the following:
I use a Junit sampler to perform the following:
HTTP POST test: I send a HTTP POST request: This will cause a DB write. I have to evaluate all the parameters (throughput, avg. response time) holistically for POST + DB_WRITE operation. As response to this POST request, I get a unique id. So if I send 1000 successful POST requests, I will have 1000 unique ids.
Now my question is how can I use these unique ids for my next test case, perform a HTTP GET on each of created unique ids.
I can parse the HTTP POST response and write the unique id into a file and try using that file for my HTTP GET test. But the problem is if I create a thread group of 10 different threads, there will be issues of synchronization on file writing.
Is there any PostProcessor I can use to record results in filesystem?
As for me looks like you can avoid usage of file to store and then read generated id's.
Logic is the following:
execute your POST request;
parse response returned from POST - using Regular Expression Extractor or any other post-processor attached to the request - to extract your ID;
store extracted ID in user-unique / thread-unique variable - in the same post-processor;
how to do this for Regular Expression Extractor see below: ${__javaScript('${username}'+'UnicID')} generates unique variable for each user/thread, to avoid interference in multi-user cases;
seems that can also use threadNum function instead of ${username} variable;
if POST request completed successfully, ID extracted and stored in variable - execute your GET request were extracted ID is used as param;
use ${__V(${username}UnicID)} construction to get back previously saved ID.
You may add also add Debug PostProcessor to POST request sampler - to monitor generated variables and their values.
Seems that's all.
Thread Group
Number of Threads = X
Loop Count = N
. . .
HTTP Request POST
checkingReturnCode // Response Assertion
extractUniqueID // Regular Expression Extractor (e.g.)
Reference Name = ${__javaScript('${username}'+'UnicID')}
Regular Expression = ...
Template = $1$
Match No. = 1
Default Value = NOTFOUND
IF Controller // execute GET only if POST was successful
Condition = ${JMeterThread.last_sample_ok} // you may change this to verify that variable with extracted ID is not empty
HTTP Request GET
param = ${__V(${username}UnicID)}
. . .
Hope this will help.
There won't be any problems with synchronization (they are resolved by file system). In every thread (which is POST-ing) you should open your file for writing and append a new line to it. Again, don't worry about synchronization, OS will take care of it.

Categories

Resources