6 Replies Latest reply on Mar 24, 2010 10:04 AM by khoying

    Logging mails in jBPM 4.0.CR1

    nilspreusker

      Dear jbpm community,

      I'm wondering if there is a way to log mails instead of sending them in jBPM 4. This would be useful for unit tests. I thought it might be possible to write a custom MailProducer or MailSession that overrides the send method and just logs the mail message rather than sending it. I'd also be interested to know how to actually make jBPM use a custom MailProducer, as the example in the user guide (jbpm-4.0.CR1) currently only shows how to override the default MailProducerImpl in java, but misses the configuration that is required to tell the workflow engine to use the custom producer instead of the default one.

      Thanks in advance for your help!

      Kind regards, Nils

        • 1. Re: Logging mails in jBPM 4.0.CR1
          aguizar

          Nils, why don't you use a mock SMTP server such as Wiser? That is what we use to test the email module.

          • 2. Re: Logging mails in jBPM 4.0.CR1
            aguizar

            Point taken, the custom MailProducer documentation and the customization mechanism itself need some more work.

            • 3. Re: Logging mails in jBPM 4.0.CR1
              kukeltje

              Alex, did you file a Jira ;-)

              • 4. Re: Logging mails in jBPM 4.0.CR1
                nilspreusker

                Hi Alex,

                thanks for the hint with Wiser, that's exactly what I ended up doing after looking at the jBPM test cases:)

                Cheers, Nils

                • 5. Re: Logging mails in jBPM 4.0.CR1
                  nilspreusker

                  Hi again,

                  I knew I would come across this again:) This time I'd like to implement a custom mail producer that uses a java class (in this particular case a spring bean) to generate attachments. The way I imagine it to work is that a custom producer first checks for the presence of a certain name (or a custom attachment type in addition to the existing ones; url, resource and file). If the name or type is present, the producer generates the custom attachment and then calls the default mail producer's addAttachment method (super.addAttachment) to take care of the rest. I think this is a pretty generic requirement, so I would like to contribute it as an example to the Developers Guide (if I actually succeed in implementing it).

                  What I know up to now is that I can extend org.jbpm.pvm.internal.email.impl.MailProducerImpl, as stated in the dev guide. I'm still not sure how I actually tell jBPM to use the custom producer. Maybe someone can point me at how to get the configuration right. The other challenge is to parse the inline mail template that defines the attachments, but looking at the source code of MailProducerImpl, extracting the relevant logic from there shouldn't be a big problem.

                  Thanks in advanced for your help!

                  Cheers, Nils

                  • 6. Re: Logging mails in jBPM 4.0.CR1
                    khoying

                    Did you ever figure out how to configure a custom MailProducer?  I have a need to do this, as well.

                     

                    Thank you!