dailyc - A Batch Multimedia Message Service

September 14, 2015

dailyc is a service for sending multimedia messages at regular intervals. You provide dailyc with a folder full of jpgs and a list of messages; it will determine which image and message hasn’t been sent in a while (if ever) and fire it off to a list of subscribers.

dailyc uses Mogreet to send messages. Mogreet offers an easy to use REST API; however, their Java SDK, mercury is a little rough around the edges (i.e. it is not complete). dailyc implements its own Java wrapper. This wrapper exists as a separate module in the Gradle project and is abstracted from the multimedia messaging service (the dailyc-core module).

The service works really well for sending baby pictures to adoring (petulant?) relatives. It is well suited to this task because, well, that’s why I implemented it.

Getting started

First step is to obtain the dailyc source code, which is available on Github:

git clone git@github.com:JLospinoso/dailyc

Since dailyc uses the gradle wrapper, you should be able to execute the gradlew script (both on Windows and other operating systems). This script will automagically download Gradle for you, then run whatever Gradle task you give it. Note: you must have the Java SDK installed.

You can verify that dailyc is compiling and that the unit tests are passing by issuing:

gradlew build

Mogreet Account

You will need to sign up for a (free) Mogreet account to be able to send messages. You get a $25 credit (which goes a long way at ~$0.01 per text).

Once you’ve obtained an account, open up the Mogreet Dashboard and take note of the API Credentials section. You will need to update the following fields in both dailyc-core\src\main\resources\application.properties and dailyc-core\src\test\resources\application.properties with the corresponding information in Mogreet Dashboard:

clientId=1111
token=deadbeefdeadbeefdeadbeef
campaignId=999999

Your campaignId is the MMS campaign id in the Dashboard.

Configuration

There are a few configuration files you’ll need to modify to get dailyc working correctly. First, let’s configure how dailyc schedules tasks. There are three tasks that execute at regular interval when dailyc is running:

  • the batch service, which checks for new messages, subscribers, and images to load into the database,
  • the send service, which sends an image and a message to all subscribers, and
  • the heartbeat service, which logs a message to let you know that dailyc is still running.

In dailyc-core\src\main\resources\application.properties, we have three fields that drive all of the scheduling. These are cron strings. So, for example, if you’d like heartbeats every hour, batch at 0500, and send at 0600, you would have:

sendCron=0 0 6 * * *
batchCron=0 0 5 * * *
heartbeatCron=0 0 * * * *

Next, we must tell dailyc where our images are stored, whom to subscribe to the service, and what messages to send. All of this information is given in a JSON file pointed to by application.properties. Suppose we specify

configPath=c:/dailyc/config.json

Use the format given in the sample configuration to create c:/dailyc/config.json:

{
  "imageDirectory": "c:/dailyc/img",
  "subscribers": [
	"5551234567",
	"5551234568",
	"..."
  ],
  "messages": [
	"Hello from your favorite granddaughter!",
	"Good morning!",
	"..."
  ]
}

All you need to do now is paste a body of .jpgs into the imageDirectory (in this case c:/dailyc/img), and dailyc is configured to run.

Advanced configuration

Since dailyc uses Spring Boot and GORM, it is very simple to configure a persistent store with dailyc. This will allow all of your state to persist across reboots of the service (which is important if you don’t want subscribers to get the same images over and over again.)

This is configured–you guessed it–in the application.properties. A Mysql database, for example, could be configured as follows:

database.driver=com.mysql.jdbc.Driver
database.url=jdbc:mysql://mysql.domain.com/dailyc
database.username=dailyc
database.password=abc123

Assuming you’ve created the database and user correctly, it really is that simple.

Running dailyc

As dailyc is a Spring Boot application, execution is as simple as

gradlew bootRun

Please provide feedback/bug reports for v0.1.0 on Github.