Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WildFly support for MailHandler #110 #114

Merged
merged 11 commits into from
Nov 8, 2023

Conversation

jmehrens
Copy link
Contributor

@jmehrens jmehrens commented Oct 31, 2023

This is the PR for WildFly support for MailHandler

The key takeaways from this patch are:

  1. A new bean style adapter methods were added to parse mail properties file from a string. This allows the MailHandler to not be tied to a specific type of transport.
  2. Existing public methods needed to be relaxed to handle properties being cleared with 0 or null.
  3. Parts of WildFly get confused by method overloading. New method names have been added to provide a unique namespace. There is really no need to deprecated the old methods as I don't see a need to ever remove them.
  4. WildFly uses printf style formatting in its log messages. This revealed a long standing bug in the CompactFormatter and required an enhancement to the CompactFormatter in order to render the subject of an email correctly.
  5. A future enhancement ticket will be created to deal with Comparator creation. It is not supported in this patch.
  6. MailHandler has been updated to fix issues with attachments but attachments are not support because WildFly doesn't understand array method parameters. I'll file an enhancement request against WildFly for this before exploring any alternative options in the MailHandler.
  7. There are references to JavaMail API in the MailHandler. I'm going to create a new ticket to deal with those.

Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
@jmehrens jmehrens self-assigned this Oct 31, 2023
@jmehrens jmehrens marked this pull request as draft October 31, 2023 06:00
@jmehrens jmehrens requested review from lukasj and jbescos October 31, 2023 06:00
@jmehrens
Copy link
Contributor Author

jmehrens commented Oct 31, 2023

My list of things to do:

  1. Re-review the diffs myself. (Done)
  2. Run SpotBugs against code. (Done)
  3. Re-test with WildFly (Done)
  4. Test authentication. (Done)
  5. JavaDoc review. (Done)

DurationFilter count can be greater than records.
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
@jmehrens jmehrens marked this pull request as ready for review November 1, 2023 18:15
@jmehrens
Copy link
Contributor Author

jmehrens commented Nov 1, 2023

For testing in WildFly I did the following:

  1. Installed and started WildFly 29.
  2. Installed the Angus Mail patch using jbosscli as:
module add --name=org.eclipse.angus.logging-mailhandler --resource-delimiter=; --resources=~/jaf-api/api/target/jakarta.activation-api-2.2.0-SNAPSHOT.jar;~/mail/api/target/jakarta.mail-api-2.1.3-SNAPSHOT.jar;~/angus-activation/activation-registry/target/angus-activation-2.1.0-SNAPSHOT.jar;~/angus-mail/providers/angus-mail/target/angus-mail-2.0.3-SNAPSHOT.jar --dependencies=jakarta.activation.api,jakarta.mail.api,org.eclipse.angus.activation,org.eclipse.angus.mail,org.jboss.modules,java.logging,org.jboss.logging
  1. Using jbosscli created max rate filter (SPAM_FILTER) and a min rate filter (PUSH_FILTER) of one email every 15 seconds:
/subsystem=logging/filter=SPAM_FILTER:add(module=org.eclipse.angus.logging-mailhandler, class=org.eclipse.angus.mail.util.logging.DurationFilter, properties={records=1000,durationMillis=15000})

/subsystem=logging/filter=PUSH_FILTER:add(module=org.eclipse.angus.logging-mailhandler, class=org.eclipse.angus.mail.util.logging.DurationFilter, properties={records=1,durationMillis=15000})
  1. Using the web UI (http://localhost:9990/console/index.html#logging-configuration) created a CustomFormatter. To bypass edit checks of the UI the standalone.xml and logging.properties were manually edited:
<formatter name="MAIL_SUBJECT">
                <custom-formatter module="org.eclipse.angus.logging-mailhandler" class="org.eclipse.angus.mail.util.logging.CollectorFormatter">
                    <properties>
                        <property name="format" value="{3}|{0}{1}{2}... {4,number,integer} more"/>
                    </properties>
                </custom-formatter>
            </formatter>
  1. Using the web UI (http://localhost:9990/console/index.html#logging-configuration) created a CustomHandler:
<custom-handler name="MAIL" class="org.eclipse.angus.mail.util.logging.MailHandler" module="org.eclipse.angus.logging-mailhandler">
                <level name="ALL"/>
                <encoding value="UTF-8"/>
                <filter-spec value="SPAM_FILTER"/>
                <properties>
                    <property name="subjectFormatter" value="MAIL_SUBJECT"/>
                    <property name="pushLevel" value="ALL"/>
                    <property name="pushFilter" value="PUSH_FILTER"/>
                    <property name="capacity" value="1000"/>
                    <property name="mailEntries" value="mail.to=support@localhost#!mail.sender=wildfly@localhost#!mail.smtp.port=2525#!mail.host=localhost#!verify=resolve"/>
                </properties>
            </custom-handler>
  1. Used the web UI (http://localhost:9990/console/index.html#logging-configuration) to attach the "MAIL" logging handler to the root logger. Tested with root logger level set to ALL and level set to INFO. Emails were only generated every 15 seconds and the number of records varied.
  2. Manually verified the logging.properties and standalone.xml as it seems that in some cases properties are not synced between the 2 files or properties removed are left over.
  3. I did perform testing with wrapping the MailHandler in an AsyncHandler however, there are some issues with re-entrance on the publish method. The AsyncHandler auto flushes so that generates more email spam. These issues will result in AsyncHandler tickets and some future MailHandler tickets.

Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
Signed-off-by: jmehrens <jason_mehrens@hotmail.com>
@jmehrens jmehrens merged commit 76fde65 into eclipse-ee4j:master Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants