BrightSide Workbench Full Report + Source Code
org.turro.mail.impl.MailQueueConsumer Class Reference
Inheritance diagram for org.turro.mail.impl.MailQueueConsumer:
Collaboration diagram for org.turro.mail.impl.MailQueueConsumer:

Public Member Functions

void addToQueue (Collection< MailMessage > pool)
 
void addToQueue (Collection< MailMessage > pool, Consumer onFinish)
 
void addToQueue (MailMessage mail)
 
void addToQueue (MailMessage mail, Consumer onFinish)
 
int size ()
 
void run ()
 

Static Public Member Functions

static MailQueueConsumer getInstance ()
 
static void destroy ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 35 of file MailQueueConsumer.java.

Member Function Documentation

◆ addToQueue() [1/4]

void org.turro.mail.impl.MailQueueConsumer.addToQueue ( Collection< MailMessage pool)

Definition at line 37 of file MailQueueConsumer.java.

37  {
38  addToQueue(pool, null);
39  }
void addToQueue(Collection< MailMessage > pool)
Here is the caller graph for this function:

◆ addToQueue() [2/4]

void org.turro.mail.impl.MailQueueConsumer.addToQueue ( Collection< MailMessage pool,
Consumer  onFinish 
)

Definition at line 41 of file MailQueueConsumer.java.

41  {
42  if(pool == null) return;
43  int index = 0, size = pool.size();
44  for(MailMessage mail : pool) {
45  if(++index == size) {
46  addToQueue(mail, onFinish);
47  } else {
48  addToQueue(mail);
49  }
50  }
51  }
Here is the call graph for this function:

◆ addToQueue() [3/4]

void org.turro.mail.impl.MailQueueConsumer.addToQueue ( MailMessage  mail)

Definition at line 53 of file MailQueueConsumer.java.

53  {
54  addToQueue(mail, null);
55  }
Here is the call graph for this function:

◆ addToQueue() [4/4]

void org.turro.mail.impl.MailQueueConsumer.addToQueue ( MailMessage  mail,
Consumer  onFinish 
)

Definition at line 57 of file MailQueueConsumer.java.

57  {
58  try {
59  if(!QUEUE.offer(new MailQueueItem(mail, onFinish), 60L, TimeUnit.MINUTES)) {
60  Logger.getLogger(MailQueueConsumer.class.getName()).log(Level.SEVERE, ElephantContext.logMsg("Too long attempt"));
61  }
62  } catch (InterruptedException ex) {
63  Logger.getLogger(MailQueueConsumer.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
64  }
65  }
Here is the call graph for this function:

◆ destroy()

static void org.turro.mail.impl.MailQueueConsumer.destroy ( )
static

Definition at line 114 of file MailQueueConsumer.java.

114  {
115  if(INSTANCE != null) {
116  running.set(false);
117  getInstance().addTrigger();
118  INSTANCE = null;
119  }
120  }
static MailQueueConsumer getInstance()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInstance()

static MailQueueConsumer org.turro.mail.impl.MailQueueConsumer.getInstance ( )
static

Definition at line 105 of file MailQueueConsumer.java.

105  {
106  if(INSTANCE == null) {
107  INSTANCE = new MailQueueConsumer();
108  MAIL_QUEUE = new Thread(INSTANCE, "ElephantMailQueue");
109  MAIL_QUEUE.start();
110  }
111  return INSTANCE;
112  }
Here is the caller graph for this function:

◆ run()

void org.turro.mail.impl.MailQueueConsumer.run ( )

Definition at line 77 of file MailQueueConsumer.java.

77  {
78  try {
79  running.set(true);
80  while (running.get()) {
81  MailQueueItem item = QUEUE.take();
82  if(!running.get()) break;
83  try {
84  item.send();
85  } catch(Exception ex) {
86  Logger.getLogger(MailQueueConsumer.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
87  }
88  Thread.sleep(200);
89  }
90  } catch (InterruptedException e) {
91  Thread.currentThread().interrupt();
92  }
93  }
Here is the call graph for this function:

◆ size()

int org.turro.mail.impl.MailQueueConsumer.size ( )

Definition at line 67 of file MailQueueConsumer.java.

67  {
68  return QUEUE.size();
69  }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: