public class JMSMailQueue extends Object implements ManageableMailQueue, JMSSupport, MailPrioritySupport
ManageableMailQueue.MailQueueItemView, ManageableMailQueue.MailQueueIterator, ManageableMailQueue.TypeMailQueue.MailQueueException, MailQueue.MailQueueItem| Modifier and Type | Field and Description |
|---|---|
protected javax.jms.ConnectionFactory |
connectionFactory |
static String |
FORCE_DELIVERY |
protected org.slf4j.Logger |
logger |
protected String |
queuename |
JAMES_MAIL_ATTRIBUTE_NAMES, JAMES_MAIL_ERROR_MESSAGE, JAMES_MAIL_LAST_UPDATED, JAMES_MAIL_MESSAGE_SIZE, JAMES_MAIL_NAME, JAMES_MAIL_RECIPIENTS, JAMES_MAIL_REMOTEADDR, JAMES_MAIL_REMOTEHOST, JAMES_MAIL_SENDER, JAMES_MAIL_SEPARATOR, JAMES_MAIL_STATE, JAMES_NEXT_DELIVERYHIGH_PRIORITY, LOW_PRIORITY, MAIL_PRIORITY, NORMAL_PRIORITY| Constructor and Description |
|---|
JMSMailQueue(javax.jms.ConnectionFactory connectionFactory,
String queuename,
org.slf4j.Logger logger) |
| Modifier and Type | Method and Description |
|---|---|
ManageableMailQueue.MailQueueIterator |
browse()
Allow to browse the queues content.
|
long |
clear()
Remove all mails from the queue
|
protected Object |
convertAttributeValue(Object value)
Convert the attribute value if necessary.
|
protected javax.jms.Message |
copy(javax.jms.Session session,
javax.jms.Message m)
Create a copy of the given
Message. |
protected long |
count(List<javax.jms.Message> msgs) |
protected org.apache.mailet.Mail |
createMail(javax.jms.Message message)
Create the complete Mail from the JMS Message.
|
protected MailQueue.MailQueueItem |
createMailQueueItem(javax.jms.Connection connection,
javax.jms.Session session,
javax.jms.MessageConsumer consumer,
javax.jms.Message message)
Create a
MailQueue.MailQueueItem for the given parameters |
MailQueue.MailQueueItem |
deQueue()
Dequeues a mail when it is ready to process.
|
void |
enQueue(org.apache.mailet.Mail mail)
Enqueue the Mail to the queue
|
void |
enQueue(org.apache.mailet.Mail mail,
long delay,
TimeUnit unit)
Enqueue the Mail to the queue.
|
long |
flush()
Flush the queue, which means it will make all message ready for dequeue
|
protected Map<String,Object> |
getJMSProperties(org.apache.mailet.Mail mail,
long delayInMillis)
Get JMS Message properties with values
|
protected String |
getMessageSelector() |
long |
getSize()
Return the size of the queue
|
protected void |
populateMail(javax.jms.Message message,
MailImpl mail)
Populate Mail with values from Message.
|
protected void |
populateMailMimeMessage(javax.jms.Message message,
org.apache.mailet.Mail mail)
Populat the given
Mail instance with a MimeMessage. |
protected void |
produceMail(javax.jms.Session session,
Map<String,Object> props,
int msgPrio,
org.apache.mailet.Mail mail)
Produce the mail to the JMS Queue
|
long |
remove(ManageableMailQueue.Type type,
String value)
Remove all mails from the queue that match
|
List<javax.jms.Message> |
removeWithSelector(String selector)
Remove messages with the given selector
|
String |
toString() |
protected final String queuename
protected final javax.jms.ConnectionFactory connectionFactory
protected final org.slf4j.Logger logger
public static final String FORCE_DELIVERY
public JMSMailQueue(javax.jms.ConnectionFactory connectionFactory,
String queuename,
org.slf4j.Logger logger)
public MailQueue.MailQueueItem deQueue() throws MailQueue.MailQueueException
Dequeues a mail when it is ready to process. As JMS does not support delay scheduling out-of-the box,
we use a messageselector to check if a mail is ready. For this a
MessageConsumer.receive(long) is used with a timeout of 10
seconds.
Many JMS implementations support better solutions for this, so this should get overridden by these implementations
deQueue in interface MailQueueMailQueue.MailQueueExceptionpublic void enQueue(org.apache.mailet.Mail mail,
long delay,
TimeUnit unit)
throws MailQueue.MailQueueException
MailQueueenQueue in interface MailQueueMailQueue.MailQueueExceptionMailQueue.enQueue(org.apache.mailet.Mail,
long, java.util.concurrent.TimeUnit)public void enQueue(org.apache.mailet.Mail mail)
throws MailQueue.MailQueueException
MailQueueenQueue in interface MailQueueMailQueue.MailQueueExceptionMailQueue.enQueue(org.apache.mailet.Mail)protected void produceMail(javax.jms.Session session,
Map<String,Object> props,
int msgPrio,
org.apache.mailet.Mail mail)
throws javax.jms.JMSException,
javax.mail.MessagingException,
IOException
javax.jms.JMSExceptionjavax.mail.MessagingExceptionIOExceptionprotected Map<String,Object> getJMSProperties(org.apache.mailet.Mail mail, long delayInMillis) throws javax.jms.JMSException, javax.mail.MessagingException
mail - delayInMillis - javax.jms.JMSExceptionjavax.mail.MessagingExceptionprotected final org.apache.mailet.Mail createMail(javax.jms.Message message)
throws javax.mail.MessagingException,
javax.jms.JMSException
Mail is completely populatedmessage - javax.mail.MessagingExceptionjavax.jms.JMSExceptionprotected void populateMailMimeMessage(javax.jms.Message message,
org.apache.mailet.Mail mail)
throws javax.mail.MessagingException,
javax.jms.JMSException
Mail instance with a MimeMessage. The
MimeMessage is read from the JMS Message. This implementation use
a BytesMessagemessage - mail - javax.mail.MessagingExceptionjavax.jms.JMSExceptionprotected void populateMail(javax.jms.Message message,
MailImpl mail)
throws javax.jms.JMSException
MimeMessagemessage - mail - javax.jms.JMSExceptionprotected Object convertAttributeValue(Object value)
value - protected MailQueue.MailQueueItem createMailQueueItem(javax.jms.Connection connection, javax.jms.Session session, javax.jms.MessageConsumer consumer, javax.jms.Message message) throws javax.jms.JMSException, javax.mail.MessagingException
MailQueue.MailQueueItem for the given parametersconnection - session - consumer - message - javax.jms.JMSExceptionjavax.mail.MessagingExceptionprotected String getMessageSelector()
public long getSize()
throws MailQueue.MailQueueException
ManageableMailQueuegetSize in interface ManageableMailQueueMailQueue.MailQueueExceptionManageableMailQueue.getSize()public long flush()
throws MailQueue.MailQueueException
ManageableMailQueueflush in interface ManageableMailQueueMailQueue.MailQueueExceptionManageableMailQueue.flush()public long clear()
throws MailQueue.MailQueueException
ManageableMailQueueclear in interface ManageableMailQueueMailQueue.MailQueueExceptionMailQueueManagementMBean.clear()protected long count(List<javax.jms.Message> msgs)
public List<javax.jms.Message> removeWithSelector(String selector) throws MailQueue.MailQueueException
selector - MailQueue.MailQueueExceptionprotected javax.jms.Message copy(javax.jms.Session session,
javax.jms.Message m)
throws javax.jms.JMSException
Message. This includes the properties
and the payloadsession - m - javax.jms.JMSExceptionpublic long remove(ManageableMailQueue.Type type, String value) throws MailQueue.MailQueueException
ManageableMailQueueremove in interface ManageableMailQueueMailQueue.MailQueueExceptionManageableMailQueue.remove(org.apache.james.queue.api.ManageableMailQueue.Type,
java.lang.String)public ManageableMailQueue.MailQueueIterator browse() throws MailQueue.MailQueueException
ManageableMailQueuebrowse in interface ManageableMailQueueMailQueue.MailQueueExceptionManageableMailQueue.browse()Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.