Return to Video

Add a Task Solution - Developing Scalable Apps with Java

  • 0:00 - 0:02
    So let's take a look at the code, that
  • 0:02 - 0:05
    adds a task to the default task queue. So it's
  • 0:05 - 0:08
    createConference in Conference API, and then this is the code
  • 0:08 - 0:11
    that we already looked at to get the profile. Get
  • 0:11 - 0:14
    the conference key, get an ID for the conference
  • 0:14 - 0:17
    key. And here is the code to get the default
  • 0:17 - 0:20
    queue. And you're going to need, of course, when you did
  • 0:20 - 0:26
    this you would've needed to import queue and queue factory.
  • 0:26 - 0:27
    So, to get the default queue we just call
  • 0:27 - 0:32
    queuefactory.getdefaultqueue. I updated my code to use a transaction,
  • 0:32 - 0:36
    so here's the code for starting the transaction, ofy.transact,
  • 0:36 - 0:38
    and then we run it, we run the transaction. Then
  • 0:38 - 0:41
    we get the profile entity from the data store,
  • 0:41 - 0:46
    we create a new conference subject. We save the conference
  • 0:46 - 0:48
    in the profile, entities in the data store, this
  • 0:48 - 0:51
    is all code from before. This is a new code
  • 0:51 - 0:53
    to add the task. You see here that
  • 0:53 - 0:57
    the first argument is ofy, don't get transaction. This
  • 0:57 - 0:58
    is how you get the current transaction when
  • 0:58 - 1:01
    you're using Objectify. And then we add, we call
  • 1:01 - 1:05
    queue.add. And then the rest of the arguments to add are
  • 1:05 - 1:12
    TaskOptions.Builder. Basically, building up the task options with URL,
  • 1:12 - 1:16
    tasks, send confirmation email. Good job. I fixed the URL there, and then the
  • 1:16 - 1:19
    parameter you want to send the email and
  • 1:19 - 1:21
    we want to send the information about the conference.
  • 1:21 - 1:24
    Then we return the conference from the transaction.
  • 1:24 - 1:26
    And we finally, return the conference from the function.
タイトル:
Add a Task Solution - Developing Scalable Apps with Java
概説:

more » « less
Video Language:
English
Team:
Udacity
プロジェクト:
UD859 - Developing Scalable Apps
Duration:
01:28

English subtitles

改訂 Compare revisions