-
-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Publish/Subscribe pattern #3140
base: master
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
Any idea why sonarcloud does not seem to analyze the code? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the review comments. Additionally:
- Check spelling of the folder (publish-subsribe -> publish-subscribe)
- Add the module to the parent pom.xml. Otherwise, CI does not even build it.
/** | ||
* Main application demonstrating different aspects of JMS publish-subscribe pattern. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Describe the pattern and explain how this example implements it
demonstrateSharedSubscriptions(); | ||
} catch (Exception e) { | ||
System.err.println("Error in publish-subscribe demo: " + e.getMessage()); | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a proper logger
} finally { | ||
cleanup(null); | ||
} | ||
JmsUtil.closeConnection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be inside the finally block?
|
||
try { | ||
// Create basic subscribers | ||
subscribers.add(new TopicSubscriber("BasicSub1", "NEWS", SubscriberType.NONDURABLE, null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use constants for strings like this
public String getContent() { | ||
return content; | ||
} | ||
|
||
public String getTopic() { | ||
return topic; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Lombok to get rid of boilerplate
<?xml version="1.0" encoding="UTF-8"?> | ||
<Configuration status="INFO"> | ||
<Appenders> | ||
<Console name="Console" target="SYSTEM_OUT"> | ||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> | ||
</Console> | ||
</Appenders> | ||
<Loggers> | ||
<Root level="info"> | ||
<AppenderRef ref="Console"/> | ||
</Root> | ||
<!-- Reduce ActiveMQ logging --> | ||
<Logger name="org.apache.activemq" level="warn" additivity="false"> | ||
<AppenderRef ref="Console"/> | ||
</Logger> | ||
</Loggers> | ||
</Configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use Lombok's logger instead
Implementation of the Publish/Subscribe design pattern using JMS
Close #2898