|
Email Answering System Version 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ninecode.email.beans.master.EmailDispatcher
Message driven bean reads from a queue and dispatches to topics based on subject. The plan was to examine the Subject property set on a BytesMessage and try to find a matching Topic. To do that it converts the subject to lower case so the case-sensitivity of the lookup doesn't matter. It also trys "jms/" + topic in the case of a failed lookup. If no topic is found it sends a message to the output queue (return to sender) with a "help" message. This, however, is not allowed since arbitrary jndi lookups are not allowed. So... Another method is used. This is a configured list of subject-topic pairs that have a direct mapping. This list can't be dynamic due to the life-cycle of the message bean. Each message driven bean that is in the list would have it's own "help" command. That is, a message with subject xxx would be forwarded on to the topic associated with xxx and if the message body is the text string "help" (case-insensitive) it would answer with some help text. If no topic can be found using the above mechanisms it responds with the list of subjects it was configured with and a helpful message that says ask them for help on the topic. If a matching topic is found the message is essentially forwarded to the topic.
Field Summary | |
protected EmailProperties |
mMap
The list of subject-topic pairs. |
Constructor Summary | |
EmailDispatcher()
Creates a EmailDispatcher bean. |
Method Summary | |
void |
bounceMessage(Message message,
String subject,
String content)
Reply with help for unhandled messages. |
protected void |
dispatch(Message message)
Dispatch the message. |
void |
ejbCreate()
Startup call. |
void |
ejbRemove()
Shutdown call. |
void |
forwardMessage(Message message,
String name)
Forward a jms message to the topic given. |
byte[] |
getBytes(BytesMessage message)
Read all bytes from a bytes message. |
protected String |
getTopics()
Get the list of configured topics. |
void |
helpMessage(Message message)
Send help messages to all topics. |
protected void |
initializeMapping()
Internalize the configured environment "Subject Topic Map". |
void |
onMessage(Message message)
Process a message. |
void |
setMessageDrivenContext(MessageDrivenContext mdc)
Remember the context for this instance. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected EmailProperties mMap
Constructor Detail |
public EmailDispatcher()
Method Detail |
public void ejbCreate()
public void ejbRemove() throws EJBException
ejbRemove
in interface MessageDrivenBean
EJBException
protected void initializeMapping()
public byte[] getBytes(BytesMessage message) throws JMSException
JMSException
public void forwardMessage(Message message, String name) throws NamingException, JMSException
message
- The message to forward.name
- The topic name.
A lookup is performed on this name within the "java:comp/env"
environment.
NamingException
JMSException
public void helpMessage(Message message) throws NamingException, JMSException
message
- The help message.
NamingException
JMSException
protected String getTopics()
public void bounceMessage(Message message, String subject, String content) throws NamingException, JMSException
message
- The message to bounce.
NamingException
JMSException
protected void dispatch(Message message)
message
- The message to dispatch.public void setMessageDrivenContext(MessageDrivenContext mdc) throws EJBException
setMessageDrivenContext
in interface MessageDrivenBean
EJBException
public void onMessage(Message message)
onMessage
in interface MessageListener
message
- The message to process.
|
Email Answering System Version 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |