{"id":9063,"date":"2013-05-21T11:42:01","date_gmt":"2013-05-21T17:42:01","guid":{"rendered":"http:\/\/www.mrc-productivity.com\/techblog\/?p=9063"},"modified":"2023-05-12T13:23:34","modified_gmt":"2023-05-12T19:23:34","slug":"messaging-scheduled-tasks","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/techblog\/?ht_kb=messaging-scheduled-tasks","title":{"rendered":"Messaging &#038; Scheduled Tasks"},"content":{"rendered":"<p><strong>Messaging &amp; Scheduled Tasks<\/strong><\/p>\n<p>Our customer (Betty), runs a small fitness center where members pay a monthly fee to utilize the facilities. Every time a member submits a payment, Betty enters the date in a maintainer to keep track of when the last payment was received from that member. Every Sunday, Betty checks to see which members are behind on their payments, and sends them an email reminder of the late payment. Betty would like to automate the process, and have m-Power send the message for her to make the process more efficient and less time consuming.<\/p>\n<p>Utilizing the m-Power Messaging &amp; Scheduled Tasks utility, we can create this solution for Betty in a few easy steps.<\/p>\n<p>This is the maintainer, it contains the names and email addresses of the members:<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MaintainerView.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9086\" alt=\"MaintainerView\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MaintainerView.jpg\" width=\"657\" height=\"425\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MaintainerView.jpg 912w, https:\/\/www.mrc-productivity.com\/techblog\/images\/MaintainerView-300x194.jpg 300w\" sizes=\"auto, (max-width: 657px) 100vw, 657px\" \/><\/a><\/p>\n<p>The first step is to setup m-Power to send emails. Click Admin, click Utilities, and then click Messaging &amp; Scheduled Tasks. From the Main menu drop down, click Task &amp; Message configuration. Here we will fill in the information for our email services. This is what the page looks like after filling in the values:<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/FakeMessageSetup.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9082\" alt=\"FakeMessageSetup\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/FakeMessageSetup.jpg\" width=\"722\" height=\"339\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/FakeMessageSetup.jpg 1003w, https:\/\/www.mrc-productivity.com\/techblog\/images\/FakeMessageSetup-300x140.jpg 300w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/a><\/p>\n<p>These values will differ depending on the email provider being used.\u00a0 If m-Power is already configured in your system to send emails, you will find these values in Admin &#8211;&gt; Edit Data Dictionary Files &#8211;&gt; Servlet Properties.<\/p>\n<p>Next, we will create the retrieval that will serve as our email body, and we will create the distribution list that holds the email addresses where we want to send our messages.<\/p>\n<p><br clear=\"ALL\" \/> Create a Single Record Inquiry over the same table where the maintainer writes the dates of payment. In m-Painter, we can delete or hide the main table and type in the text for our email body. Then from the retrieval properties, set the hide_header_footer to \u2018Yes\u2019 since we do not want the header and footer in the email. Notice in the retrieval we are using the name of the customer and the date of the last payment, from the variable, to create a more personalized message.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/EmailRetrieval.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9081\" alt=\"EmailRetrieval\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/EmailRetrieval.jpg\" width=\"668\" height=\"375\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/EmailRetrieval.jpg 954w, https:\/\/www.mrc-productivity.com\/techblog\/images\/EmailRetrieval-300x168.jpg 300w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/a><\/p>\n<p>Next we will create the distribution list. From the retrieval tab, click Create New, and then select the Address Distribution List as the template.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/DistributionListTemplate.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9080\" alt=\"DistributionListTemplate\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/DistributionListTemplate.jpg\" width=\"676\" height=\"384\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/DistributionListTemplate.jpg 965w, https:\/\/www.mrc-productivity.com\/techblog\/images\/DistributionListTemplate-300x170.jpg 300w\" sizes=\"auto, (max-width: 676px) 100vw, 676px\" \/><\/a><\/p>\n<p>Select the same table from the maintainer. Sequence the application by the email address. As you can see the Address Distribution List does not look like an application, it just holds the list of email addresses where to send the message. I create a record selection combined with a calculation to send the message to only those members whose payment is older than a month.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/DistributionListMenu.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9079\" alt=\"DistributionListMenu\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/DistributionListMenu.jpg\" width=\"986\" height=\"477\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/DistributionListMenu.jpg 1409w, https:\/\/www.mrc-productivity.com\/techblog\/images\/DistributionListMenu-300x145.jpg 300w, https:\/\/www.mrc-productivity.com\/techblog\/images\/DistributionListMenu-1024x495.jpg 1024w\" sizes=\"auto, (max-width: 986px) 100vw, 986px\" \/><\/a><\/p>\n<p>The next step is to add a new Group to the messaging utility. Click Admin, then click Utilities, and then click Messaging &amp; Scheduled Tasks. \u00a0Click the green plus sign to add a new group, give it a name and a description. Click Accept.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/CreateGroup.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9078\" alt=\"CreateGroup\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/CreateGroup.jpg\" width=\"456\" height=\"255\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/CreateGroup.jpg 570w, https:\/\/www.mrc-productivity.com\/techblog\/images\/CreateGroup-300x167.jpg 300w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/a><\/p>\n<p>Next click Add Task, when we click Add Task we are offered two options: New Message or New Summary. In our case we need to send a message, so we will select New Message.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/ClickAddTask.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9077\" alt=\"ClickAddTask\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/ClickAddTask.jpg\" width=\"548\" height=\"262\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/ClickAddTask.jpg 609w, https:\/\/www.mrc-productivity.com\/techblog\/images\/ClickAddTask-300x143.jpg 300w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/a><\/p>\n<p>In the next window we will find four tabs. Let\u2019s go over each one of them.<\/p>\n<p>In the Message Type tab type a message description. Under Message Source, we have two options: Static Message or m-Power Application. Static message will allow us to type the text for our message, without the need for an application. This is not a good idea in our case, because we want to send the message only to those customer that have not paid, and we want the message to be customized with their names and last date of payment received. So we will select m-Power Application. Then we are prompted with the location of the application that will be our message. I our case the retrieval 20.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageType.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9090\" alt=\"MessageType\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageType.jpg\" width=\"619\" height=\"411\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageType.jpg 774w, https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageType-300x199.jpg 300w\" sizes=\"auto, (max-width: 619px) 100vw, 619px\" \/><\/a><\/p>\n<p>Clicking the Message Format tab will allows us to choose what type of message we want to send, we will select Email. We will embed the message in the email body, and we will select HTML as the output format.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageFormat.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9087\" alt=\"MessageFormat\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageFormat.jpg\" width=\"578\" height=\"262\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageFormat.jpg 722w, https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageFormat-300x135.jpg 300w\" sizes=\"auto, (max-width: 578px) 100vw, 578px\" \/><\/a><\/p>\n<p>The next tab is the Recipients tab. Here we will select the Send 1 message per recipient choice, since we will personalize the message with the customer name and the last date of payment received. Select the dictionary and the application that is our distribution list. For our example we can leave the rest as default.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/Recipients.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9092\" alt=\"Recipients\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/Recipients.jpg\" width=\"635\" height=\"482\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/Recipients.jpg 794w, https:\/\/www.mrc-productivity.com\/techblog\/images\/Recipients-300x227.jpg 300w\" sizes=\"auto, (max-width: 635px) 100vw, 635px\" \/><\/a><\/p>\n<p>The last tab is the Message Text tab. Here we set the email subject for the email. Optionally, we can specify a different email as the sender email address.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageText.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9089\" alt=\"MessageText\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageText.jpg\" width=\"659\" height=\"335\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageText.jpg 732w, https:\/\/www.mrc-productivity.com\/techblog\/images\/MessageText-300x152.jpg 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/a><\/p>\n<p>We are now finished setting up the email message. The next step is to send the message to our customers. There are three ways that we can send a message form m-Power. The simplest way is by triggering the message from the URL. This method is best for testing purposes, or if you need to send a message one time only. To run the message simple point you URL to: \/mrcjava\/servlet\/DICTIONARY.Task?group=NAME_OF_GROUP<br \/>\nThis will trigger the message to be sent only that one time.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/URLcall.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9095\" alt=\"URLcall\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/URLcall.jpg\" width=\"439\" height=\"46\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/URLcall.jpg 439w, https:\/\/www.mrc-productivity.com\/techblog\/images\/URLcall-300x31.jpg 300w\" sizes=\"auto, (max-width: 439px) 100vw, 439px\" \/><\/a><\/p>\n<p>The second way of sending the message is by sending it automatically after a maintainer has completed an action. This could be used to send an email confirmation after a change or update was done to the table via the maintainer. To trigger the message from the maintainer, open the maintainer properties, and click the After Actions tab. Here you will find four properties where you can set the group to be triggered depending on the action performed by the maintainer. For or example I chose the all_message, which will trigger the message after any action (Add, Update, Delete)<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MaintainerCall.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9085\" alt=\"MaintainerCall\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MaintainerCall.jpg\" width=\"786\" height=\"459\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MaintainerCall.jpg 982w, https:\/\/www.mrc-productivity.com\/techblog\/images\/MaintainerCall-300x175.jpg 300w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/a><\/p>\n<p>The third way of triggering the message is by setting a scheduled task. Using this method we can setup when and how often the message will be sent. To schedule a task: navigate to the Messaging &amp; Scheduled Tasks, hover over the Main Menu and click Scheduled Tasks.<br \/>\nClick the green plus sign to schedule a new task. A drop down will allow you select the Task Group you will like to schedule. Then click the button on the Frequency row. Here we will specify \u2018week\u2019 because we want to send one message a week. Then we select a day and time, Sunday at 06:00 will work for us. NOTE: The time is specified in military time, 06:00 will mean 6am, if you wanted to send the message at 6pm it would be: 18:00.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/ScheduledTasks.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9093\" alt=\"ScheduledTasks\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/ScheduledTasks.jpg\" width=\"544\" height=\"221\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/ScheduledTasks.jpg 544w, https:\/\/www.mrc-productivity.com\/techblog\/images\/ScheduledTasks-300x121.jpg 300w\" sizes=\"auto, (max-width: 544px) 100vw, 544px\" \/><\/a><\/p>\n<p>Click Accept. We are back at the Scheduled Tasks page. The task we just scheduled will display here.\u00a0 NOTE: the schedule task will not run until Tomcat has restarted to allow the new setting to be loaded. From this screen you can restart Tomcat by clicking the Reload Tomcat Now link, if you have the permissions to do so. Otherwise you will need to ask your server administrator to restart Tomcat.<\/p>\n<p style=\"text-align: left;\"><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/ScheduledTasksView.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9094\" alt=\"ScheduledTasksView\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/ScheduledTasksView.jpg\" width=\"697\" height=\"288\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/ScheduledTasksView.jpg 774w, https:\/\/www.mrc-productivity.com\/techblog\/images\/ScheduledTasksView-300x124.jpg 300w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/a><strong><\/strong><\/p>\n<p style=\"text-align: left;\" id=\"promote\"><strong>Promoting the Task to Production<\/strong><\/p>\n<p>Now that we are finished, we can test the message and confirm that everything is working as expected. It is time to promote the task to production. To promote the task to production we will need to move all the applications involved: the email body (retrieval), the Distribution List (retrieval), and the maintainer if one was used. These applications will be promoted in the regular way. Besides the application files, there are four files that also need to be promoted. These are the files, and their corresponding locations:<\/p>\n<ul>\n<li>mrc_distribution_jobs_mysql1.txt\u00a0\u00a0 \u00a0 \u00a0 \u00a0 \\m-power\\mrcjava\\job_streams<\/li>\n<li>message-queue.properties\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \\m-power\\mrcjava\\job_streams<\/li>\n<li>messaging.properties\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \\m-power\\mrcjava\\job_streams<\/li>\n<li>mrc_distributions.txt\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \\m-power\\mrcjava\\WEB-INF\\classes\\DICTIONARY<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/JobStream.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9084\" alt=\"JobStream\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/JobStream.jpg\" width=\"545\" height=\"274\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/JobStream.jpg 605w, https:\/\/www.mrc-productivity.com\/techblog\/images\/JobStream-300x150.jpg 300w\" sizes=\"auto, (max-width: 545px) 100vw, 545px\" \/><\/a><\/p>\n<p>The mrc_distribution_jobs_mysql1.txt references your database connection, in my case I am connecting to a MySQL database, as you can see by the reference: _mysql1, if I was using an AS400 connection, it will be: _AS400_remote1<br \/>\nthese files will need to be promoted every time a new message task has been created or modified.<\/p>\n<p>The fourth file that needs to be promoted, the messaging.properties, is located: \\m-power\\mrcjava\\job_streams<br \/>\nthis file needs to be promoted only once, unless the properties of the email server changes, then it will need to be promoted again.<\/p>\n<p>After the messaging.properties file was promoted, it will need to be modified to point to the correct port for the production instance. Open the file in a text editor, and as you can see in the picture, in line four I changed the port number from 8011 to 80, which is the port my production instance works on, make sure you type the port number your production instance works on.<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessagingProperties.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-9091\" alt=\"MessagingProperties\" src=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessagingProperties.jpg\" width=\"458\" height=\"249\" srcset=\"https:\/\/www.mrc-productivity.com\/techblog\/images\/MessagingProperties.jpg 509w, https:\/\/www.mrc-productivity.com\/techblog\/images\/MessagingProperties-300x163.jpg 300w\" sizes=\"auto, (max-width: 458px) 100vw, 458px\" \/><\/a><\/p>\n<p>Restart the production instance of Tomcat.\u00a0 Now m-Power will send the message to the customers every Sunday at 6am.<\/p>\n<p><strong>Stopping Scheduled Tasks from Running in Development<\/strong><\/p>\n<p><strong><\/strong>After setting up your Scheduled Task and promoting it to production, it will run in both production and development.\u00a0 Should you wish to stop the task from running in development, you can do so by editing the messaging.properties file located in m-power\/mrcjava\/job_streams.\u00a0 Add the following text to the file:<\/p>\n<p>enable_scheduler=false<\/p>\n<p>Save this file, and restart Tomcat.\u00a0 If you are receiving nightly emails from development, those should stop tonight.\u00a0 Now, you will no longer be able to run a scheduled task through development.\u00a0 However, you will be able to create and set the scheduled task, so that once promoted, it runs as scheduled.\u00a0 Additionally, you can still test the task with the ?task= parameter.\u00a0 Note that if you accidentally promote the edited messaging.properties file to production, scheduled tasks will no longer run in production either.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Messaging &amp; Scheduled Tasks Our customer (Betty), runs a small fitness center where members pay a monthly fee to utilize the facilities. Every time a member submits a payment, Betty enters the date in a maintainer to keep track of when the last payment was received from that member. Every&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"open","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[],"ht-kb-tag":[],"class_list":["post-9063","ht_kb","type-ht_kb","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/ht-kb\/9063","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9063"}],"version-history":[{"count":39,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/ht-kb\/9063\/revisions"}],"predecessor-version":[{"id":9456,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/ht-kb\/9063\/revisions\/9456"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9063"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fht-kb-category&post=9063"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fht-kb-tag&post=9063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}