I configured invoker to make webservice request when ticket is changed or updated.
it working fine.
If the ticket changed and the remote webservice is not running than it will wait till timeout happen and after that it wont make another request.
Now one requirement i got is when ticket is changed the invoker will make a call to remote host url, if that remote webservice is not running than after timeout happens i have to make another request to webservice till remote webservice gets the request.
how can i configure the invoker to resend the request to the remote webservice.
I have worked with the Generic Interface for quite some time and in my experience you can't configure it to behave like this.
You can however create your own solution:
You could add a dynamic field for all tickets of type checkbox, let's call it WebserviceUnavailable and set it to False/Invalid by default. In your invoker the first thing you do is set that dynamic field WebserviceUnavailable to True. Then you do your processing and prepare your data for the Generic Interface as usual. In the code for the response you set the dynamic field WebserviceUnavailable to False if your processing went well.
Then you can write another script that gets called periodically (using a Cronjob for example). In this script you search for all tickets that have the Webserviceunavailable dynamic field with the value True. For each of those tickets you call your webservice again.
Related
I have a sample Spring Rest application.
I have several clients accessing an API in the Spring Rest application. The API checks whether a job has started or not against the MSSQL DB that we use.
If the Job status in DB is in started status, it will pick the record and update its status to inprogress and return the details of the Job as the response to the API and based on that the client will do some processing.
We have observed that, more than one client is picking up the same Job which is in started status and updates it to inprogress and pass the response to the client. So, it ends up like the same job is being processed by multiple clients.
We tried to resolve this by adding a synchronized block and enclosed the DB call that picks the record in started state and update it to inprogress. The DB call resides in the service layer. But still the duplicate issue is there.
If the controller and the subsequent layers like service and DAO layers are singleton then, when multiple API calls hit the web app, the synchronized block of code should be executed by one request at a time. But that is not what we see practically.
Could someone please help to resolve this issue?
Actually Rest Controllers are Thread Safe it means it is capable of handling each HTTP requests unique. Also when you try to access the Rest Controller it creates a separate session id in browser you can also check that using developer console. Here you are trying to access same DB and change the status as inprogress, so there is a chance for the next api to fetch details of the previous session.. so try to modify the Rest API without modifying status in DB every time or you can do something like, if the DB is accessed by one API then the other API should not be able to access DB until the first connection is closed. Hope this can work for you.
I know I don't have any code to show you guys, I am stuck at some point and I dont know where to start. I hope someone will help me.
I am developing a Spring MVC application, and I need to send a message to all active session users to execute a script which is available to all the clients as it is defined in a js file and included for every user.
I have looked around and found some frameworks which offers these type of functionalities like Atmosphere but I don't think it should be used in my situation as it is a big framework and the functionality required is very little. I have also gone thorough WebSockets but I cant find anything which would help me in invoking the script on client side for all the clients.
If someone can help me go to a right path or direct me to a similar example. I will be grateful
****Update****
I can also use polling if there is way that: if the controller gets a request the session should be considered idle during that, for instance, there is controller which is called every 5 minutes and in the session out time is 30 minutes. The session won't expire in this time if the controller used for polling is called every 5 minutes, I need to exclude the particular controller from calculating the idle time
No Polling Solution:
From what I gather, you need a Remote Procedure Call mechanism.
I would go with https://github.com/eriksank/rpc-websocket.
The general idea:
Your clients register themselves to your server process as "consumers".
When a message is ready, your server then goes through every registered "consumer" and sends the message which rpc-websocket can handle .
Polling Solution:
Here is a general idea, works if you have registered, logged on users.
Have a database table that stores messages, lets call it "messages".
Have a database table that keeps track of messages and users, lets call it "message_tracker". if a user has seen a message, there will be a row in this table for the messageId and UserID.
Have a javascript script poll a server url for new messages. What is a new message can be decided based on the database tables above.
If a new message is found, process it and then call another server url which inserts into the message_tracker database table
I have to make a method in spring project which gets executed always without interfering of the user.
In fact, my application's main goal is to send emails every specified time without clicking a button.
Just the system sending the emails after configuring the database of emails.
You can use the #Scheduled annotation to trigger a method invocation. See the documentation: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/scheduling.html#scheduling-annotation-support-scheduled
I'm running a multi-threaded load test using SoapUI open source edition. I'm testing an asynchronous web-service. I send requests to the service via SoapUI, these requests are queued for later execution, and the web service sends notification responses later.
I'm using a MockService to capture these notification responses. I now need a way of mapping each response back to the request that SoapUI originally sent out so that the latency from request to response can be tracked. To do this, I was going to define a ConcurrentHashMap. The test step that sends a request would update the hashmap with the request id and current time. When my MockService receives a notification response it would access the hashmap to get the start time of that request id.
The problem I'm facing is that I would need to declare the hashmap in a scope where all the threads access the same hashmap and the MockService also has access to it.
If I declare my hashmap in a groovy test step, then each thread when executing the test step would create its own copy of it, which is not what I want.
My question is whether there is a way in SoapUI to declare my hashmap at a "global" scope so that all the test threads (and my MockService) can access the same hashmap instance?
I tried declaring it in the setup script of the TestSuite and adding it to the TestSuite context but that doesn't seem to be working.
Can someone help with this?
I have a Spring MVC web application that is generating a report on the server, once the report is generated, I need to enable a button that allows the user to download it. I am not sure how to go about doing this.
I figured that I will have to spawn off a thread that will just keep checking for the existence of the file and use javascript (jQuery or prototype most likely) to handle the UI elements, but I'm just not sure how to tie these all together.
There are no threads in Javascript. Instead you'll set a timeout to do the polling. The polling would take the form of a URL that will respond with some sort of "ready" indicator when the file is ready. If the file is not ready, then the AJAX success handler will start another timeout. When the server says it's ready, your Javascript handler will make the button visible and no further polling will be necessary.
Check this example here http://forum.springsource.org/showthread.php?t=70489 and let know if it works
You could use some type of messaging on the server that tells the client when the file is ready e.g. we us a table for all report requests and the server writes the status into the table and the client is then asking for the status of the report job with an AJAX call every few seconds.