Please any one help me on this requirement.
Please let me know how can i send content of message body as Email attachment. And how to use SMTP details (host, user name and password) from database.
I am eagerly waiting for your help...
Hi. Do you want to define 'to', 'subject' etc. on a per message basis? Have you considered overriding NotifyEmail.sendEmailNotification?
BTW, I've been looking at the current NotifyEmail class for similar reasons recently, so would be interested in your feedback on your use case.
Mark, thanks for your reply.
Yes i want 'from', 'sendTo', 'subject' per message basis.
And i want SMTPHost, User name, Password also per message basis.
For dynamic 'from', 'sendTo', 'subject' i have planned this way.
1. Create one action which will extend "Notifier" action.
public class SendFileAction extends Notifier
2. Overwrite notifyOK method.
3. Modify the config tree to change 'from', 'sendTo', 'subject' with the values taken from database (these values will be different for each message)
4. Create object of NotifyEmail with modified config tree.
NotifyFTP nftp = new NotifyFTP(modifiedConfigTree);
5. Then call "sendNotification" function
Similar things i had done while creating "FTPService", and I have successfully created FTPService which FTPs the message body as a file.
Here is my problem:
1. SMTP host, user name and password will also be per message basis, for ex. first message to this service may use SMTP host 22.214.171.124 and second message may use 126.96.36.199.
Since the SMTP host should be specified in "jbossesb.sar/jbossesb-properties.xml" file so how can we use SMTP host, user name and password from database?
Is there any other way to create FTPService and SMTPService, I am sure there should be some effective way to implement this. I have planned this way since I have limited knowledge of ESB. Below are my use cases.
1. User will subscribe any one of the available service like sendRailBill, sendShipmentInfo. While subscribing user will provide the following information,
a. communication mode (possible values FTP, SMTP)
b. FTP details (if communication mode is FTP): IP, user name, password, ftp folder name.
c. SMTP details (if communication mode is SMTP): Email ID, SMTP host, user name, password
2. On timely basis or some UI event basis JMS message will get generated for subscribed service. Suppose user had subscribed for sendRailBill service.
3. sendRailBill service will work this way,
a. Extract data from database
b. Transform the data into client format
c. On basis of communication mode, route the message to FTPService/SMTPService
4. SMTPService should get all the information from database like mail id, smtp host, user name, password and convert the message body in configured file name and send the mail by attaching the file.
we created a jira for this issue: https://jira.jboss.org/jira/browse/JBESB-2257. If you take a look at the comments I think that they will address your issues here and you should now be able to achieve what you described in you last post.
Please give it a try and let us know how it works out.
Thanks all, for taking care of my requirement.
After looking at JIRA task it seems this is fixed by Daniel, but i don't know what should i do to use the new code. I am using jbossesb-server-4.4.GA.
I really appreciate your efforts.
Sorry I should have explained that more closely.
So, the configuration in jboss-esb.xml can now look like:
<target class="NotifyEmail" host="localhost" port="8801" username="smtpUsername" password="smtpPassword" auth="true" from="email@example.com" sendTo="firstname.lastname@example.org" subject="theSubject"> msgAttachmentName="theSubject"> <attachment>attachThisFile.txt</attachment> </target>
The above properties can be overriden by setting the same properties on the ESB Message object. This could be done in a separate action in the action pipeline.
You also have the option to extend NotifyEmail and implement its sendNotification method.
Perhaps a separate action would be cleaner as you could configure it with the database connection properties for the query operation that retrieves the connection properties
Does that make sense?
Forgot to ask you a question. Would it been easier for you use case if there was a email action instead of using a notifier. Do you have the need to send notification if there is a failure?
Mark and I were discussing this yesterday and created the following feature request:
The above properties can be overridden by setting the same properties on the ESB Message object. This could be done in a separate action in the action pipeline.
Can i achieve this in my current version of esb that is "jbossesb-server-4.4.GA" or i would have to change some files?
Would it been easier for you use case if there was a email action instead of using a notifier. Do you have the need to send notification if there is a failure?
It would be great if i can use Email action instead of using Notifier action.
And if we can do the similar things in NotifyFTP things would be very easy.
If you are interested i could share the code i have written to implement FTPService, i am not sure where i am doing the things in right way or not.
Thanks a ton...
The notification mechanism was never intended to be used in the way that the current notifiers are working.
The original intention of the notifiers was to allow actions to handle the result of the pipeline, for example cleanup any resources they may have associated with the message or inform on successful completion/failure.
It should be easy to extend the current notification code to allow all the notifiers to be used within a pipeline as well as for notifications. I believe this would be the real fix.
I absolutely agree - that is the way to fix this.
It would be great to be able to use the notifier (or perhaps just the notification targets?) as part of a 'normal' pipeline.