How to schedule web services responses? - java

I'm a bit new to web services, but I'm using Axis2 with Java.
My question is simple, is it possible to schedule a web service function to return String data every, say 10 minutes?

Having a webservice deliver something to you (push) is not possible, since it's an interface used for retrieving (pull) data.
Client side, you can build an application, either as a standalone application, using Thread.sleep, waiting for a given period of time, or you utilize JCron, Quartz or another scheduling API for querying at a given interval.
So, in summary, you cannot have a web service deliver "anything" at a given interval.

Related

calling Django API using apache (mod_wsgi)

I have a frontend web tool which interacts with REST API written in danjgo. Each API calls take long time to process the call and is also CPU/GPU intensive. So I am planning to run only 1 call at a time and putting rest of the calls in queue. Now I am not sure if Celery with redis can be helpful here or should I stick with job queue approach at the java side.
So, the tool would be used by multiple users and and so each user would have their jobs. So, I need to put the jobs in queue so that they can be processed one by one asynchronously. Would Celery be helpful here?

How to make IBM MQ listener process slowly using spring java application

We are trying to migrate our legacy system to Micro service
With Paas environment, we have scheduler jobs to trigger and put messages in MQ one by one and we have MQ listener in our Microservice to get message and create request and send request to external party.
Here the problem comes our micro service is capable doing Asynchronous call to external service, but our external service is not able to handle Asynchronous call so it is returning wrong data.
For example, we are hitting external service with 40 to 60 request per minute and external service is capable to handle only 6 request per minute.
So how can I make the MQ listener to process slowly.
I have tried reducing setMaxConcurrenceConsumer to 1 and
Used observable.toblocking.single() to make the process to run in only one thread.
We use RxJava in our micro service.
It sounds like either your micro service or the external service is not following the use case for Request-Reply messaging.
(1) Is the external service setting the Reply's message Correlation ID with the Request message's Message ID?
(2) Is your micro service performing an MQGET with the matching option of getting by Correlation ID.
You can blame the external service for the error but if your micro service is actually picking up the wrong message then it is your application's fault. i.e. Does your micro service simply get the "next" message on the queue?
Read this answer: How to match MQ Server reply messages to the correct request
Here's a explanation (looks like from the 90's but has good information): https://www.enterpriseintegrationpatterns.com/patterns/messaging/RequestReplyJmsExample.html
In long term approach we are planning to migrate the External service to as well.
In short time i have fixed it using the observable.toblocking.single() ,thread.sleep(), and setMaxConcurrenceConsumer() to 1 so only one thread will run at a time. which will avoid the Asynchronous call to external service.The sleep time will set dynamically with some analysis done on the external service.

Update the sqlite database by making web service calls at regular intervals in java

I have a Java JsonRPC webservice application(we can also think of it as a client application that uses other web services.) This jsonrpc webservice application has a sqlite db.
This web service is doing a number of tasks (such as calling web services, sending transactions, querying balance, etc.).
These calls are transactions made by the user.
Another important task of this web service is to update the local database (sqlite) by making a web service call at regular intervals (10 seconds).
The process that runs continuously with this 10 second time interval should not interfere with other read and write operations.
How can I find a solution for this problem? Should I create a child thread in the java main thread?
Yes , creating another Thread will work bu another cleaner approach is to use Spring Quartz

Java patterns for long running process in a web service

I'm building a web service that executes a database process (SQL code to run several queries , then move data between two really large tables), I'm assuming some processes might take 2 to 10 hours to execute.
What are the best practices for executing a long running database process from within a Java web service (it's actually REST-based using JAX-RS and Spring)? The process would be executed upon 1 web service call. It is expected that this execution would be done once a week.
Thanks in advance!
It's gotta be asynchronous.
Since your web service call is an RPC, best to have the implementation validate the request, put it on a queue for processing, and immediately send back a response that has a token or URL to check on progress.
Set up a JMS queue and register a listener that takes the message off the queue and persists it.
If this is really taking 2-10 hours, I'd recommend looking at your schema and queries to see if you can speed it up. There's an index missing somewhere, I'd bet.
Where I work, I am currently evaluating different strategies for this exact situation, only times are different.
With the times you state, you may be better served by using Publish/Subscribe message queuing (ActiveMQ).

jBPM Web Service

I ve got a question regarding jBPM. In one of our projects I developed an enterprise service (.Net) that other systems (jBPM, Delphi, etc.) should receive data from. For this I am providing a SOAP interface.
Now there's a case that when the a jBPM system contacts the service, some manual work has to be done before the data the system needs can be returned. In this case, the SOAP service returns a "ManualWorkTicketId". This id can then be used to poll the SOAP interface in let's say 1 minute intervals. As soon as the manual work has been done , the SOAP service is able to return the required data to the jBPM system.
Since the enterprise service should not know about any systems and just provide a SOAP interface for communication, I see this as a good solution to handle the asnychronous part.
But the jBPM developer told me that this isn't a good approach. Instead he suggests to write the information in an ActiveMQ queue, that I should listen to. When then manual work is done, I have to write back to another queue the jBPM system provided me, where the message then is consumed by the jBPM process.
question: Since I am not a jbpm developer, I was wondering if there isn't a standard pattern to handle the web service polling part within jBPM?
question: Which approach would you suggest in such cases keeping in mind that the enterprise service should be loosely coupled?
If you implement a JMS queue, then I assume the Delphi developer will complain. SOAP is a good solution.
Take a look at this, and give it to the jBPM developer. (btw, are you using jbpm 3 or 4?)
If perfect timing isn't important, he can poll the SOAP service every X minutes and see the result.

Categories