Author: heiko.braun(a)jboss.com
Date: 2007-01-15 07:29:50 -0500 (Mon, 15 Jan 2007)
New Revision: 1962
Added:
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/element/NotificationFailure.java
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/Subscription.java
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManager.java
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManagerMBean.java
Log:
Fix JBWS-1406. Thanks for the contribution from Alessio Soldano
Added:
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/element/NotificationFailure.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/element/NotificationFailure.java 2007-01-15
12:14:55 UTC (rev 1961)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/element/NotificationFailure.java 2007-01-15
12:29:50 UTC (rev 1962)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.eventing.element;
+
+import java.net.URI;
+
+import org.jboss.ws.core.utils.DOMWriter;
+import org.w3c.dom.Element;
+
+/**
+ * Represent an error during notification.
+ *
+ * @author Stefano Maestri <stefano.maestri(a)javalinux.it>, Alessio Soldano
<alessio.soldano(a)javalinux.it>
+ * @since 26/11/2006
+ */
+
+public class NotificationFailure
+{
+ private URI endTo;
+ private Element event;
+ private Exception exception;
+
+ public NotificationFailure(URI endTo, Element event, Exception exception)
+ {
+ super();
+ this.endTo = endTo;
+ this.event = event;
+ this.exception = exception;
+ }
+ public URI getEndTo()
+ {
+ return endTo;
+ }
+ public void setEndTo(URI endTo)
+ {
+ this.endTo = endTo;
+ }
+ public Element getEvent()
+ {
+ return event;
+ }
+ public void setEvent(Element event)
+ {
+ this.event = event;
+ }
+ public Exception getException()
+ {
+ return exception;
+ }
+ public void setException(Exception exception)
+ {
+ this.exception = exception;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("endTo: ");
+ sb.append(endTo);
+ sb.append("\n\nevent: ");
+ sb.append(DOMWriter.printNode(event, false));
+ sb.append("\n\nexception: ");
+ sb.append(exception);
+ sb.append("\n*******************\n");
+ return sb.toString();
+ }
+
+}
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/Subscription.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/Subscription.java 2007-01-15
12:14:55 UTC (rev 1961)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/Subscription.java 2007-01-15
12:29:50 UTC (rev 1962)
@@ -39,6 +39,7 @@
import org.jboss.ws.core.utils.DOMWriter;
import org.jboss.ws.extensions.eventing.EventingConstants;
import org.jboss.ws.extensions.eventing.element.EndpointReference;
+import org.jboss.ws.extensions.eventing.element.NotificationFailure;
import org.w3c.dom.Element;
/**
@@ -58,6 +59,8 @@
final private EndpointReference endpointReference;
final private URI eventSourceNS;
+ private SubscriptionManagerFactory factory =
SubscriptionManagerFactory.getInstance();
+
public Subscription(URI eventSourceNS, EndpointReference endpointReference,
EndpointReference notifyTo, EndpointReference endTo, Date expires, Filter filter)
{
this.eventSourceNS = eventSourceNS;
@@ -98,7 +101,9 @@
}
catch (Exception e)
{
- // todo: this should get back to manager
+ SubscriptionManagerMBean manager = factory.getSubscriptionManager();
+ NotificationFailure failure = new NotificationFailure(this.endTo.getAddress(),
event, e);
+ manager.addNotificationFailure(failure);
log.error("Failed to send notification message", e);
}
}
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManager.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManager.java 2007-01-15
12:14:55 UTC (rev 1961)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManager.java 2007-01-15
12:29:50 UTC (rev 1962)
@@ -53,6 +53,7 @@
import org.jboss.ws.extensions.eventing.deployment.EventingEndpointDI;
import org.jboss.ws.extensions.eventing.element.EndpointReference;
import org.jboss.ws.extensions.eventing.element.ReferenceParameters;
+import org.jboss.ws.extensions.eventing.element.NotificationFailure;
import org.w3c.dom.Element;
/**
@@ -116,6 +117,13 @@
private static EventingBuilder builder = EventingBuilder.createEventingBuilder();
+
+ /**
+ * List containing all errors occured during notification since service startup
+ * todo: save this list and made possible to resend failed notification using jms
instead of list
+ */
+ private List<NotificationFailure> notificationFailures = new
ArrayList<NotificationFailure>();
+
public void create() throws Exception
{
MBeanServer server = getJMXServer();
@@ -457,6 +465,16 @@
threadPool.execute(dispatchJob);
}
+ public void addNotificationFailure(NotificationFailure failure)
+ {
+ notificationFailures.add(failure);
+ }
+
+ public List<NotificationFailure> showNotificationFailures()
+ {
+ return notificationFailures;
+ }
+
// ----------------------------------------------------------------------
// MBean support
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManagerMBean.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManagerMBean.java 2007-01-15
12:14:55 UTC (rev 1961)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/extensions/eventing/mgmt/SubscriptionManagerMBean.java 2007-01-15
12:29:50 UTC (rev 1962)
@@ -25,9 +25,11 @@
import java.net.URI;
import java.util.Date;
+import java.util.List;
import org.jboss.ws.extensions.eventing.deployment.EventingEndpointDI;
import org.jboss.ws.extensions.eventing.element.EndpointReference;
+import org.jboss.ws.extensions.eventing.element.NotificationFailure;
import org.w3c.dom.Element;
/**
@@ -98,4 +100,8 @@
String showSubscriptionTable();
String showEventsourceTable();
+
+ public void addNotificationFailure(NotificationFailure failure);
+
+ public List<NotificationFailure> showNotificationFailures();
}