I'm working on a Symfony 3 (PHP) project.
I would like to launch a Java executable using parameters I got from Symfony.
Some informations to consider:
The executable generates a file as an output.
Execution can take several minutes depending on the input parameters.
Multiple users can trigger the execution simultaneously.
I'm looking for a long-term sustainable solution. Do you have any advice?
After some research on queues.io, I found out that Beanstalk for PHP seems to be fitting my needs, but I would like to confirm or infirm this position with you.
What would you do in a similar case?
Related
I need to create a Java application which sends some input parameters to a python script and sends some output back to my java application.
I cannot run the script in my java code using jython Or similar things as the python scripts are build on demand and I may need to add new scripts every now and then. So this should not impact my java app.
My java application will be running on a container and based on a few condition check it might have to select 1 of the py scripts from suppose 100 scripts and run it. And again the condition later on may change and a different script has to run at that time
I went through many websites and tutorials on the net but did not find anything relevant.
Has someone tried anything similar?
I have created a Java program that utilizes Chrome Driver, Selenium, and Java Excel API. The program is used to automate a few different processes on Google Chrome. Currently, setting up this automation is more complicated than I would like it to be: the user needs to download a zipped folder, unzip it, download the Java Runtime Environment, and launch the program using the executable.
My goal is to simplify the installation of the automation. Ideally, a user would come to a SharePoint website, fill out a form with the parameters of the automation (potentially upload an Excel Workbook), click an "execute" button, and the automation would run. As a result, the automation would run seamlessly across platforms (Windows and MacOS) without any modifications.
I have researched changing the programming language to achieve this functionality. I concluded that a different language could remove the need for a Java Runtime Environment download, but it would still require some type of installation process. Additionally, I have researched using HTML/JavaScript, but I concluded that this is not possible because the functionality (triggering a web automation from a website) could be used maliciously without the user's knowledge. Finally, I began researching containerization through Docker. This solution seems promising but I do not know enough about it to determine if it is the appropriate solution.
What would be the best route to achieve the results that I am looking for (outlined in the second paragraph)? I have access to enterprise-grade databases that I thought may be useful. Would it be possible to have the form trigger a virtual machine to run the automation on a remote database and then output the result to the user once it has finished?
Thank you in advance for any guidance you can provide. I do not know much about making a Java program into an enterprise-grade application so any information about what to research is extremely useful. Finally, please do not hesitate to correct my logic at any point in this question as I may have drawn the wrong conclusions from my research.
You want to look into creating a jar file with your selenium code.
I need to execute a java simulation program for a very long time, many hours or maybe days, and i wish i could do it on a server.
I've been heard about Cloud Computing, and i'm searching a free platform, or a very cheap one.
For example, i found Oracle Cloud, but i am open to any type of solution.
On the link there are several points to follow to deploy an application, it seems a bit complicated and you also have to install Maven.
Do you think there is a simpler solution, or that this one could be my best try?
I mean, my program consists on a few .class files, i wish i could edit/compile/run the main class very easily, like with a kind of shell or cmd.
Unfortunately, i know very little about web programming, so i don't know even if this would be possible.
However, assuming i can launch my program, and log in after a very long time, will i be able to read the results?
Or is it possible to write a text file to read the results later?
i wish i could do it on a server. I've been heard about Cloud Computing
A possible solution is using AWS Lambda. You only provide your Java code in a ZIP file and it will run in a "server-less" environment. What this means is that you don't have to setup a server yourself instead AWS will manage everything for you.
i'm searching a free platform, or a very cheap one.
It's not for free, but it's pretty cheap though: https://aws.amazon.com/lambda/pricing/
However, assuming i can launch my program, and log in after a very long time, will i be able to read the results? Or is it possible to write a text file to read the results later?
I would not recommend writing it to a text file, instead look at solutions such as S3 Buckets or Elasticsearch with Kibana
I am building a web-application with PHP front-end and Java as a back-end to retrieve information from the customized Lucene index.
On the PHP, I use exec() to run the JAR that retrieve results from Java lucene index (that prints out only metdata results of the documents and we are dealing with about 300+ lines of String or results). I figured the more the results, the slower the speed of search from PHP. It took roughly 4-5 secs to retrieve 300 line of results but in Java(using Eclipse IDE), only 0.3 sec or lesser is required to retrieve the same results using the same method. I tried running JAR directly from command-line and the search speed is in the middle
So I put timer in the Java to debug the problem and found that what seems to be slowing down is the use of System.out.println(). Without printing out the search results, the search speed in PHP is as fast as in Java IDE.
Is there a good way to capture the output of Java methods from PHP without compromising the speed? I want my search engine to be scale-able and handle more results. btw, I am developing on Windows 7.
This is a very broad subject that involves architecture design and many other things. But to summarize a useful answer I would advice you abandon the current "exec a jar" approach, and convert your java backend into a tomcat webapp, that is always running in the background, ready to answer and without the need to warm up again everytime.
Also, this enables you to cache results, and to scale horizontally (adding another tomcat on the side and balancing charge), etc.
More importantly, you would be using streaming, which is what tomcat would be using via its httpResponse object, which should have considerably better performance than system.out, and last but not least, exec creates a new process at the operating system level, but tomcat use threads (simplifying and for your scenario, should mean better performance).
I would give all that a try, and also google some "apache lucene php client" and see what comes out.
EDIT: have a look at Apache SolR: http://lucene.apache.org/solr/features.html
Is a standalone server powered by Lucene that already features a REST-like API. This will save you the trouble of making a tomcat webapp of your own.
EDIT 2: there is a PHP SolR Client: https://github.com/PTCInc/solr-php-client, but I haven't tried it myself.
Alright! the speed issue is gone. Here's how is solved it:
I deployed a java-backend web app (suggested by #jotadepicas)on a Tomcat server from Eclipse IDE and capture the output from PHP with file_get_contents() function. For now, I just need to learn how to setup webapp on tomcat on XAMPP instead of Eclipse IDE.
Thank you all for helping me solve this. huge thanks to #jotadepicas !
I created a small application that, when run, creates or updates some tables in a database by extracting data from some PDF files. Everything works fine in this desktop application, but the next step for me would be to make it possible for an administrator on a website to upload a PDF file and my Java program would then run and update the tables accordingly.
The problem is I have no idea where to start with this (the site isn't done yet, but I'm running some tests and it is going to be coded in PHP). I'd like to know what kind of technologies I need to let the server run the program and update everything as it would in the offline version. Sometimes it takes a while to update everything, so ideally, the user uploading the PDF could continue browsing other pages while the server does its job. (I'll probably implement something that when the server is done processing the file, it says if the program ended successfully or not in a log file)
Can someone tell me what terms to search for on Google or give me some pointers? I haven't chosen where my website is going to be hosted either, so if someone could tell me what to look for to know if they support running applications like this, I'd really appreciate it as well!
This could also apply to other programming languages as I know a bit of Python and C++ as well, so in the future I might have some applications in those languages I'll want to use on the web.
If I'm not approaching this the right way, I'm open to other suggestions, but the best solution would be to keep my Java program intact as I know it works exactly like I want it to and I'd rather not have to start it all over again.
If your host is *NIX based you can use crontab (Automatic Task Scheduler) to run your program at set intervals. Make it check if a "new" PDF exists, and run the program if there is. There may be a way to use Windows Task Scheduler type programs to do it on Windows. This is probably the easiest way.
Alternately you can use You can use shell_exec() in your php to execute a command on your *NIX system directly to run your java program.