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

Publish/Subscribe pattern #3140

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

hungryDev399
Copy link

Implementation of the Publish/Subscribe design pattern using JMS

Close #2898

Copy link

sonarqubecloud bot commented Dec 9, 2024

@hungryDev399
Copy link
Author

Any idea why sonarcloud does not seem to analyze the code?

Copy link
Owner

@iluwatar iluwatar left a 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.

Comment on lines +11 to +13
/**
* Main application demonstrating different aspects of JMS publish-subscribe pattern.
*/
Copy link
Owner

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();
Copy link
Owner

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();
Copy link
Owner

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));
Copy link
Owner

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

Comment on lines +17 to +23
public String getContent() {
return content;
}

public String getTopic() {
return topic;
}
Copy link
Owner

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

Comment on lines +1 to +17
<?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>
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publish/Subscribe pattern
2 participants