BrightSide Workbench Full Report + Source Code
org.turro.mail.pool.MailQueueConsumer Class Reference
Inheritance diagram for org.turro.mail.pool.MailQueueConsumer:
Collaboration diagram for org.turro.mail.pool.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 ()
 
 MailQueueConsumer ()
 
void closeElephant ()
 

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 37 of file MailQueueConsumer.java.

Constructor & Destructor Documentation

◆ MailQueueConsumer()

org.turro.mail.pool.MailQueueConsumer.MailQueueConsumer ( )

Used by turro-commons reflection

Deprecated:
Use getInstance method instead.

Definition at line 129 of file MailQueueConsumer.java.

129  {
130  }
Here is the caller graph for this function:

Member Function Documentation

◆ addToQueue() [1/4]

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

Definition at line 39 of file MailQueueConsumer.java.

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

◆ addToQueue() [2/4]

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

Definition at line 43 of file MailQueueConsumer.java.

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

◆ addToQueue() [3/4]

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

Definition at line 55 of file MailQueueConsumer.java.

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

◆ addToQueue() [4/4]

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

Definition at line 59 of file MailQueueConsumer.java.

59  {
60  try {
61  if(!QUEUE.offer(new MailQueueItem(mail, onFinish), 60L, TimeUnit.MINUTES)) {
62  WebLoggers.warning(this).message("Too long attempt").log();
63  }
64  } catch (InterruptedException ex) {
65  WebLoggers.severe(this).exception(ex).log();
66  }
67  }
Here is the call graph for this function:

◆ closeElephant()

void org.turro.mail.pool.MailQueueConsumer.closeElephant ( )

Implements org.turro.action.IElephantCloseable.

Definition at line 135 of file MailQueueConsumer.java.

135  {
136  MailQueueConsumer.destroy();
137  }
Here is the call graph for this function:

◆ destroy()

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

Definition at line 116 of file MailQueueConsumer.java.

116  {
117  if(INSTANCE != null) {
118  running.set(false);
119  getInstance().addTrigger();
120  INSTANCE = null;
121  }
122  }
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.pool.MailQueueConsumer.getInstance ( )
static

Definition at line 107 of file MailQueueConsumer.java.

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

◆ run()

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

Definition at line 79 of file MailQueueConsumer.java.

79  {
80  try {
81  running.set(true);
82  while (running.get()) {
83  MailQueueItem item = QUEUE.take();
84  if(!running.get()) break;
85  try {
86  item.send();
87  } catch(Exception ex) {
88  WebLoggers.severe(this).exception(ex).log();
89  }
90  Thread.sleep(200);
91  }
92  } catch (InterruptedException e) {
93  Thread.currentThread().interrupt();
94  }
95  }
Here is the call graph for this function:

◆ size()

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

Definition at line 69 of file MailQueueConsumer.java.

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

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