You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2007/02/20 16:49:19 UTC
svn commit: r509614 - in
/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl:
Messages.properties SimpleSubscriptionManager.java
Author: danj
Date: Tue Feb 20 07:49:18 2007
New Revision: 509614
URL: http://svn.apache.org/viewvc?view=rev&rev=509614
Log:
Fix for MUSE-196 - make notification failure more configurable.
Modified:
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/Messages.properties
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleSubscriptionManager.java
Modified: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/Messages.properties?view=diff&rev=509614&r1=509613&r2=509614
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/Messages.properties Tue Feb 20 07:49:18 2007
@@ -16,3 +16,4 @@
InvalidFilterType=The filter provided is not valid according to the WS-N spec - there is no filter type for element 'XXX'.
InvalidDialect=Subscription filters do not support the dialect 'XXX'. The supported dialects are: XXX
LastPublishFailed=The last notification published via wsnt\:Notify failed to reach its destination. The consumer may be unavailable. The original error was: XXX
+InvalidNumberOfTries=The number-of-tries parameter must be greater than or equal to 1 (the default value is 1).
Modified: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleSubscriptionManager.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleSubscriptionManager.java?view=diff&rev=509614&r1=509613&r2=509614
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleSubscriptionManager.java (original)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleSubscriptionManager.java Tue Feb 20 07:49:18 2007
@@ -67,6 +67,16 @@
private static final String _TRACE_PARAM = "trace-notifications";
//
+ // init. param used to re-try notifications that fail
+ //
+ private static final String _TRY_PARAM = "number-of-tries";
+
+ //
+ // init. param used to destroy subscriptions if notifications fail
+ //
+ private static final String _DESTROY_PARAM = "destroy-on-failure";
+
+ //
// The client that is used to publish messages to the consumer
//
private NotificationConsumerClient _client = null;
@@ -86,11 +96,18 @@
//
private Filter _filter = null;
+ private boolean _isDestroyedOnFailure = false;
+
private boolean _isPaused = false;
private boolean _isUsingTrace = false;
//
+ // number of times to try a notification before giving up
+ //
+ private int _numberOfTries = 1;
+
+ //
// EPR of the resource using this capability
//
private EndpointReference _producer = null;
@@ -139,6 +156,11 @@
return _filter;
}
+ protected int getNumberOfTries()
+ {
+ return _numberOfTries;
+ }
+
public EndpointReference getProducerReference()
{
return _producer;
@@ -171,6 +193,30 @@
if (traceString != null)
_isUsingTrace = Boolean.valueOf(traceString).booleanValue();
+
+ //
+ // allow for notification re-tries, if desired
+ //
+ String retryString = getInitializationParameter(_TRY_PARAM);
+
+ if (retryString != null)
+ _numberOfTries = Integer.valueOf(retryString).intValue();
+
+ if (_numberOfTries <= 0)
+ throw new RuntimeException(_MESSAGES.get("InvalidNumberOfTries"));
+
+ //
+ // allow for subscription destruction on failure, if desired
+ //
+ String destroyString = getInitializationParameter(_DESTROY_PARAM);
+
+ if (destroyString != null)
+ _isDestroyedOnFailure = Boolean.valueOf(destroyString).booleanValue();
+ }
+
+ protected synchronized boolean isDestroyedOnFailure()
+ {
+ return _isDestroyedOnFailure;
}
public synchronized boolean isPaused()
@@ -199,22 +245,37 @@
message.setProducerReference(getProducerReference());
message.setSubscriptionReference(getResource().getEndpointReference());
+ boolean success = false;
+ int tries = getNumberOfTries();
+
+ for (int n = 0; n < tries && !success; ++n)
+ {
+ try
+ {
+ NotificationConsumerClient client = getConsumerClient();
+ client.notify(new NotificationMessage[]{ message });
+
+ success = true;
+ }
+
+ catch (SoapFault error)
+ {
+ LoggingUtils.logError(getLog(), error);
+
+ Object[] filler = { error.getMessage() };
+ getLog().info(_MESSAGES.get("LastPublishFailed", filler));
+ }
+ }
+
try
{
- NotificationConsumerClient client = getConsumerClient();
- client.notify(new NotificationMessage[]{ message });
+ if (!success && isDestroyedOnFailure())
+ getResource().shutdown();
}
catch (SoapFault error)
{
- //
- // log the error and include a follow up message to
- // provide some context
- //
LoggingUtils.logError(getLog(), error);
-
- Object[] filler = { error.getMessage() };
- getLog().info(_MESSAGES.get("LastPublishFailed", filler));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org