Hi Friends,
Here is a situation I would like to point out, where by a system is having Human as well as System components interfaces bound together.
Now a component will have to decide whether to generate an email or a JMS message as response , I hereby propose a Factory pattern that decides the type of response, depending on the recipient address and from address.
If a '@' symbol encountered in both the addresses, then go for the emailing to a SMTP server, otherwise send a message to the JMS server.
Regards,
Istiaque.
http://techtips.ontheweb.com
-
Factory with JMS and Email (5 messages)
- Posted by: shaikh istiaque
- Posted on: September 02 2003 06:13 EDT
Threaded Messages (5)
- Factory with JMS and Email by Bob Lee on September 02 2003 11:49 EDT
- Factory with JMS and Email by shaikh istiaque on September 08 2003 07:26 EDT
- Factory with JMS and Email by Dorel Vaida on September 12 2003 09:33 EDT
- Factory with JMS and Email by shaikh istiaque on September 08 2003 07:26 EDT
- Factory with JMS and Email by Alexandr Kalinovski on September 03 2003 06:25 EDT
- Factory with JMS and Email by Srinivasa Rallabandi on September 05 2003 11:42 EDT
-
Factory with JMS and Email[ Go to top ]
- Posted by: Bob Lee
- Posted on: September 02 2003 11:49 EDT
- in response to shaikh istiaque
Why not always send a JMS message and implement a JMS client that sends e-mails in response to certain JMS messages? -
Factory with JMS and Email[ Go to top ]
- Posted by: shaikh istiaque
- Posted on: September 08 2003 07:26 EDT
- in response to Bob Lee
This way don't u think we shall be writing an application specific to a JMS implementation.
I may want to have my mailing system receivig the replys from the recipients SMTP server, not the JMS system.
Let me elaborate the design a bit,
inteface IMessage
{
public void sendMessage(String address, java.util.Hashtable param);
}
public class MessageFacade implements IMessage
{
//a singleton class
private MessageFacade messFac = new MessageFacade();
private MessageFacade()
{
}
public static MessageFacade getMessageFacade()
{
return messFac;
}
public void sendMessage(String address, Hashtable param)
{
if(address conatins '@', .com,.net,.org, etc etc)
{
call a SMTP and send the message.
} else {
call JMS message service.
}
}
}
class Client
{
public Client()
{
IMessage iMessage = MessageFacade.getInstance().sendMessage(..,..);
}
}
does all the trick.
Regards,
Istiaque.
http://www.ideas2work.com
} -
Factory with JMS and Email[ Go to top ]
- Posted by: Dorel Vaida
- Posted on: September 12 2003 09:33 EDT
- in response to shaikh istiaque
You might consider making messFac static if you want to compile the above code. Regarding this topic I don't think this is a new 'pattern'. Factory is a pattern indeed. What you have pointed out is a use of the Factory pattern. how is this new ? -
Factory with JMS and Email[ Go to top ]
- Posted by: Alexandr Kalinovski
- Posted on: September 03 2003 06:25 EDT
- in response to shaikh istiaque
I think that this idea is not very good just because in the future you can need some other notifying services. And component must not solve what kind of message to send. Otherwise it can reduce application scalability and maintenance. Instead You should use one message center, that you can configure at deployment time and that thus can solve whether to send simple JMS or e-mail or other type of messages. Similiar idea is Apache Log4J - You use general API to log application events and you can configure it to log into simple files,JMS,SMTP etc. But Your components know nothing about their sent messages.
For this needs, I also propose to use JMS and one fairly complicated MDB to solve this problem. And Your components always will send general JMS messages. -
Factory with JMS and Email[ Go to top ]
- Posted by: Srinivasa Rallabandi
- Posted on: September 05 2003 11:42 EDT
- in response to Alexandr Kalinovski
Better way to do is have a configuration file, which tells what are the listener classes for a JMS Topic. Dynamically instantiate them at the startup and let the listener classes implement what they want to do to either send an e-mail or do any activity.