Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
#110 - reimplemented after the changes made in #115
Browse files Browse the repository at this point in the history
  • Loading branch information
danhaywood committed Oct 3, 2019
1 parent 98e80bf commit 7b1c8aa
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public class InteractionExecutionRepositoryMq implements InteractionExecutionRep

public static final String KEY_MEMBER_INTERACTIONS_QUEUE = ROOT + "memberInteractionsQueue";
public static final String KEY_MEMBER_INTERACTIONS_QUEUE_DEFAULT = "memberInteractionsQueue";

public static final String KEY_PROPAGATE_EXCEPTION = ROOT + "propagateException";
public static final String KEY_PROPAGATE_EXCEPTION_DEFAULT = "false";

//endregion


Expand All @@ -65,6 +69,8 @@ public class InteractionExecutionRepositoryMq implements InteractionExecutionRep

private boolean enabled;

private boolean propagateException;

//endregion

//region > init, shutdown
Expand All @@ -85,6 +91,8 @@ public void init(Map<String,String> properties) {
memberInteractionsQueueName = properties.getOrDefault(KEY_MEMBER_INTERACTIONS_QUEUE,
KEY_MEMBER_INTERACTIONS_QUEUE_DEFAULT);

propagateException = properties.getOrDefault(KEY_PROPAGATE_EXCEPTION, KEY_PROPAGATE_EXCEPTION_DEFAULT).equalsIgnoreCase("true");

connect();

}
Expand Down Expand Up @@ -192,9 +200,17 @@ private void sendUsingJms(final InteractionDto interactionDto) {

session.commit();

} catch (JMSException e) {
} catch (JMSException ex) {
rollback(session);
throw new ApplicationException("Failed to publish message", e);
if(propagateException) {
throw new ApplicationException(String.format(
"Failed to publish message, and aborting (as per '%s' property)", KEY_PROPAGATE_EXCEPTION),
ex);
} else {
LOG.error(String.format(
"Failed to publish message, but continuing (as per '%s' property)", KEY_PROPAGATE_EXCEPTION),
ex);
}
} finally {
if(session != null) {
closeSafely(session);
Expand Down

0 comments on commit 7b1c8aa

Please sign in to comment.