Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need to create a REST based web service where the request will be handled asynchronously.
By asynchronous, I mean that the client will make the request and continue with its execution with out waiting for the response from the service.Is it possible to achieve this?
I need to deploy the service in WebSphere Application Server.
So I am not sure if your question is about how to do asynchronous processing on the server, or how to handle asynchronous operations in a RESTful manner. If it is the latter, then here is a summary of the approach suggested at: http://restcookbook.com/Resources/asynchroneous-operations/
Code your service method to
(a) handle the requested operation asynchronously (using a separate
thread most likely).
(b) Immediately return a response code of 202-Accepted
(c) In the response body, return a URI that represents the status of the requested operation.
Then code your client to:
(a) Call the main service method. When the response is completed, if the response code is 202, note the URI returned in the body.
(b) In a background thread, periodically poll that URI, until it returns an indication that the operation is complete.
Yes, you could create a Thread which calls your REST service. Maybe you could see how to achieve this here:
http://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am currently trying to use the AWS method GetPreSignedURL which doesn't not have a asynchronous alternative. Why would it not provide an asynchronous option?
As this makes an http request which could in theory take a long time, should this operation be be wrapped in a Task to mitigate this and make the application more performant? e.g
public async Task<string> GetPreSignedURL(GetPreSignedUrlRequest request)
{
try
{
return await Task.FromResult(awsClient.GetPreSignedURL())
}
catch (Exception e)
{
// Do something
}
}
This would then be called by something like
await GetPreSignedURL(request)
this makes an http request which could in theory take a long time
^ Here's the misunderstanding.
The HTTP request is not actually performed at this time. What this method does is it takes an HTTP URL (including parameters) and then signs it using your service's credentials. It then returns a new URL that is signed with your credentials, which you can pass elsewhere (e.g., return to your caller). At some point in the future, some other code will issue the actual request using that new URL.
Since your service credentials are already in-memory, and since signing is a CPU operation with no I/O, this operation is properly represented as a synchronous API.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I've got a Django application, which has an form to order stuff. After the form is submitted you should be forwarded to a confirmation site, while two e-mails should be send as well.
Sending an e-mail with Django is not the problem
send_mail(subject, plain_message, from_email, [order.customer.email], html_message=html_message)
but it seems not happening in a asynchronous way as it takes some time.
I would just like call my send_email method, let the sending be handled asynchronous and then proceed with forwarding.
How would I accomplish this, what kind of possibilities do I have? I am fairly new to Django/Python but I imagine creating a Thread or sth like it? Whats best practise for this case?
As suggested in the comments you need to implement a task queue and worker. In my projects I use django-rq and Redis.
See the repo here: https://github.com/rq/django-rq
Then you can push the send_mail function into the queue as shown in the example:
import django_rq
# process stuff here
# queue the email for sending
django_rq.enqueue(send_mail, subject, plain_message, from_email, [order.customer.email], html_message=html_message)
But make sure that you'll need to also have a worker in the background to actually process the items in the queue.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I test ray on local with different machines. Most of them run fine but one of these got (pid=raylet) E0515 16:26:30.978312 358451 node_manager.cc:3537] Failed to send get core worker stats request: IOError: 8: Sent message larger than max (290460356 vs. 104857600) this warning. And the performance in this machine dose lower then others. If there are any connections between them?
When Ray head cluster is initialized, it starts a built-in dashboard which collects metrics across the cluster. I guess since your cluster is really large, some of this requests exceed the max request size.
In this case, you can turn off the dashboard. You can do this by setting an argument --include-web-ui when you launch the head node. For example,
If you launch the head node from the script.
ray.init(include_webui=False)
If you launch the head node using the command line tool
ray start --include-webui=False
Could not find any current questions that solve my problem.
I am using the nodejs-howto sample from alexa tutorial. Located https://github.com/alexa/skill-sample-nodejs-howto.
I have followed the instructions for the Alexa-Hosted and was successful in creating the app.
I am using the alea simulator for testing via typing in the questions.
Problem: After asking the first question which does return the correct response. I then ask another question but the simulator seems to have closed my skill and the question is sent to the default alexa where of course my question does not exist. I have to re-invoke the skill after the first question.
My code is copy and pasted from the instruction from the above github link.
Thanks.
It seems your session is getting closed after the first response. Make sure that your intent response sets shouldEndSession as false
shouldEndSession
A boolean value that indicates what should happen after Alexa speaks
the response:
true: The session ends.
false: Alexa opens the microphone for a few
seconds to listen for the user's response. When you use false, include
a reprompt to give the user a second chance to respond.
null / undefined: Behavior depends on the type of device and the content of
the response. See Keep the Session Open.
EDIT : As per #R.Vait and #dan comments
Check whether a re-prompt is used and is properly configured.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I am trying to move a traveler profile into a PNR by sending the "NM" Sabre command via the SabreCommandLLSRQ web service call and get "Invalid Input for GDS" as the response. This command works via Sabre Red, but for some reason doesn't seem support via webservice.
Is there a list of unsupported commands, or is there something I'm missing?
Apparently, the Output format of the request was set to "SDS" instead of "SCREEN" and that apparently has some serious side effects on what commands can be executed.
Is this for Legacy Stars or new Sabre Profiles?
Have you checked out the Move Profile to PNR service API?
https://developer.sabre.com/docs/read/soap_apis/profiles/build_reservation/Copy_Profile_to_Itinerary
Might not be relevant, but if you're using PassengerDetailsRQ you can just set UniqueId on ProfileRQ
https://developer.sabre.com/docs/read/soap_apis/management/itinerary/Passenger_Details
Blockquote I like to connect Flights api App using php file dsbridge.php by making
ajax request to the class curl Bridge getting array response
error - invalid_client
error_descr - Credentials are missing or the syntax is not correct.
When I make the _dsAppKey using base64 tool using this procedure.
1. Base64 your Client Id
2. Base64 Client Secret
3. Concatenate both Base64 values with a :
4. Base64 the concatenation.
It still gives me the Response code as NULL. This code gives me the
Access token. You have to send another request to the Sabre Api.
Pl. help me with the complete example.