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

Commit 7b1c8aa

Browse files
committed
#110 - reimplemented after the changes made in #115
1 parent 98e80bf commit 7b1c8aa

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

modules/spi/publishmq/impl/mq/src/main/java/org/isisaddons/module/publishmq/dom/mq/spi/InteractionExecutionRepositoryMq.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public class InteractionExecutionRepositoryMq implements InteractionExecutionRep
4949

5050
public static final String KEY_MEMBER_INTERACTIONS_QUEUE = ROOT + "memberInteractionsQueue";
5151
public static final String KEY_MEMBER_INTERACTIONS_QUEUE_DEFAULT = "memberInteractionsQueue";
52+
53+
public static final String KEY_PROPAGATE_EXCEPTION = ROOT + "propagateException";
54+
public static final String KEY_PROPAGATE_EXCEPTION_DEFAULT = "false";
55+
5256
//endregion
5357

5458

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

6670
private boolean enabled;
6771

72+
private boolean propagateException;
73+
6874
//endregion
6975

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

94+
propagateException = properties.getOrDefault(KEY_PROPAGATE_EXCEPTION, KEY_PROPAGATE_EXCEPTION_DEFAULT).equalsIgnoreCase("true");
95+
8896
connect();
8997

9098
}
@@ -192,9 +200,17 @@ private void sendUsingJms(final InteractionDto interactionDto) {
192200

193201
session.commit();
194202

195-
} catch (JMSException e) {
203+
} catch (JMSException ex) {
196204
rollback(session);
197-
throw new ApplicationException("Failed to publish message", e);
205+
if(propagateException) {
206+
throw new ApplicationException(String.format(
207+
"Failed to publish message, and aborting (as per '%s' property)", KEY_PROPAGATE_EXCEPTION),
208+
ex);
209+
} else {
210+
LOG.error(String.format(
211+
"Failed to publish message, but continuing (as per '%s' property)", KEY_PROPAGATE_EXCEPTION),
212+
ex);
213+
}
198214
} finally {
199215
if(session != null) {
200216
closeSafely(session);

0 commit comments

Comments
 (0)