Regarding schedule time for sending email - java

Need to schedule time for sending email via javamail on Google app engine, I already tried OOP MailScheduler for this but at the end I am getting error due to it does not support for Google App Engine, it only support to Tomcat, is there any other efficient way to schedule the time for sending emails.

When you create a task and add to the task queue, you can specify when this task should be executed.

Related

In Azure DevOps, how to gracefully restart when deploying an app to Functions

In Azure DevOps Pipeliens, when deploying an app to Functions, the app may restart during the process of the app.
Is there a way to monitor if the Functions app is running in the pipeline, make sure it's done, and then deploy the app?
Conditions
Functions runtime: Java
Trigger: Service Bus Trigger
I tried to check the lock status of Service Bus messages or the processing status of the Functions app with the Azure CLI, but it seems that there is no interface to check the processing status.
https://learn.microsoft.com/en-us/cli/azure/functionapp?view=azure-cli-latest
https://learn.microsoft.com/en-us/cli/azure/servicebus/queue?view=azure-cli-latest
You should never rely on that better build your functions to execute fast.
When Azure function sends signal to stop in c# we have CancellationToken this way we can have extra code to implement shutdown, otherwise as soon as AF get signal to stop it will not accept new events from service bus but will continue to execute current functions, and if they wont stop for some time they can be terminated (cant find exact time but will update answer )
I would also suggest you to utilise deployment slots this way you can minimise your downtime.

How to be made aware of incoming emails on GMail without frequent polling?

If I am developing an Android application, what is the most feasible way to get near real-time notifications about an incoming email? Is there a push-like mechanism, or can I hold my IMAP connection for a long time, or do I use IDLE command?
Consider that user is authorized to use GMail services via OAuth and I don't want to poll IMAP server madly.
Update:
I'm not using the phone's configured-in Google account. There is another account set up using OAuth.
I'm using Apache Commons Net to connect to IMAP/SMTP in my app. It's a bare-bone library for IMAP, but I can perhaps modify it to add IMAP commands/extensions.
You can register a ContentObserver with GMail, anytime something changes in GMail, the observer will be called.
contentResolver.registerContentObserver(Uri.parse("content://gmail-ls"), true, myContentObserver );
Override onChange in your ContentObserver to do stuff when something in GMail changes.
Since IMAP does natively provide any sort of push notifications and the Google extensions don't either, you have to implement it yourself.
One way is to use IDLE requests, which is still a cheap way to do polling. Of course, you can't expect your app to be running all the time, so you need to use a background service. An 'always-on' service is however an anti-pattern on Android and will drain the battery quickly and likely get you many 1-stars. Additionally the system may decide to kill it at any time. The other alternative is to use AlarmManager to start the service periodically, but starting it every couple of seconds or so is just as bad. So you are basically back to square one: polling.
The other way is to get push notifications using GCM or a similar service. This does require you to have a server, and the server needs to have the authentication info for the user (which might be a problem), but there are no real constraints concerning keeping open connections and sending IDLEs each second, etc. On the Android side, if you want to implement push yourself, you need to keep an open socket to get notifications. This is not very easy to do if you are not a system app (see above), so that leaves GCM. The connection it uses is manged by the system (Google Services framework), it can do things a regular app cannot, and you basically get it for free, since it's already there. It receives small pieces of data when there is something to do, called 'tickles'. Those in turn trigger broadcasts, Google Play updates, etc.
So, take your pick. Or just give up, register the account and use GMail and its labels Android API.
I'd check out Google Cloud Messaging (GCM):
http://developer.android.com/training/cloudsync/gcm.html
My understanding is that this works without requiring the user's Google account, and lets you handle authentication.
See a tutorial here:
http://www.techrepublic.com/blog/app-builder/implementing-googles-cloud-to-device-messaging/428
You would need additional server-side code running to do this though.

timer in message application

HELLO Developers,
I have taken over a project in android environment which i am completely new to, which imbibes a timer facility so that user can time his sms to be sent. Which messaging API will prove to be a help in this. Hoping to get good response from your side.
You don't need a messaging API. SMS sending is included in the Android SDK. To delay the sending I would recommend to use a Timer and schedule it with an delay:
http://developer.android.com/reference/java/util/Timer.html#schedule(java.util.TimerTask, long)

How to run asynchronous task using GWT with App Engine?

Hi
What would be a best solution to initiate the task on App Engine?
What I am trying to achieve is to send email to user every 6, 16, 30 days after the registration. This service should run independently from the app (so not user initiated).
What would be the best way to achieve this with App Engine and GWT (Java)?
Thanks.
You'll want to use the Scheduled Task API (Python or Java) or Task Queue API (Python or Java) depending on your use case. Perhaps send the initial e-mail using the task queue and then the follow-up e-mails could be generated via scheduled tasks.

Tool to send email from a DB

We are developing a webapp that needs to send out emails written in Java/Groovy. Currently, we are persisting each email to a database before we call the Java Mail APIs to send the mail to our SMTP server.
I want to send out email asynchronously. I want to persist the email and then have another process pick up the email and send it (and send it only once). Ideally, this process is running outside of my webapp.
Are there any tools that do that?
Update: This solution needs to prevent duplicate emails and it needs to handle spikes in email. I was hoping someone already wrote an offline email processor. (I'd rather not implement this myself.)
The suggestions to use a cron job to read the database are quite workable.
Another good approach here is to use a Java Message Service (JMS) message queue. These are persistent (backed up by a database) and reliable. You can have one or more producer programs enqueue messages with the relevant data in them, and then one or more consumers process the messages and dequeue them. All of this is set up for very high reliability, and you gain the flexibility of asynchronously decoupling the operations, which means during email spikes the message queue can grow larger until the consumers catch up with the spike. Another benefit is that the email goes out as soon as a consumer gets to it instead of on a timer. Plus, if you require high availability, you can have multiple consumers in case one goes down.
Check out Apache's ActiveMQ for a good open source implementation of JMS.
If you're using Linux/Unix you could create a cron job to run every few minutes which calls a program to grab the email from the database and send it out. You could also have a field in the database to indicate whether the message has been sent. The downside of this approach is that there may be a delay of a few minutes from when your webapp persists the email and when the cron job is run.
Setup a cron job and use scripts to query the db and send out emails via sendmail.
On the off chance it's an Oracle DB, you can use the UTL_MAIL package to write PL/SQL to send the mail through your SMTP server. Then create a scheduled job to execute on your desired schedule.
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_mail.htm
Since you are already using groovy, this might be an interesting tool to solve your problem
http://gaq.sourceforge.net/
You could use Quartz, a scheduling library (similar to cron), to schedule a recurring task that reads the DB and sends the emails. If you're using Grails, there's a Quartz plugin that makes working with Quartz a bit more Groovy.

Categories