-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Created the BroadcastController on module common-web-notification. - Created the module common-web-notification-client. - Renamed AbstractEntity.kt to AbstractIdentity.kt.
- Loading branch information
1 parent
a6c3031
commit fe1b371
Showing
77 changed files
with
963 additions
and
238 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="common-web-notification" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot"> | ||
<module name="common-web-notification" /> | ||
<option name="SPRING_BOOT_MAIN_CLASS" value="io.herd.common.web.notification.WebTempApplication" /> | ||
<extension name="coverage"> | ||
<pattern> | ||
<option name="PATTERN" value="io.herd.common.web.notification.*" /> | ||
<option name="ENABLED" value="true" /> | ||
</pattern> | ||
</extension> | ||
<method v="2"> | ||
<option name="Make" enabled="true" /> | ||
</method> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Support for JMS Queues | ||
---------------------- | ||
|
||
It will be necessary to copy the file `jms.properties` contained in the directory `/src/main/resources` | ||
of this project, to your application's `/src/main/resources` directory, changing the values | ||
It will be necessary to copy the file `jms.properties` contained in the directory `/src/main/resources` | ||
of this project, to your application's `/src/main/resources` directory, changing the values | ||
of its properties according to the necessity. | ||
Only copy this properties file, in case there is a change in the properties. | ||
Only copy this properties file, in case there is a change in the properties. |
41 changes: 41 additions & 0 deletions
41
common-jms/src/main/java/io/herd/common/jms/AbstractAsyncMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2024 - Felipe Desiderati | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
* associated documentation files (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial | ||
* portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT | ||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
package io.herd.common.jms; | ||
|
||
import java.util.UUID; | ||
|
||
@SuppressWarnings("unused") | ||
public abstract class AbstractAsyncMessage implements AsyncMessage { | ||
|
||
private final UUID msgId; | ||
|
||
public AbstractAsyncMessage() { | ||
this.msgId = UUID.randomUUID(); | ||
} | ||
|
||
@Override | ||
public UUID getMsgId() { | ||
return msgId; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AbstractAsyncMessage{mgId=" + msgId + "}"; | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
common-jms/src/main/java/io/herd/common/jms/AbstractAsyncMessageListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (c) 2024 - Felipe Desiderati | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
* associated documentation files (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial | ||
* portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT | ||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
package io.herd.common.jms; | ||
|
||
import io.herd.common.exception.ApplicationException; | ||
import io.herd.common.jms.configuration.JmsAutoConfiguration; | ||
import jakarta.jms.Message; | ||
import jakarta.validation.ConstraintViolationException; | ||
import lombok.SneakyThrows; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.jms.annotation.JmsListener; | ||
|
||
/** | ||
* {@link jakarta.jms.MessageListener} responsible for reading messages sent to the standard queue. | ||
* | ||
* @see JmsAutoConfiguration#queue(String) | ||
*/ | ||
@Slf4j | ||
public abstract class AbstractAsyncMessageListener<M extends AsyncMessage> { | ||
|
||
@SneakyThrows | ||
@JmsListener(destination = "${jms.default-queue.name}") | ||
public void onMessage(Message jmsMessage, M message) { | ||
try { | ||
log.info("Message '{}' received!", message.getMsgId()); | ||
log.debug("{}", jmsMessage); | ||
receive(message); | ||
log.info("Message '{}' received and processed with success!", message.getMsgId()); | ||
jmsMessage.acknowledge(); | ||
|
||
} catch (ApplicationException applicationException) { | ||
// It means is an application (business) exception and there's nothing else to do about it. | ||
handleApplicationException(jmsMessage, message, applicationException); | ||
|
||
} catch (ConstraintViolationException constraintViolationException) { | ||
// Thrown when used the @{link jakarta.validation.Valid} annotation. | ||
StringBuilder validationErrorsMsg = new StringBuilder("Constraint Violations:"); | ||
constraintViolationException.getConstraintViolations().forEach( | ||
constraintViolation -> validationErrorsMsg | ||
.append(System.lineSeparator()) | ||
.append(constraintViolation.getPropertyPath()) | ||
.append(":") | ||
.append(constraintViolation.getMessage()) | ||
); | ||
handleApplicationException(jmsMessage, message, new ApplicationException(validationErrorsMsg.toString())); | ||
|
||
} catch (Throwable throwable) { | ||
throw new JmsApplicationException(jmsMessage, throwable.getMessage(), throwable); | ||
} | ||
} | ||
|
||
/** | ||
* Method responsible for processing the message received from the queue. | ||
* | ||
* @param message The message received from the queue. | ||
* @throws Exception If any error occurs during the processing of the message. | ||
*/ | ||
protected abstract void receive(M message) throws Exception; | ||
|
||
/** | ||
* Handles an application (business) exception that occurred while processing a message. | ||
* | ||
* @param jmsMessage The JMS message that triggered the exception. | ||
* @param message The message being processed when the exception occurred. | ||
* @param applicationException The application exception that occurred. | ||
*/ | ||
@SuppressWarnings("unused") | ||
protected void handleApplicationException( | ||
Message jmsMessage, | ||
M message, | ||
ApplicationException applicationException | ||
) { | ||
log.error("Error while processing message '{}': ", message.getMsgId(), applicationException); | ||
} | ||
} |
43 changes: 0 additions & 43 deletions
43
common-jms/src/main/java/io/herd/common/jms/AbstractMessageListener.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.