public class EmailJobKeeper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
BATCH_SIZE_FOR_ONE_SCHEDULE
BATCH SIZE FOR ONE SCHEDULE
|
static java.lang.String |
CONFIG_SMTP_USE_SSL
Constant for the configuration in
|
static java.lang.String |
CONTENT_GENERIC
Property - generic content
|
static java.lang.String |
CONTINUEJOB
The parameter name for Email sending job - identify this job is a continuing of a existing batch job.
|
static java.lang.String |
COPYRIGHT
Copyright.
|
static java.lang.String |
DELETE_MEMBER_GROUP_AFTER_SEND
The parameter name for Email sending job - delete member group after send
|
static java.lang.String |
EMAIL_PROMOTION_MEMBER_GROUP_ID
The parameter name for Email sending job - email promotion member group ID
|
static java.lang.String |
EMLPROMO_ID
The parameter name for Email sending job - email promotion id
|
static java.lang.String |
PROPERTY_THREADCOUNT
Property - THREADCOUNT
|
static java.lang.String |
STORE_ID
The parameter name for Email sending job - store id
|
Modifier and Type | Method and Description |
---|---|
void |
addRecipient(javax.mail.Message.RecipientType recipientType,
javax.mail.Address[] addresses)
This method is to be used by customizations that want to set the CC or BCC recipients
on the MimeMessage used to send a marketing email.
|
void |
addToQueues(java.util.List[] queues)
This method assign email-sending job [the e-mail target content (user Id, email1, email2)] in one schedule
evenly to the sending-queues which are used in different sending threads.
|
static void |
clean(EmailRecipientSupplier sendingJobType,
long id)
This method help to clean the on-going instance.
|
static void |
cleanThreadLocalResources()
This method is used to release the resource in thread local pool.
|
static void |
cleanUpPromotionIdToAvailableCodesMap()
This method cleans up the in memory objects containing available unique promotion codes.
|
void |
finish()
This method set the sending count on the batch job finish,
and prepare the next batch job if there are more email to be sent.
|
boolean |
getAuthentication()
Returns true if authentication with the SMTP server will be attempted,
false otherwise.
|
static java.io.ByteArrayOutputStream |
getByteArrayOutputStreamForCurrentThread()
This method help to reuse a heavy ByteArrayOutputStream for every thread.
|
static com.ibm.commerce.messaging.composer.Composer |
getComposerForCurrentThread(java.lang.String view,
com.ibm.commerce.command.CommandContext comContext,
com.ibm.commerce.datatype.TypedProperty properties)
This method help to reuse the Composer instance for every thread,
and set the parameters of that composer.
|
java.util.Map<javax.mail.Message.RecipientType,javax.mail.Address[]> |
getCustomRecipients()
Get the custom message recipients.
|
java.lang.Object |
getEmailPromotionId()
Get the email promotion Id.
|
java.lang.String |
getEmailPromotionName()
Get the email promotion name.
|
int |
getEmailRecipientListSize()
Get the number of recipients to whom to send the e-mail
|
java.util.Map |
getHeaders()
Get the message headers.
|
java.lang.String |
getHost()
Gets the host name of the SMTP server.
|
static EmailJobKeeper |
getInstance(EmailRecipientSupplier sendingJobType,
long id)
This method get the on-going instance of this class
|
int |
getNumberOfThreads()
Get the number of thread used to send email.
|
java.lang.String |
getPassword()
Gets the user account password used on the SMTP server.
|
PersonalizedEmailContent |
getPersonalizedEmailContent()
Get the personalized email content.
|
static java.util.Stack<PoolIdAndCode> |
getPoolIdAndCodeStack(java.lang.Integer promoId)
This method returns the
Stack containing PoolIdAndCode objects. |
int |
getPort()
Gets the port number through which the connection to the SMTP server will be attempted.
|
java.lang.String |
getReplyTo()
Gets the e-mail address that will be placed in the replyTo field of the e-mail message.
|
java.lang.String |
getSender()
Gets the e-mail address that is placed in the sender field of the e-mail message.
|
java.util.Map |
getSmtpSessionProperties()
This method returns the map with the additional properties to use when setting up the SMTP Session.
|
PurgingStringBuffer |
getSuccessfulRecipientReportBuffer()
This method return the successful recipient report buffer.
|
static TagEngine |
getTagEngineForCurrentThread()
This method help to reuse the TagEngine instance for every thread.
|
java.lang.String |
getUser()
Gets the user account name used on the SMTP server.
|
void |
prepareBatch(int ePromId,
java.util.Map triggerParas,
java.lang.String reply,
int msgIdInEntityType,
boolean dupEmailFilter,
boolean tryRecordSuccessfulRecipients,
com.ibm.commerce.command.CommandContext cc)
This method prepare the mail list to be send, if the list is empty.
|
void |
prepareBatch(int ePromId,
java.lang.String ePromoName,
java.util.Map triggerParas,
java.lang.String reply,
int msgIdInEntityType,
boolean dupEmailFilter,
boolean tryRecordSuccessfulRecipients,
com.ibm.commerce.command.CommandContext cc)
This method prepare the mail list to be send, if the list is empty.
|
static void |
putPoolIdAndCodeStack(java.lang.Integer promoId,
java.util.Stack<PoolIdAndCode> poolIdAndCodeStack)
This method associates the
Stack containing PoolIdAndCode objects with a promotion. |
void |
setDeleteMemberGroupAfterSend(boolean del)
This method sets if the member group associated with the e-mail promotion
should be deleted after the e-mails have been sent.
|
void |
setEmailPromoMemberGroupId(java.lang.String mbrGrpId)
This method sets the member group to whom the e-mail is being sent.
|
void |
setJobHost(java.lang.String host)
This method sets the scheduled job host, that is used to tell which host to
run the mail schedule-job; If the job host is empty or null, the host set in
email configuration table will be used.
|
void |
setNewHeader(java.lang.String name,
java.lang.String value)
Set a new header for the message.
|
void |
setReplyTo(java.lang.String r)
This method sets the e-mail address to be specified as the reply-to of the e-mail.
|
void |
setSender(java.lang.String s)
This method sets the e-mail address to be specified as the sender of the e-mail.
|
void |
setSmtpSessionProperties(java.util.Map properties)
This method checks the marketing wc-admin.component.xml file for the useSSLForSMTPAuthentication-
|
void |
startNewBatch(int ePromId,
java.util.Map triggerParas,
java.lang.String reply,
int msgIdInEntityType,
boolean dupEmailFilter,
boolean tryRecordSuccessfulRecipients,
com.ibm.commerce.command.CommandContext cc)
This method prepare the mail list to be send, if the list is empty.
|
void |
startNewBatch(int ePromId,
java.lang.String ePromoName,
java.util.Map triggerParas,
java.lang.String reply,
int msgIdInEntityType,
boolean dupEmailFilter,
boolean tryRecordSuccessfulRecipients,
com.ibm.commerce.command.CommandContext cc)
This method prepare the mail list to be send, if the list is empty.
|
public static final int BATCH_SIZE_FOR_ONE_SCHEDULE
public static final java.lang.String CONFIG_SMTP_USE_SSL
<_config:property name="useSSLForSMTPAuthentication-10001" value="true"/>
public static final java.lang.String CONTENT_GENERIC
public static final java.lang.String CONTINUEJOB
public static final java.lang.String COPYRIGHT
public static final java.lang.String DELETE_MEMBER_GROUP_AFTER_SEND
public static final java.lang.String EMAIL_PROMOTION_MEMBER_GROUP_ID
public static final java.lang.String EMLPROMO_ID
public static final java.lang.String PROPERTY_THREADCOUNT
public static final java.lang.String STORE_ID
public void addRecipient(javax.mail.Message.RecipientType recipientType, javax.mail.Address[] addresses)
The following is an example of a customization to set a BCC email address when sending a marketing email.
A) When sending a marketing e-mail from a dialog activity when the "Send immediately" checkbox is selected:
package com.custom.marketing; import javax.mail.Address; import javax.mail.Message; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import com.ibm.commerce.emarketing.commands.EmailIndividualCreateCmdImpl; import com.ibm.commerce.emarketing.engine.EmailJobKeeper; import com.ibm.commerce.exception.ECException; //insert into cmdreg (storeent_id, interfacename, classname) values (0,'com.ibm.commerce.emarketing.commands.EmailIndividualCreateCmd', 'com.custom.marketing.ExtEmailIndividualCreateCmdImpl'); public class ExtEmailIndividualCreateCmdImpl extends EmailIndividualCreateCmdImpl { protected void sendEmailDirectly(EmailJobKeeper mailJobKeeper) throws ECException { try { Address[] addresses = new Address[] { new InternetAddress("me@mycompany.com") }; mailJobKeeper.addRecipient(Message.RecipientType.BCC, addresses); } catch (AddressException e) { // do nothing } super.sendEmailDirectly(mailJobKeeper); } }
insert into cmdreg (storeent_id, interfacename, classname) values (0, 'com.ibm.commerce.emarketing.commands.EmailIndividualCreateCmd', 'com.custom.marketing.ExtEmailIndividualCreateCmdImpl');
B) When sending a marketing e-mail from a dialog activity when the "Send immediately" checkbox not is selected, or when sending a marketing e-mail from an e-mail activity.
package com.custom.marketing; import javax.mail.Address; import javax.mail.Message; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import com.ibm.commerce.emarketing.commands.SendEmailActivityTaskCmdImpl; import com.ibm.commerce.emarketing.engine.EmailJobKeeper; import com.ibm.commerce.exception.ECException; //insert into cmdreg (storeent_id, interfacename, classname) values (0, 'com.ibm.commerce.emarketing.commands.SendEmailActivityTaskCmd', 'com.custom.marketing.ExtSendEmailActivityTaskCmdImpl'); public class ExtSendEmailActivityTaskCmdImpl extends SendEmailActivityTaskCmdImpl { protected void sendEmail(EmailJobKeeper mailJobKeeper) throws ECException { try { Address[] addresses = new Address[] { new InternetAddress("me@mycompany.com") }; mailJobKeeper.addRecipient(Message.RecipientType.BCC, addresses); } catch (AddressException e) { // do nothing } super.sendEmail(mailJobKeeper); } }
package com.custom.marketing; import javax.mail.Address; import javax.mail.Message; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import com.ibm.commerce.emarketing.commands.ResendEmailActivityTaskCmdImpl; import com.ibm.commerce.emarketing.engine.EmailJobKeeper; import com.ibm.commerce.exception.ECException; //insert into cmdreg (storeent_id, interfacename, classname) values (0, 'com.ibm.commerce.emarketing.commands.ResendEmailActivityTaskCmd', 'com.custom.marketing.ExtResendEmailActivityTaskCmdImpl'); public class ExtResendEmailActivityTaskCmdImpl extends ResendEmailActivityTaskCmdImpl { protected void sendEmail(EmailJobKeeper mailJobKeeper) throws ECException { try { Address[] addresses = new Address[] { new InternetAddress("me@mycompany.com") }; mailJobKeeper.addRecipient(Message.RecipientType.BCC, addresses); } catch (AddressException e) { // do nothing } super.sendEmail(mailJobKeeper); } }
insert into cmdreg (storeent_id, interfacename, classname) values (0, 'com.ibm.commerce.emarketing.commands.SendEmailActivityTaskCmd', 'com.custom.marketing.ExtSendEmailActivityTaskCmdImpl'); insert into cmdreg (storeent_id, interfacename, classname) values (0, 'com.ibm.commerce.emarketing.commands.ResendEmailActivityTaskCmd', 'com.custom.marketing.ExtResendEmailActivityTaskCmdImpl');
recipientType
- The recipient type.addresses
- The list of email addresses.public void addToQueues(java.util.List[] queues)
queues
- The queue lists the email recipients.public static void clean(EmailRecipientSupplier sendingJobType, long id)
sendingJobType
- the EmailRecipientSupplier object is the type for the sending job, one type should only have one on-going sending job.id
- the task id.public static void cleanThreadLocalResources()
public static void cleanUpPromotionIdToAvailableCodesMap()
EmailActivitySendCmdImpl
after completing the sending
of an e-mail in an e-mail activity.public void finish()
public boolean getAuthentication()
public static java.io.ByteArrayOutputStream getByteArrayOutputStreamForCurrentThread()
public static com.ibm.commerce.messaging.composer.Composer getComposerForCurrentThread(java.lang.String view, com.ibm.commerce.command.CommandContext comContext, com.ibm.commerce.datatype.TypedProperty properties)
view
- the view name of the composer.comContext
- the command context of the composer.properties
- the properties of the composer.public java.util.Map<javax.mail.Message.RecipientType,javax.mail.Address[]> getCustomRecipients()
public java.lang.Object getEmailPromotionId()
public java.lang.String getEmailPromotionName()
public int getEmailRecipientListSize()
public java.util.Map getHeaders()
public java.lang.String getHost()
public static EmailJobKeeper getInstance(EmailRecipientSupplier sendingJobType, long id)
sendingJobType
- the EmailRecipientSupplier object is the type for the sending job, one type should only have one on-going sending job.id
- the task id.public int getNumberOfThreads()
public java.lang.String getPassword()
getAuthenication()
returns true.public PersonalizedEmailContent getPersonalizedEmailContent()
public static java.util.Stack<PoolIdAndCode> getPoolIdAndCodeStack(java.lang.Integer promoId)
Stack
containing PoolIdAndCode
objects. Each PoolIdAndCode
object
represents an available unique promotion code that can be assigned to a customer. The stack contains a subset of the entire
set of available promotion codes. Available promotion codes are added to the stack in batches of up to 1000 codes
in the class AllocatePromotionCodeCmdImpl
.promoId
- The promotion ID for which to get the stack of available promotion codes.PoolIdAndCode
objects.public int getPort()
public java.lang.String getReplyTo()
public java.lang.String getSender()
public java.util.Map getSmtpSessionProperties()
public PurgingStringBuffer getSuccessfulRecipientReportBuffer()
public static TagEngine getTagEngineForCurrentThread()
public java.lang.String getUser()
public void prepareBatch(int ePromId, java.util.Map triggerParas, java.lang.String reply, int msgIdInEntityType, boolean dupEmailFilter, boolean tryRecordSuccessfulRecipients, com.ibm.commerce.command.CommandContext cc) throws com.ibm.commerce.exception.ECException
ePromId
- the email activity id.triggerParas
- the trigger parameters.reply
- the reply to.msgIdInEntityType
- the message id in Entitytype.dupEmailFilter
- the flag to tell if filter the duplicated mails.tryRecordSuccessfulRecipients
- the flag to tell if try to record the successful recipient in mail-sending.cc
- the command context.com.ibm.commerce.exception.ECException
public void prepareBatch(int ePromId, java.lang.String ePromoName, java.util.Map triggerParas, java.lang.String reply, int msgIdInEntityType, boolean dupEmailFilter, boolean tryRecordSuccessfulRecipients, com.ibm.commerce.command.CommandContext cc) throws com.ibm.commerce.exception.ECException
ePromId
- the email activity id.ePromoName
- the email activity Name.triggerParas
- the trigger parameters.reply
- the reply to.msgIdInEntityType
- the message id in Entitytype.dupEmailFilter
- the flag to tell if filter the duplicated mails.tryRecordSuccessfulRecipients
- the flag to tell if try to record the successful recipient in mail-sending.cc
- the command context.com.ibm.commerce.exception.ECException
public static void putPoolIdAndCodeStack(java.lang.Integer promoId, java.util.Stack<PoolIdAndCode> poolIdAndCodeStack)
Stack
containing PoolIdAndCode
objects with a promotion.
Each PoolIdAndCode
object represents an available unique promotion code that can be assigned to a customer.
The stack contains a subset of the entire set of available promotion codes.
Available promotion codes are added to the stack in batches of up to 1000 codes
in the class AllocatePromotionCodeCmdImpl
.promoId
- The promotion ID for which to assign the stack of available promotion codes.poolIdAndCodeStack
- A stack containing PoolIdAndCode
objects.public void setDeleteMemberGroupAfterSend(boolean del)
del
- Set to true if the member group should be deleted.public void setEmailPromoMemberGroupId(java.lang.String mbrGrpId)
mbrGrpId
- The member group IDpublic void setJobHost(java.lang.String host)
host
- public void setNewHeader(java.lang.String name, java.lang.String value)
name
- the string input the new header name.value
- the string input the new header value.public void setReplyTo(java.lang.String r)
r
- The reply-to e-mail address.public void setSender(java.lang.String s)
s
- The sender e-mail address.public void setSmtpSessionProperties(java.util.Map properties)
properties
- A map with additional properties to use when setting up the SMTP Session.public void startNewBatch(int ePromId, java.util.Map triggerParas, java.lang.String reply, int msgIdInEntityType, boolean dupEmailFilter, boolean tryRecordSuccessfulRecipients, com.ibm.commerce.command.CommandContext cc) throws com.ibm.commerce.exception.ECException
ePromId
- the email activity id.triggerParas
- the trigger parameters.reply
- the reply to.msgIdInEntityType
- the message id in Entitytype.dupEmailFilter
- the flag to tell if filter the duplicated mails.tryRecordSuccessfulRecipients
- the flag to tell if try to record the successful recipient in mail-sending.cc
- the command context.com.ibm.commerce.exception.ECException
public void startNewBatch(int ePromId, java.lang.String ePromoName, java.util.Map triggerParas, java.lang.String reply, int msgIdInEntityType, boolean dupEmailFilter, boolean tryRecordSuccessfulRecipients, com.ibm.commerce.command.CommandContext cc) throws com.ibm.commerce.exception.ECException
ePromId
- the email activity id.ePromoName
- the email activity Name.triggerParas
- the trigger parameters.reply
- the reply to.msgIdInEntityType
- the message id in Entity type.dupEmailFilter
- the flag to tell if filter the duplicated mails.tryRecordSuccessfulRecipients
- the flag to tell if try to record the successful recipient in mail-sending.cc
- the command context.com.ibm.commerce.exception.ECException