I need my web application to send thousands of per day. Currently, on being triggered by front-end user, i run a for loop in back-end which send mails.
Read this: How can I send an email by Java application using GMail, Yahoo, or Hotmail?
Issues:
If someone closes the web page after sending request, request is incomplete.
It takes long time to send email and user has to wait.
Ideally, i would like to save the email and content in database from where scheduler picks up the job and send email and notify the user once mail is sent/any issue occurs.
How can i achieve this? Will cron jobs help here? What if application is deployed on windows server? Or shall i write a separate java application to pick up the tasks from database and send mail? Can i schedule a job in web application?
Related
I currently am developing a semi-simple chat app. I want the user to be able to communicate with one other person in a private chat. Just plain text will be sent. Currently my system calls php scripts from a webpage, passes in parameters and then parses the data returned. I have it so that the client sends the message, which calls a send message script on my webserver, the script then makes a message file on the webserver and then returns a success or failure back to the client. Then for the client to view this message, it would have to call a script that checks the server for a message file with a message for him. If it finds one, it sends the message back, if not, it sends a response about not having messages.
This technique works perfectly besides the fact that the client either would have to manually refresh to check to see if he had messages, or a background thread would have to refresh every few seconds. That would be fine, however that would use data if the user was on a mobile network. Not to mention the kind of resources a background loop would pull if it was refreshing at a speed that would be convenient.
So, I decided on a second idea, this would be a server programmed in Java, which would communicate over sockets. The user would send the message as a packet over the socket and the server would check to see who it was meant to go to. If the person is online, it passes the message along to that user. However this method requires a constant connection between the client and the server and that is unreliable because what if the user is in the car and data cuts out. Or some other situation where the connection gets severed. Then it would throw errors and have to reconnect.
Anyhow, my question is which technique is better. Or are they both terrible? If so, what is the correct way of doing this? Thanks in advance.
AngularJs and Ajax will be the perfect solution for you , try to learn
for actually real time messaging Use AngularJs
If the amount of data is very less ..say 20-25 messages per day...you can REST APIs on your server to transfer actual text messages and Google Cloud messaging for pushing notifications..Recently I followed this approach to develop private chat for one of my friend.
I'm developing a web application and one of it's features is to send email notifications once the form is submitted. I wonder what's the easiest/best way of sending them asynchronously. I'd like to get the response from the server instantly and invoke an email sending job in the background not waiting for it to finish.
Thanks
You can use JMS to send mails asynchronously.
Here is a question about this befure
You can look at thtis link fopr simple JMS Queue implemantation
In my Java client application, I have a web service call which communicates with a server application using MQ/ESB to update data.
Sometime it happens MQ/ESB is down and the data does not update from one application to another, as MQ/ESB is a channel between the client and server applications.
Is there a site or tool which periodically hits the web service url and reports an error via email when it goes down?
You can use a custom script that fires a curl request periodically and email it based on the response. A simple java program hitting the web service in a loop can also help.
There are monitoring tools like nagios that can be configured and used for this purpose.
Using FreeSiteStatus.com Web-based control panel, enter the URL you wish to monitor (e.g. http://www.yourdomain.com), and select the monitoring interval (e.g. 1 minute). The monitoring interval represents how often we’ll check to see if the website is online and responding properly. The smaller the interval, the more frequently we’ll check your website.
Next, add email, SMS and push contacts to be alerted on outages. We’ll send an email or text message to these contacts any time there is an outage with your URL, so you’ll know instantly if your website goes down.
Features
1. 24 x 7 x 365 Non-Stop Monitoring
2. Worldwide Monitoring
3. Downtime Notification
4. Send Reboot Request to Your Provider during Downtime
5. Multi-Protocol Support
6. Uptime & Performance Reports
7. Push(SMS) Notification
I'm starting out with Grails and want to build a sample application.
Below is the flow of the application I'm envisioning. I'll follow up with questions.
The flow of the app:
User uploads a file
controller gets the file and just sends a response back saying "uploaded"
File is put in a JMS queue
Java service running separately fetches the file from the queue and processes it (just reads the first word)
Java service puts the response back (where does it put the response?)
Grails App will read the response and present it to the user
Questions
Where does the java service put the data after reading the file?
How does the grails app read the data put by the java sevice?
Is there something missing from my understanding? I plan to use grails jms plugin and ActiveMQ
Can something be improved in this architecture? This is a prototype I'm putting together for a bigger application.
I would really appreciate any articles/tutorials on an example of a simple app like the one above...?
In you case JMS is used in a synchonous way, so it depends on your JMS provider if you can do this. If the JMS provider is able of doing synchronous communication you put the answer after the file processsing into a reply queue.
In the synchronous JMS way, the java service will wait for a response from the JMS provider so can can present the response from the service back to the controller and then to the user...
So..:
User uploads a file
controller gets the file and just sends a it to the JMS queue and waits for response!
Java service running separately fetches the file from the queue and processes it (just reads the first word)
Java service puts the response back in a reply queue
Controller wil get the response reads the response and present it to the user
Your page could be a nice ajax page that presents the user with a processing spinner.
I want in my j2me application that a server check a table in database and send response to the application after some interval. I am using Tomcat as server.
Any suggestion how and what way I will implement it?
Do you want tomcat to take initiative to send a response after specific time interval?
Are you using Ajax in application. What you can do is in your application, at client side run a thread which can make a request to tomcat after a specific time interval and get a response.