You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2007/10/02 05:27:25 UTC
svn commit: r581131 [1/2] - in /webservices/synapse/trunk/java: ./
modules/core/src/main/java/org/apache/synapse/
modules/core/src/main/java/org/apache/synapse/config/xml/
modules/core/src/main/java/org/apache/synapse/core/axis2/
modules/core/src/main/...
Author: asankha
Date: Mon Oct 1 20:27:24 2007
New Revision: 581131
URL: http://svn.apache.org/viewvc?rev=581131&view=rev
Log:
review/refactor and document more code being careful with the core/axis2 package
improve logging somemore
Added:
webservices/synapse/trunk/java/modules/core/src/main/resources/providers.xml
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AnonymousServiceFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AsyncCallback.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2MessageContext.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/MessageContextCreatorForAxis2.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SynapseMediator.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java
webservices/synapse/trunk/java/modules/core/src/main/resources/log4j.properties
webservices/synapse/trunk/java/pom.xml
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java Mon Oct 1 20:27:24 2007
@@ -22,6 +22,8 @@
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMNamespace;
+import javax.xml.namespace.QName;
+
/**
* Global constants for the Apache Synapse project
*/
@@ -38,6 +40,11 @@
/** The name of the fault sequence to execute on failures during mediation */
public static final String FAULT_SEQUENCE_KEY = "fault";
+ /** The name of the Synapse service (used for message mediation) */
+ public static final String SYNAPSE_SERVICE_NAME ="SynapseService";
+ /** The operation name used by the Synapse service (for message mediation) */
+ public static final QName SYNAPSE_OPERATION_NAME = new QName("mediate");
+
//- names of modules to be engaged at runtime -
/** The Name of the WS-RM Sandesha module */
public static final String SANDESHA2_MODULE_NAME = "sandesha2";
@@ -126,16 +133,16 @@
public static final int STATISTICS_UNSET=2;
/** key for lookup sequence statistics stack */
- public static final String SEQUENCE_STATISTICS_STACK ="sequence_statistics_stack";
+ public static final String SEQUENCE_STATS ="synapse.sequence.stats";
/** key for lookup Proxy Service statistics stack */
- public static final String PROXYSERVICE_STATISTICS_STACK ="proxyservice_statistics_stack";
+ public static final String PROXY_STATS ="synapse.proxy.stats";
/** key for lookup Proxy Service statistics stack */
- public static final String SYNAPSESERVICE_STATISTICS_STACK ="synapseservice_statistics_stack";
+ public static final String SERVICE_STATS ="synapse.service.stats";
/** key for lookup Endpoint statistics stack */
- public static final String ENDPOINT_STATISTICS_STACK ="endpoint_statistics_stack";
+ public static final String ENDPOINT_STATS ="synapse.endpoint.stats";
/** Sequence statistics category*/
public static final int SEQUENCE_STATISTICS = 0;
@@ -147,12 +154,27 @@
public static final int ENDPOINT_STATISTICS = 2;
//- handling of timed out events from the callbacks -
+ /** The System property that states the duration at which the timeout handler runs */
+ public static final String TIMEOUT_HANDLER_INTERVAL = "synapse.timeout_handler_interval";
+
/**
* Interval for activating the timeout handler for cleaning up expired requests. Note that
* there can be an error as large as the value of the interval. But for smaller intervals
* and larger timeouts this error is negligable.
*/
- public static final long TIMEOUT_HANDLER_INTERVAL = 1000;
+ public static final long DEFAULT_TIMEOUT_HANDLER_INTERVAL = 15000;
+
+ /**
+ * This is a system wide interval for handling otherwise non-expiring callbacks to
+ * ensure system stability over a period of time
+ */
+ public static final String GLOBAL_TIMEOUT_INTERVAL = "synapse.global_timeout_interval";
+
+ /**
+ * this is the timeout for otherwise non-expiring callbacks
+ * to ensure system stability over time
+ */
+ public static final long DEFAULT_GLOBAL_TIMEOUT = 24 * 60 * 60 * 1000;
/**
* don't do anything for response timeouts. this means infinite timeout. this is the default
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java Mon Oct 1 20:27:24 2007
@@ -39,7 +39,7 @@
/**
* Creates a ProxyService instance using the XML fragment specification
* <p/>
- * <proxy-service name="string" [transports="(http |https |jms )+|all"]>
+ * <proxy-service name="string" [transports="(http |https |jms )+|all"] [trace="enable|disable"]>
* <description>..</description>?
* <target [inSequence="name"] [outSequence="name"] [faultSequence="name"] [endpoint="name"]>
* <endpoint>...</endpoint>
@@ -81,9 +81,9 @@
String statisticsValue = statistics.getAttributeValue();
if (statisticsValue != null) {
if (XMLConfigConstants.STATISTICS_ENABLE.equals(statisticsValue)) {
- proxy.setStatisticsEnable(org.apache.synapse.SynapseConstants.STATISTICS_ON);
+ proxy.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_ON);
} else if (XMLConfigConstants.STATISTICS_DISABLE.equals(statisticsValue)) {
- proxy.setStatisticsEnable(org.apache.synapse.SynapseConstants.STATISTICS_OFF);
+ proxy.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_OFF);
}
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java Mon Oct 1 20:27:24 2007
@@ -205,7 +205,7 @@
proxy.addChild(fac.createOMElement("enableSec", synNS));
}
- int isEnableStatistics = service.getStatisticsEnable();
+ int isEnableStatistics = service.getStatisticsState();
String statisticsValue = null;
if (isEnableStatistics == org.apache.synapse.SynapseConstants.STATISTICS_ON) {
statisticsValue = XMLConfigConstants.STATISTICS_ENABLE;
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AnonymousServiceFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AnonymousServiceFactory.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AnonymousServiceFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AnonymousServiceFactory.java Mon Oct 1 20:27:24 2007
@@ -47,7 +47,7 @@
private static final String SEC_AND_ADDR = "__SEC_AND_ADDR__";
private static final String RM_SEC_AND_ADDR = "__RM_SEC_AND_ADDR__";
- public static final String OUT_IN_OPERATION = "__OUT_IN_OPERATION__";
+ public static final String OUT_IN_OPERATION = "__OUT_IN_OPERATION__";
public static final String OUT_ONLY_OPERATION = "__OUT_ONLY_OPERATION__";
private static SynapseCallbackReceiver synapseCallbackReceiver = null;
@@ -165,12 +165,17 @@
return null;
}
- private static SynapseCallbackReceiver getCallbackReceiver(SynapseConfiguration synCfg) {
+ /**
+ * Create a single callback receiver if required, and return its reference
+ * @param synCfg the Synapse configuration
+ * @return the callback receiver thats created or now exists
+ */
+ private static synchronized SynapseCallbackReceiver getCallbackReceiver(
+ SynapseConfiguration synCfg) {
+
if (synapseCallbackReceiver == null) {
synapseCallbackReceiver = new SynapseCallbackReceiver(synCfg);
}
-
return synapseCallbackReceiver;
}
-
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AsyncCallback.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AsyncCallback.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AsyncCallback.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AsyncCallback.java Mon Oct 1 20:27:24 2007
@@ -21,8 +21,8 @@
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.client.async.AsyncResult;
-import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseConstants;
+import org.apache.synapse.MessageContext;
/**
* This class only "holds" the Synapse out message context for the Synapse callback message
@@ -30,20 +30,16 @@
*/
public class AsyncCallback extends Callback {
+ /** The corresponding Synapse outgoing message context this instance is holding onto */
MessageContext synapseOutMsgCtx = null;
- /**
- * Time to timeout this callback.
- */
+ /** Time to timeout this callback */
private long timeOutOn;
- /**
- * Action to perform when timeout occurs.
- */
+ /** Action to perform when timeout occurs */
private int timeOutAction = SynapseConstants.NONE;
-
- public AsyncCallback(org.apache.synapse.MessageContext synapseOutMsgCtx) {
+ public AsyncCallback(MessageContext synapseOutMsgCtx) {
this.synapseOutMsgCtx = synapseOutMsgCtx;
}
@@ -51,11 +47,7 @@
public void onError(Exception e) {}
- public void setSynapseOutMshCtx(MessageContext synapseOutMsgCtx) {
- this.synapseOutMsgCtx = synapseOutMsgCtx;
- }
-
- public MessageContext getSynapseOutMsgCtx() {
+ public org.apache.synapse.MessageContext getSynapseOutMsgCtx() {
return synapseOutMsgCtx;
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java Mon Oct 1 20:27:24 2007
@@ -68,12 +68,11 @@
* the Axis2 message context for the response.
*
* Here Synapse works as a Client to the service. It would expect 200 ok, 202 ok and
- * 500 internal server error as possible responses. Currently the code expects
- * Synchronus operation
+ * 500 internal server error as possible responses.
*
- * @param endpoint
- * @param synapseOutMessageContext
- * @return The Axis2 reponse message context
+ * @param endpoint the endpoint being sent to, maybe null
+ * @param synapseOutMessageContext the outgoing synapse message
+ * @throws AxisFault on errors
*/
public static void send(
@@ -98,7 +97,7 @@
if (log.isDebugEnabled()) {
log.debug(
- "sending [add = " + wsAddressingEnabled +
+ "Sending [add = " + wsAddressingEnabled +
"] [sec = " + wsSecurityEnabled +
"] [rm = " + wsRMEnabled +
(endpoint != null ?
@@ -122,6 +121,7 @@
if (endpoint.isForcePOX()) {
axisOutMsgCtx.setDoingREST(true);
+
} else if (endpoint.isForceSOAP()) {
axisOutMsgCtx.setDoingREST(false);
if (axisOutMsgCtx.getSoapAction() == null && axisOutMsgCtx.getWSAAction() != null) {
@@ -194,9 +194,6 @@
getPolicy(synapseOutMessageContext, wsRMPolicyKey));
}
copyRMOptions(originalInMsgCtx, clientOptions);
-
- // always send each and every message in a new sequence and terminate sequence
- //clientOptions.setProperty("Sandesha2LastMessage", "true");
}
// if security is enabled,
@@ -297,19 +294,19 @@
private static void copyRMOptions(MessageContext oriContext, Options targetOptions) {
Options oriOptions = oriContext.getOptions();
- if(oriOptions.getProperty(SynapseConstants.SANDESHA_LAST_MESSAGE) != null) {
+ if (oriOptions.getProperty(SynapseConstants.SANDESHA_LAST_MESSAGE) != null) {
targetOptions.setProperty(SynapseConstants.SANDESHA_LAST_MESSAGE,
oriOptions.getProperty(SynapseConstants.SANDESHA_LAST_MESSAGE));
}
- if(oriOptions.getProperty(SynapseConstants.SANDESHA_SPEC_VERSION) != null) {
+ if (oriOptions.getProperty(SynapseConstants.SANDESHA_SPEC_VERSION) != null) {
targetOptions.setProperty(SynapseConstants.SANDESHA_SPEC_VERSION,
oriOptions.getProperty(SynapseConstants.SANDESHA_SPEC_VERSION));
}
- if(oriOptions.getProperty(SynapseConstants.SANDESHA_SEQUENCE_KEY) != null) {
+ if (oriOptions.getProperty(SynapseConstants.SANDESHA_SEQUENCE_KEY) != null) {
targetOptions.setProperty(SynapseConstants.SANDESHA_SEQUENCE_KEY,
oriOptions.getProperty(SynapseConstants.SANDESHA_SEQUENCE_KEY));
}
- if(oriOptions.getProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID) != null) {
+ if (oriOptions.getProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID) != null) {
targetOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,
oriOptions.getProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID));
}
@@ -326,7 +323,7 @@
if (property != null && property instanceof OMElement) {
return PolicyEngine.getPolicy((OMElement) property);
} else {
- handleException("Cannot locate Policy from the property : " + propertyKey);
+ handleException("Cannot locate policy from the property : " + propertyKey);
}
return null;
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2MessageContext.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2MessageContext.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2MessageContext.java Mon Oct 1 20:27:24 2007
@@ -82,6 +82,9 @@
/** Attribute of MC stating the tracing state of the message */
private int tracingState = SynapseConstants.TRACING_UNSET;
+ /** The service log for this message */
+ private Log serviceLog = null;
+
public SynapseConfiguration getConfiguration() {
return synCfg;
}
@@ -342,14 +345,29 @@
* @return the service level Log for the message
*/
public Log getServiceLog() {
- String serviceName = (String) getProperty(SynapseConstants.PROXY_SERVICE);
- if (serviceName != null && synCfg.getProxyService(serviceName) != null) {
- return LogFactory.getLog(SynapseConstants.SERVICE_LOGGER_PREFIX + serviceName);
+
+ if (serviceLog != null) {
+ return serviceLog;
} else {
- return LogFactory.getLog(Axis2MessageContext.class);
+ String serviceName = (String) getProperty(SynapseConstants.PROXY_SERVICE);
+ if (serviceName != null && synCfg.getProxyService(serviceName) != null) {
+ serviceLog = LogFactory.getLog(SynapseConstants.SERVICE_LOGGER_PREFIX + serviceName);
+ return serviceLog;
+ } else {
+ serviceLog = LogFactory.getLog(Axis2MessageContext.class);
+ return serviceLog;
+ }
}
}
+ /**
+ * Set the service log
+ * @param serviceLog
+ */
+ public void setServiceLog(Log serviceLog) {
+ this.serviceLog = serviceLog;
+ }
+
public org.apache.axis2.context.MessageContext getAxis2MessageContext() {
return axis2MessageContext;
}
@@ -491,4 +509,6 @@
return sb.toString();
}
+
+
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java Mon Oct 1 20:27:24 2007
@@ -20,6 +20,7 @@
package org.apache.synapse.core.axis2;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
import org.apache.axis2.util.Utils;
import org.apache.axis2.transport.nhttp.NhttpConstants;
import org.apache.axis2.context.MessageContext;
@@ -42,32 +43,39 @@
private static final Log log = LogFactory.getLog(Axis2Sender.class);
- public static void sendOn(
- EndpointDefinition endpoint,
- org.apache.synapse.MessageContext synapseInMessageContext) {
+ /**
+ * Send a message out from the Synapse engine to an external service
+ * @param endpoint the endpoint definition where the message should be sent
+ * @param synapseInMessageContext the Synapse message context
+ */
+ public static void sendOn(EndpointDefinition endpoint,
+ org.apache.synapse.MessageContext synapseInMessageContext) {
try {
- Axis2FlexibleMEPClient.send(
- // The endpoint where we are sending to
- endpoint,
-
- // The Axis2 Message context of the Synapse MC
- synapseInMessageContext);
+ Axis2FlexibleMEPClient.send(
+ // The endpoint where we are sending to
+ endpoint,
+ // The Axis2 Message context of the Synapse MC
+ synapseInMessageContext);
} catch (Exception e) {
- handleException("Unexpected error during Sending message onwards", e);
+ handleException("Unexpected error during sending message out", e);
}
}
+ /**
+ * Send a response back to a client of Synapse
+ * @param smc the Synapse message context sent as the response
+ */
public static void sendBack(org.apache.synapse.MessageContext smc) {
MessageContext messageContext = ((Axis2MessageContext) smc).getAxis2MessageContext();
// if this is a dummy 202 Accepted message meant only for the http/s transports
// prevent it from going into any other transport sender
- if (Utils.isExplicitlyTrue(messageContext, NhttpConstants.SC_ACCEPTED) &&
+ if (messageContext.isPropertyTrue(NhttpConstants.SC_ACCEPTED) &&
messageContext.getTransportOut() != null &&
- !messageContext.getTransportOut().getName().startsWith("http")) {
+ !messageContext.getTransportOut().getName().startsWith(Constants.TRANSPORT_HTTP)) {
return;
}
@@ -96,7 +104,7 @@
ae.send(messageContext);
} catch (AxisFault e) {
- handleException("Unexpected error during Sending message back", e);
+ handleException("Unexpected error sending message back", e);
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java Mon Oct 1 20:27:24 2007
@@ -42,20 +42,19 @@
public class Axis2SynapseEnvironment implements SynapseEnvironment {
private static final Log log = LogFactory.getLog(Axis2SynapseEnvironment.class);
- private int threadPoolSize = 10;
+
private SynapseConfiguration synapseConfig;
private ConfigurationContext configContext;
- /**
- * The StatisticsCollector object
- */
+
+ /** The StatisticsCollector object */
private StatisticsCollector statisticsCollector;
- public Axis2SynapseEnvironment() {
- }
+ public Axis2SynapseEnvironment() {}
public Axis2SynapseEnvironment(ConfigurationContext cfgCtx,
- SynapseConfiguration synapseConfig) {
- this.configContext = cfgCtx;
+ SynapseConfiguration synapseConfig) {
+
+ this.configContext = cfgCtx;
this.synapseConfig = synapseConfig;
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/MessageContextCreatorForAxis2.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/MessageContextCreatorForAxis2.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/MessageContextCreatorForAxis2.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/MessageContextCreatorForAxis2.java Mon Oct 1 20:27:24 2007
@@ -34,7 +34,7 @@
*/
public class MessageContextCreatorForAxis2 {
- private static Log log = LogFactory.getLog(MessageContextCreatorForAxis2.class);
+ private static final Log log = LogFactory.getLog(MessageContextCreatorForAxis2.class);
private static SynapseConfiguration synCfg = null;
private static SynapseEnvironment synEnv = null;
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java Mon Oct 1 20:27:24 2007
@@ -45,7 +45,7 @@
import java.net.*;
/**
- * <proxy-service name="string" [transports="(http |https |jms )+|all"]>
+ * <proxy-service name="string" [transports="(http |https |jms )+|all"] [trace="enable|disable"]>
* <description>..</description>?
* <target [inSequence="name"] [outSequence="name"] [faultSequence="name"] [endpoint="name"]>
* <endpoint>...</endpoint>
@@ -157,7 +157,7 @@
/**
* To decide to whether statistics should have collected or not
*/
- private int statisticsEnable = SynapseConstants.STATISTICS_UNSET;
+ private int statisticsState = SynapseConstants.STATISTICS_UNSET;
/**
* The variable that indicate tracing on or off for the current mediator
*/
@@ -222,7 +222,7 @@
// serialize and create an inputstream to read WSDL
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
- if (trace()) trace.info("Serializing wsdlElement found to build Axis service");
+ if (trace()) trace.info("Serializing wsdlElement found to build an Axis2 service");
wsdlElement.serialize(baos);
wsdlInputStream = new ByteArrayInputStream(baos.toByteArray());
} catch (XMLStreamException e) {
@@ -233,7 +233,7 @@
try {
// detect version of the WSDL 1.1 or 2.0
- if (trace()) trace.info("WSDL Namespace is : " + wsdlNamespace);
+ if (trace()) trace.info("WSDL Namespace is : " + wsdlNamespace.getNamespaceURI());
if (wsdlNamespace != null) {
boolean isWSDL11 = false;
@@ -260,7 +260,7 @@
}
if (trace()) {
- trace.info("Populating Axis service using WSDL");
+ trace.info("Populating Axis2 service using WSDL");
if (trace.isTraceEnabled()) {
trace.trace("WSDL : " + wsdlElement.toString());
}
@@ -343,7 +343,7 @@
}
}
- if (trace()) trace.info("Seeting service level policies : " + serviceLevelPolicies);
+ if (trace()) trace.info("Setting service level policies : " + serviceLevelPolicies);
// if service level policies are specified, apply them
if (!serviceLevelPolicies.isEmpty()) {
@@ -378,6 +378,7 @@
// create a custom message receiver for this proxy service
ProxyServiceMessageReceiver msgRcvr = new ProxyServiceMessageReceiver();
msgRcvr.setName(name);
+ msgRcvr.setProxy(this);
iter = proxyService.getOperations();
while (iter.hasNext()) {
@@ -386,7 +387,7 @@
}
try {
- auditInfo("Adding service " + name + "to the Axis2 configuration");
+ auditInfo("Adding service " + name + " to the Axis2 configuration");
axisCfg.addService(proxyService);
this.setRunning(true);
} catch (AxisFault axisFault) {
@@ -618,17 +619,17 @@
*
* @return Returns the int value that indicate statistics is enabled or not.
*/
- public int getStatisticsEnable() {
- return statisticsEnable;
+ public int getStatisticsState() {
+ return statisticsState;
}
/**
* To set the statistics enable variable value
*
- * @param statisticsEnable
+ * @param statisticsState
*/
- public void setStatisticsEnable(int statisticsEnable) {
- this.statisticsEnable = statisticsEnable;
+ public void setStatisticsState(int statisticsState) {
+ this.statisticsState = statisticsState;
}
/**
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java Mon Oct 1 20:27:24 2007
@@ -35,154 +35,141 @@
private static final Log log = LogFactory.getLog(ProxyServiceMessageReceiver.class);
private static final Log trace = LogFactory.getLog(SynapseConstants.TRACE_LOGGER);
- /**
- * The name of the Proxy Service
- */
+ /** The name of the Proxy Service */
private String name = null;
+ /** The proxy service */
+ private ProxyService proxy = null;
public void receive(org.apache.axis2.context.MessageContext mc) throws AxisFault {
- if (log.isDebugEnabled()) {
- log.debug("Proxy Service " + name + " received a new message...");
- log.debug("Message To: " + (mc.getTo() != null ? mc.getTo().getAddress() : "null"));
- log.debug("SOAPAction: " + (mc.getSoapAction() != null ? mc.getSoapAction() : "null"));
- log.debug("WSA-Action: " + (mc.getWSAAction() != null ? mc.getWSAAction() : "null"));
- String[] cids = mc.getAttachmentMap().getAllContentIDs();
- if (cids != null && cids.length > 0) {
- for (int i = 0; i < cids.length; i++) {
- log.debug("Attachment : " + cids[i]);
+ boolean traceOn = proxy.getTraceState() == SynapseConstants.TRACING_ON;
+ boolean traceOrDebugOn = traceOn || log.isDebugEnabled();
+
+ String remoteAddr = (String) mc.getProperty(
+ org.apache.axis2.context.MessageContext.REMOTE_ADDR);
+
+ if (traceOrDebugOn) {
+ traceOrDebug(traceOn, "Proxy Service " + name + " received a new message" +
+ (remoteAddr != null ? " from : " + remoteAddr : "..."));
+ traceOrDebug(traceOn, ("Message To: " +
+ (mc.getTo() != null ? mc.getTo().getAddress() : "null")));
+ traceOrDebug(traceOn, ("SOAPAction: " +
+ (mc.getSoapAction() != null ? mc.getSoapAction() : "null")));
+ traceOrDebug(traceOn, ("WSA-Action: " +
+ (mc.getWSAAction() != null ? mc.getWSAAction() : "null")));
+
+ if (traceOn && trace.isTraceEnabled()) {
+ String[] cids = mc.getAttachmentMap().getAllContentIDs();
+ if (cids != null && cids.length > 0) {
+ for (int i = 0; i < cids.length; i++) {
+ trace.trace("With attachment content ID : " + cids[i]);
+ }
}
+ trace.trace("Envelope : " + mc.getEnvelope());
}
- log.debug("Body : \n" + mc.getEnvelope());
}
MessageContext synCtx = MessageContextCreatorForAxis2.getSynapseMessageContext(mc);
+ // get service log for this message and attach to the message context also set proxy name
+ Log serviceLog = LogFactory.getLog(SynapseConstants.SERVICE_LOGGER_PREFIX + name);
+ ((Axis2MessageContext) synCtx).setServiceLog(serviceLog);
+
+ synCtx.setProperty(SynapseConstants.PROXY_SERVICE, name);
+ synCtx.setTracingState(proxy.getTraceState());
+
try {
- synCtx.setProperty(org.apache.synapse.SynapseConstants.PROXY_SERVICE, name);
- ProxyService proxy = synCtx.getConfiguration().getProxyService(name);
+ // Setting property to collect the proxy service statistics
+ boolean statsOn = (SynapseConstants.STATISTICS_ON == proxy.getStatisticsState());
+ if (statsOn) {
+ ProxyServiceStatisticsStack proxyServiceStatisticsStack
+ = new ProxyServiceStatisticsStack();
+ boolean isFault = synCtx.getEnvelope().getBody().hasFault();
+ proxyServiceStatisticsStack.put(name, System.currentTimeMillis(),
+ !synCtx.isResponse(), statsOn, isFault);
+ synCtx.setProperty(SynapseConstants.PROXY_STATS,
+ proxyServiceStatisticsStack);
+ }
- // Setting Required property to collect the proxy service statistics
- boolean statisticsEnable;
- if (proxy != null) {
- statisticsEnable = (
- org.apache.synapse.SynapseConstants.STATISTICS_ON == proxy.getStatisticsEnable());
- if (statisticsEnable) {
- ProxyServiceStatisticsStack proxyServiceStatisticsStack
- = new ProxyServiceStatisticsStack();
- boolean isFault = synCtx.getEnvelope().getBody().hasFault();
- proxyServiceStatisticsStack.put(name, System.currentTimeMillis(),
- !synCtx.isResponse(), statisticsEnable, isFault);
- synCtx.setProperty(org.apache.synapse.SynapseConstants.PROXYSERVICE_STATISTICS_STACK,
- proxyServiceStatisticsStack);
- }
- boolean shouldTrace = (proxy.getTraceState() == SynapseConstants.TRACING_ON);
- if (shouldTrace) {
- trace.trace("Proxy Service " + name + " received a new message...");
- trace.trace("Received Message :: " + mc.getEnvelope());
- }
- if (proxy.getTargetFaultSequence() != null) {
+ // setup fault sequence - i.e. what happens when something goes wrong with this message
+ if (proxy.getTargetFaultSequence() != null) {
- Mediator faultSequence = synCtx.getSequence(proxy.getTargetFaultSequence());
- if (faultSequence != null) {
- if (log.isDebugEnabled()) {
- log.debug("Setting the fault-sequence of the " +
- "proxy service to MessageContext");
- }
- synCtx.pushFaultHandler(new MediatorFaultHandler(
- synCtx.getSequence(proxy.getTargetFaultSequence())));
- } else {
- // when we can not find the reference to the fault sequence of the proxy
- // service we should not throw an exception because still we have the global
- // fault sequence and the message mediation can still continue
- log.warn("Unable to find the fault-sequence for the proxy service " +
- "specified by the name " + proxy.getTargetFaultSequence());
- }
- } else if (proxy.getTargetInLineFaultSequence() != null) {
- if (log.isDebugEnabled()) {
- log.debug("Setting the anonymous fault-sequence of the proxy to context");
- }
- synCtx.pushFaultHandler(
- new MediatorFaultHandler(proxy.getTargetInLineFaultSequence()));
+ Mediator faultSequence = synCtx.getSequence(proxy.getTargetFaultSequence());
+ if (faultSequence != null) {
+ if (traceOrDebugOn) {
+ traceOrDebug(traceOn,
+ "Setting the fault-sequence to : " + faultSequence);
+ }
+ synCtx.pushFaultHandler(new MediatorFaultHandler(
+ synCtx.getSequence(proxy.getTargetFaultSequence())));
+
+ } else {
+ // when we can not find the reference to the fault sequence of the proxy
+ // service we should not throw an exception because still we have the global
+ // fault sequence and the message mediation can still continue
+ traceOrDebug(traceOn, "Unable to find fault-sequence : " +
+ proxy.getTargetFaultSequence() + "; using default fault sequence");
+ synCtx.pushFaultHandler(new MediatorFaultHandler(
+ synCtx.getSequence(SynapseConstants.FAULT_SEQUENCE_KEY)));
+ }
+
+ } else if (proxy.getTargetInLineFaultSequence() != null) {
+ if (traceOrDebugOn) {
+ traceOrDebug(traceOn, "Setting specified anonymous fault-sequence for proxy");
}
+ synCtx.pushFaultHandler(
+ new MediatorFaultHandler(proxy.getTargetInLineFaultSequence()));
+ }
- // Using inSequence for the incoming message mediation
- if (proxy.getTargetInSequence() != null) {
- Mediator inSequence = synCtx.getSequence(proxy.getTargetInSequence());
- if (inSequence != null) {
- String msg = "Using the sequence named "
- + proxy.getTargetInSequence() + " for message mediation";
- if (shouldTrace) {
- trace.trace(msg);
- }
- if (log.isDebugEnabled()) {
- log.debug(msg);
- }
- inSequence.mediate(synCtx);
- } else {
-
- log.error("Unable to find the in-sequence for the proxy service " +
- "specified by the name " + proxy.getTargetInSequence());
- throw new SynapseException("Unable to find the in-sequence for the proxy " +
- "service specified by the name " + proxy.getTargetInSequence());
- }
- } else if (proxy.getTargetInLineInSequence() != null) {
- String msg = "Using the anonymous " +
- "in-sequence of the proxy service for message mediation";
- if (shouldTrace) {
- trace.trace(msg);
- }
- if (log.isDebugEnabled()) {
- log.debug(msg);
- }
- proxy.getTargetInLineInSequence().mediate(synCtx);
- }
+ // Using inSequence for the incoming message mediation
+ if (proxy.getTargetInSequence() != null) {
- if (proxy.getTargetEndpoint() != null) {
- Endpoint endpoint = synCtx.getEndpoint(proxy.getTargetEndpoint());
- if (endpoint != null) {
- String msg = "Forwarding message to the endpoint named "
- + proxy.getTargetEndpoint() + " after message mediation";
- if (shouldTrace) {
- trace.trace(msg);
- }
- if (log.isDebugEnabled()) {
- log.debug(msg);
- }
- endpoint.send(synCtx);
- } else {
-
- log.error("Unable to find the endpoint for the proxy service " +
- "specified by the name " + proxy.getTargetEndpoint());
- throw new SynapseException("Unable to find the endpoint for the " +
- "proxy service specified by the name " + proxy.getTargetEndpoint());
- }
- } else if (proxy.getTargetInLineEndpoint() != null) {
- String msg = "Forwarding the message to the anonymous " +
- "endpoint of the proxy service after message mediation";
- if (shouldTrace) {
- trace.trace(msg);
- }
- if (log.isDebugEnabled()) {
- log.debug(msg);
- }
- proxy.getTargetInLineEndpoint().send(synCtx);
- }
+ Mediator inSequence = synCtx.getSequence(proxy.getTargetInSequence());
+ if (inSequence != null) {
+ traceOrDebug(traceOn, "Using sequence named : "
+ + proxy.getTargetInSequence() + " for incoming message mediation");
+ inSequence.mediate(synCtx);
+
+ } else {
+ handleException("Unable to find in-sequence : " + proxy.getTargetInSequence(), synCtx);
+ }
+
+ } else if (proxy.getTargetInLineInSequence() != null) {
+ traceOrDebug(traceOn, "Using the anonymous " +
+ "in-sequence of the proxy service for mediation");
+ proxy.getTargetInLineInSequence().mediate(synCtx);
+ }
- } else {
- log.error("Proxy Service with the name " + name + " does not exists");
- throw new SynapseException(
- "Proxy Service with the name " + name + " does not exists");
+ if (proxy.getTargetEndpoint() != null) {
+ Endpoint endpoint = synCtx.getEndpoint(proxy.getTargetEndpoint());
+
+ if (endpoint != null) {
+ traceOrDebug(traceOn, "Forwarding message to the endpoint : "
+ + proxy.getTargetEndpoint());
+ endpoint.send(synCtx);
+
+ } else {
+ handleException("Unable to find the endpoint specified : " +
+ proxy.getTargetEndpoint(), synCtx);
+ }
+
+ } else if (proxy.getTargetInLineEndpoint() != null) {
+ traceOrDebug(traceOn, "Forwarding the message to the anonymous " +
+ "endpoint of the proxy service");
+ proxy.getTargetInLineEndpoint().send(synCtx);
}
+
} catch (SynapseException syne) {
+
if (!synCtx.getFaultStack().isEmpty()) {
+ warn(traceOn, "Executing fault handler due to exception encountered", synCtx);
((FaultHandler) synCtx.getFaultStack().pop()).handleFault(synCtx, syne);
+
} else {
- log.error("Synapse encountered an exception, " +
- "No error handlers found - [Message Dropped]\n" + syne.getMessage());
+ warn(traceOn, "Exception encountered but no fault handler found - " +
+ "message dropped", synCtx);
}
}
-
}
/**
@@ -192,6 +179,46 @@
*/
public void setName(String name) {
this.name = name;
+ }
+
+ /**
+ * Set reference to actual proxy service
+ * @param proxy
+ */
+ public void setProxy(ProxyService proxy) {
+ this.proxy = proxy;
+ }
+
+ private void traceOrDebug(boolean traceOn, String msg) {
+ if (traceOn) {
+ trace.info(msg);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(msg);
+ }
+ }
+
+ private void warn(boolean traceOn, String msg, MessageContext msgContext) {
+ if (traceOn) {
+ trace.warn(msg);
+ }
+ if (log.isDebugEnabled()) {
+ log.warn(msg);
+ }
+ if (msgContext.getServiceLog() != null) {
+ msgContext.getServiceLog().warn(msg);
+ }
+ }
+
+ private void handleException(String msg, MessageContext msgContext) {
+ log.error(msg);
+ if (msgContext.getServiceLog() != null) {
+ msgContext.getServiceLog().error(msg);
+ }
+ if (proxy.getTraceState() == SynapseConstants.TRACING_ON) {
+ trace.error(msg);
+ }
+ throw new SynapseException(msg);
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java Mon Oct 1 20:27:24 2007
@@ -27,10 +27,10 @@
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.addressing.RelatesTo;
import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.client.Options;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.transport.nhttp.NhttpConstants;
-import org.apache.axis2.util.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.sandesha2.client.SandeshaClientConstants;
@@ -42,32 +42,70 @@
import java.util.*;
+/**
+ * This is the message receiver that receives the responses for outgoing messages sent out
+ * by Synapse. It holds a callbackStore that maps the [unique] messageID of each message to
+ * a callback object that gets executed on timeout or when a response is recived (before timeout)
+ *
+ * The AnonymousServiceFactory uses this MessageReceiver for all Anonymous services created by it.
+ * This however - effectively - is a singleton class
+ */
public class SynapseCallbackReceiver implements MessageReceiver {
private static final Log log = LogFactory.getLog(SynapseCallbackReceiver.class);
+ /** This is the synchronized callbackStore that maps outgoing messageID's to callback objects */
private Map callbackStore; // this will be made thread safe within the constructor
+ /**
+ * Create the *single* instance of this class that would be used by all anonymous services
+ * used for outgoing messaging.
+ * @param synCfg the Synapse configuration
+ */
public SynapseCallbackReceiver(SynapseConfiguration synCfg) {
+
callbackStore = Collections.synchronizedMap(new HashMap());
- // create the Timer object and a TimeoutHandler task. Schedule it to run every 10 seconds from here
+ // create the Timer object and a TimeoutHandler task
TimeoutHandler timeoutHandler = new TimeoutHandler(callbackStore);
Timer timeOutTimer = synCfg.getSynapseTimer();
- timeOutTimer.schedule(timeoutHandler, 0, SynapseConstants.TIMEOUT_HANDLER_INTERVAL);
+ long timeoutHandlerInterval = SynapseConstants.DEFAULT_TIMEOUT_HANDLER_INTERVAL;
+ try {
+ timeoutHandlerInterval = Long.parseLong(
+ System.getProperty(SynapseConstants.TIMEOUT_HANDLER_INTERVAL));
+ } catch (Exception ignore) {}
+
+ // schedule timeout handler to run every n seconds (n : specified or defaults to 15s)
+ timeOutTimer.schedule(timeoutHandler, 0, timeoutHandlerInterval);
}
+
public void addCallback(String MsgID, Callback callback) {
callbackStore.put(MsgID, callback);
}
+ /**
+ * Everytime a response message is received this method gets invoked. It will then select
+ * the outgoing *Synapse* message context for the reply we received, and determine what action
+ * to take at the Synapse level
+ *
+ * @param messageCtx the Axis2 message context of the reply received
+ * @throws AxisFault
+ */
public void receive(MessageContext messageCtx) throws AxisFault {
String messageID = null;
if (messageCtx.getOptions() != null && messageCtx.getOptions().getRelatesTo() != null) {
- messageID = messageCtx.getOptions().getRelatesTo().getValue();
+ // never take a chance with a NPE at this stage.. so check at each level :-)
+ Options options = messageCtx.getOptions();
+ if (options != null) {
+ RelatesTo relatesTo = options.getRelatesTo();
+ if (relatesTo != null) {
+ messageID = relatesTo.getValue();
+ }
+ }
} else if (messageCtx.getProperty(SandeshaClientConstants.SEQUENCE_KEY) == null) {
messageID = (String) messageCtx.getProperty(SynapseConstants.RELATES_TO_FOR_POX);
}
@@ -85,13 +123,14 @@
if (callback != null) {
handleMessage(messageCtx, ((AsyncCallback) callback).getSynapseOutMsgCtx());
+
} else {
// TODO invoke a generic synapse error handler for this message
log.warn("Synapse received a response for the request with message Id : " +
messageID + " But a callback has not been registered to process this response");
}
- } else if (!Utils.isExplicitlyTrue(messageCtx, NhttpConstants.SC_ACCEPTED)){
+ } else if (!messageCtx.isPropertyTrue(NhttpConstants.SC_ACCEPTED)){
// TODO invoke a generic synapse error handler for this message
log.warn("Synapse received a response message without a message Id");
}
@@ -209,6 +248,7 @@
synapseInMessageContext.setResponse(true);
synapseInMessageContext.setTo(
new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL));
+ synapseInMessageContext.setTracingState(synapseOutMsgCtx.getTracingState());
// set the properties of the original MC to the new MC
Iterator iter = synapseOutMsgCtx.getPropertyKeySet().iterator();
@@ -235,6 +275,14 @@
}
}
+ /**
+ * It is possible for us (Synapse) to cause the creation of a duplicate relatesTo as we
+ * try to hold onto the outgoing message ID even for POX messages using the relates to
+ * Now once we get a response, make sure we remove any trace of this before we proceed any
+ * further
+ * @param mc the message context from which a possibly duplicated relatesTo should be removed
+ * @param relates the existing relatedTo array of the message
+ */
private void removeDuplicateRelatesTo(MessageContext mc, RelatesTo[] relates) {
int insertPos = 0;
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseDispatcher.java Mon Oct 1 20:27:24 2007
@@ -26,8 +26,7 @@
import org.apache.axis2.description.HandlerDescription;
import org.apache.axis2.engine.AbstractDispatcher;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseConstants;
import javax.xml.namespace.QName;
@@ -37,14 +36,6 @@
*/
public class SynapseDispatcher extends AbstractDispatcher {
- private static final Log log = LogFactory.getLog(SynapseDispatcher.class);
-
- private static final long serialVersionUID = -6970206989111592645L;
-
- private static final String SYNAPSE_SERVICE_NAME = "synapse";
-
- private static final QName MEDIATE_OPERATION_NAME = new QName("mediate");
-
public void initDispatcher() {
QName qn = new QName("http://synapse.apache.org", "SynapseDispatcher");
HandlerDescription hd = new HandlerDescription(qn.getLocalPart());
@@ -53,12 +44,12 @@
public AxisService findService(MessageContext mc) throws AxisFault {
AxisConfiguration ac = mc.getConfigurationContext().getAxisConfiguration();
- AxisService as = ac.getService(SYNAPSE_SERVICE_NAME);
+ AxisService as = ac.getService(SynapseConstants.SYNAPSE_SERVICE_NAME);
return as;
}
public AxisOperation findOperation(AxisService svc, MessageContext mc) throws AxisFault {
- AxisOperation ao = svc.getOperation(MEDIATE_OPERATION_NAME);
+ AxisOperation ao = svc.getOperation(SynapseConstants.SYNAPSE_OPERATION_NAME);
return ao;
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java Mon Oct 1 20:27:24 2007
@@ -20,6 +20,7 @@
package org.apache.synapse.core.axis2;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.*;
import org.apache.axis2.engine.AxisConfiguration;
@@ -34,12 +35,12 @@
import org.apache.synapse.config.SynapseConfiguration;
import org.apache.synapse.config.SynapseConfigurationBuilder;
-import javax.xml.namespace.QName;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
+import java.util.Date;
/**
* This is the Synapse Module implementation class, which would initialize Synapse when it is
@@ -48,14 +49,12 @@
public class SynapseInitializationModule implements Module {
private static final Log log = LogFactory.getLog(SynapseInitializationModule.class);
-
- private static final String SYNAPSE_SERVICE_NAME = "synapse";
- private static final QName MEDIATE_OPERATION_Q_NAME = new QName("mediate");
private SynapseConfiguration synCfg;
public void init(ConfigurationContext configurationContext,
AxisModule axisModule) throws AxisFault {
+ log.info("Initializing Synapse at : " + new Date());
try {
InetAddress addr = InetAddress.getLocalHost();
if (addr != null) {
@@ -73,10 +72,11 @@
MDC.put("host", hostname);
}
} catch (UnknownHostException e) {
- log.warn("Unable to report hostname or IP address for tracing", e);
+ log.warn("Unable to determine hostname or IP address of the server for logging", e);
}
// this will deploy the mediators in the mediator extensions folder
+ log.info("Loading mediator extensions...");
configurationContext.getAxisConfiguration().getConfigurator().loadServices();
// Initializing the SynapseEnvironment and SynapseConfiguration
@@ -86,13 +86,13 @@
log.info("Deploying the Synapse service..");
// Dynamically initialize the Synapse Service and deploy it into Axis2
AxisConfiguration axisCfg = configurationContext.getAxisConfiguration();
- AxisService synapseService = new AxisService(SYNAPSE_SERVICE_NAME);
- AxisOperation mediateOperation = new InOutAxisOperation(MEDIATE_OPERATION_Q_NAME);
+ AxisService synapseService = new AxisService(SynapseConstants.SYNAPSE_SERVICE_NAME);
+ AxisOperation mediateOperation = new InOutAxisOperation(SynapseConstants.SYNAPSE_OPERATION_NAME);
mediateOperation.setMessageReceiver(new SynapseMessageReceiver());
synapseService.addOperation(mediateOperation);
List transports = new ArrayList();
- transports.add(org.apache.axis2.Constants.TRANSPORT_HTTP);
- transports.add("https");
+ transports.add(Constants.TRANSPORT_HTTP);
+ transports.add(Constants.TRANSPORT_HTTPS);
synapseService.setExposedTransports(transports);
axisCfg.addService(synapseService);
@@ -109,9 +109,7 @@
while (iter.hasNext()) {
ProxyService proxy = (ProxyService) iter.next();
proxy.buildAxisService(synCfg, axisCfg);
- if (log.isDebugEnabled()) {
- log.debug("Deployed Proxy service : " + proxy.getName());
- }
+ log.info("Deployed Proxy service : " + proxy.getName());
if (!proxy.isStartOnLoad()) {
proxy.stop(synCfg);
}
@@ -132,7 +130,7 @@
if (config != null) {
if (log.isDebugEnabled()) {
log.debug("System property '" + SynapseConstants.SYNAPSE_XML +
- "' specifies synapse configuration as " + config);
+ "' specifies Synapse configuration as " + config);
}
synapseConfiguration = SynapseConfigurationBuilder.getConfiguration(config);
} else {
@@ -169,7 +167,6 @@
// now initialize SynapseConfig
synapseConfiguration.init(synEnv);
-
return synapseConfiguration;
}
@@ -189,6 +186,5 @@
throws AxisFault {
// ignore
synCfg.destroy();
-
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java Mon Oct 1 20:27:24 2007
@@ -26,6 +26,8 @@
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseException;
import org.apache.synapse.FaultHandler;
+import org.apache.synapse.SynapseConstants;
+import org.apache.synapse.mediators.MediatorFaultHandler;
import org.apache.synapse.statistics.StatisticsStack;
import org.apache.synapse.statistics.impl.ProxyServiceStatisticsStack;
@@ -37,47 +39,86 @@
public class SynapseMessageReceiver implements MessageReceiver {
private static final Log log = LogFactory.getLog(SynapseMessageReceiver.class);
+ private static final Log trace = LogFactory.getLog(SynapseConstants.TRACE_LOGGER);
public void receive(org.apache.axis2.context.MessageContext mc) throws AxisFault {
- if (log.isDebugEnabled()) {
- log.debug("Synapse received a new message for message mediation...");
- log.debug("Received To: " + (mc.getTo() != null ? mc.getTo().getAddress() : "null"));
- log.debug("SOAPAction: " + (mc.getSoapAction() != null ? mc.getSoapAction() : "null"));
- log.debug("WSA-Action: " + (mc.getWSAAction() != null ? mc.getWSAAction() : "null"));
- String[] cids = mc.getAttachmentMap().getAllContentIDs();
- if (cids != null && cids.length > 0) {
- for (int i=0; i<cids.length; i++) {
- log.debug("Attachment : " + cids[i]);
+ MessageContext synCtx = MessageContextCreatorForAxis2.getSynapseMessageContext(mc);
+
+ boolean traceOn = synCtx.getMainSequence().getTraceState() == SynapseConstants.TRACING_ON;
+ boolean traceOrDebugOn = traceOn || log.isDebugEnabled();
+
+ if (traceOrDebugOn) {
+ traceOrDebug(traceOn, "Synapse received a new message for message mediation...");
+ traceOrDebug(traceOn, "Received To: " +
+ (mc.getTo() != null ? mc.getTo().getAddress() : "null"));
+ traceOrDebug(traceOn, "SOAPAction: " +
+ (mc.getSoapAction() != null ? mc.getSoapAction() : "null"));
+ traceOrDebug(traceOn, "WSA-Action: " +
+ (mc.getWSAAction() != null ? mc.getWSAAction() : "null"));
+
+ if (traceOn && trace.isTraceEnabled()) {
+ String[] cids = mc.getAttachmentMap().getAllContentIDs();
+ if (cids != null && cids.length > 0) {
+ for (int i=0; i<cids.length; i++) {
+ trace.trace("Attachment : " + cids[i]);
+ }
}
+ trace.trace("Envelope : " + mc.getEnvelope());
}
- log.debug("Body : \n" + mc.getEnvelope());
}
- MessageContext synCtx = MessageContextCreatorForAxis2.getSynapseMessageContext(mc);
+ // get service log for this message and attach to the message context
+ Log serviceLog = LogFactory.getLog(SynapseConstants.SERVICE_LOGGER_PREFIX +
+ SynapseConstants.SYNAPSE_SERVICE_NAME);
+ ((Axis2MessageContext) synCtx).setServiceLog(serviceLog);
+
try {
- StatisticsStack synapseServiceStack =
- (StatisticsStack) synCtx.getProperty(
- org.apache.synapse.SynapseConstants.SYNAPSESERVICE_STATISTICS_STACK);
- if (synapseServiceStack == null) {
- synapseServiceStack = new ProxyServiceStatisticsStack();
- synCtx.setProperty(org.apache.synapse.SynapseConstants.SYNAPSESERVICE_STATISTICS_STACK,
- synapseServiceStack);
- }
- String name = "SynapseService";
+ // set the statistics collection stack for this message
+ StatisticsStack synapseServiceStack = new ProxyServiceStatisticsStack();
boolean isFault = synCtx.getEnvelope().getBody().hasFault();
- synapseServiceStack.put(name, System.currentTimeMillis(), !synCtx.isResponse(),
- true, isFault);
+ synapseServiceStack.put(SynapseConstants.SYNAPSE_SERVICE_NAME,
+ System.currentTimeMillis(), !synCtx.isResponse(), true, isFault);
+ synCtx.setProperty(SynapseConstants.SERVICE_STATS, synapseServiceStack);
+
+ // set default fault handler
+ synCtx.pushFaultHandler(new MediatorFaultHandler(
+ synCtx.getSequence(SynapseConstants.FAULT_SEQUENCE_KEY)));
- // invoke synapse message mediation
+ // invoke synapse message mediation through the main sequence
synCtx.getEnvironment().injectMessage(synCtx);
+
} catch (SynapseException syne) {
+
if (!synCtx.getFaultStack().isEmpty()) {
+ warn(traceOn, "Executing fault handler due to exception encountered", synCtx);
((FaultHandler) synCtx.getFaultStack().pop()).handleFault(synCtx, syne);
+
} else {
- log.error("Synapse encountered an exception, " +
- "No error handlers found - [Message Dropped]\n" + syne.getMessage());
+ warn(traceOn, "Exception encountered but no fault handler found - " +
+ "message dropped", synCtx);
}
+ }
+ }
+
+ private void traceOrDebug(boolean traceOn, String msg) {
+ if (traceOn) {
+ trace.info(msg);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(msg);
+ }
+ }
+
+ private void warn(boolean traceOn, String msg, MessageContext msgContext) {
+ if (traceOn) {
+ trace.warn(msg);
+ }
+ if (log.isDebugEnabled()) {
+ log.warn(msg);
+ }
+ if (msgContext.getServiceLog() != null) {
+ msgContext.getServiceLog().warn(msg);
}
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java Mon Oct 1 20:27:24 2007
@@ -22,6 +22,8 @@
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.mediators.MediatorFaultHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.util.TimerTask;
import java.util.Map;
@@ -42,14 +44,27 @@
*/
public class TimeoutHandler extends TimerTask {
+ private static final Log log = LogFactory.getLog(TimeoutHandler.class);
+
/** The callback map - already a Collections.synchronized() hash map */
private Map callbackStore = null;
/** a lock to prevent concurrent execution while ensuring least overhead */
private Object lock = new Object();
private boolean alreadyExecuting = false;
+ /**
+ * this is the timeout for otherwise non-expiring callbacks
+ * to ensure system stability over time
+ */
+ private long globalTimeout = SynapseConstants.DEFAULT_GLOBAL_TIMEOUT;
public TimeoutHandler(Map callbacks) {
this.callbackStore = callbacks;
+ try {
+ globalTimeout = Long.parseLong(
+ System.getProperty(SynapseConstants.GLOBAL_TIMEOUT_INTERVAL));
+ } catch (Exception ignore) {}
+ log.info("This engine will expire all callbacks after : " + (globalTimeout /1000) +
+ " seconds, irrespective of the timeout action, after the specified or optional timeout");
}
/**
@@ -80,10 +95,10 @@
if (callbackStore.size() > 0) {
long currentTime = currentTime();
-
Iterator i = callbackStore.keySet().iterator();
while (i.hasNext()) {
+
Object key = i.next();
AsyncCallback callback = (AsyncCallback) callbackStore.get(key);
@@ -95,7 +110,6 @@
if (callback.getTimeOutAction() == SynapseConstants.DISCARD_AND_FAULT) {
// actiavte the fault sequence of the current sequence mediator
-
MessageContext msgContext = callback.getSynapseOutMsgCtx();
// add an error code to the message context, so that error sequences
@@ -113,6 +127,11 @@
}
}
+
+ } else if (currentTime > globalTimeout + callback.getTimeOutOn()) {
+ log.warn("Expiring message ID : " + key + "; dropping message after " +
+ "global timeout of : " + (globalTimeout/1000) + " seconds");
+ callbackStore.remove(key);
}
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java Mon Oct 1 20:27:24 2007
@@ -155,10 +155,10 @@
if (statisticsEnable) {
EndPointStatisticsStack endPointStatisticsStack = null;
Object statisticsStackObj =
- synCtx.getProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATISTICS_STACK);
+ synCtx.getProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATS);
if (statisticsStackObj == null) {
endPointStatisticsStack = new EndPointStatisticsStack();
- synCtx.setProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATISTICS_STACK,
+ synCtx.setProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATS,
endPointStatisticsStack);
} else if (statisticsStackObj instanceof EndPointStatisticsStack) {
endPointStatisticsStack = (EndPointStatisticsStack) statisticsStackObj;
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java Mon Oct 1 20:27:24 2007
@@ -90,10 +90,10 @@
if (statisticsEnable) {
EndPointStatisticsStack endPointStatisticsStack = null;
Object statisticsStackObj =
- synCtx.getProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATISTICS_STACK);
+ synCtx.getProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATS);
if (statisticsStackObj == null) {
endPointStatisticsStack = new EndPointStatisticsStack();
- synCtx.setProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATISTICS_STACK,
+ synCtx.setProperty(org.apache.synapse.SynapseConstants.ENDPOINT_STATS,
endPointStatisticsStack);
} else if (statisticsStackObj instanceof EndPointStatisticsStack) {
endPointStatisticsStack = (EndPointStatisticsStack) statisticsStackObj;
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java Mon Oct 1 20:27:24 2007
@@ -68,7 +68,7 @@
*/
public boolean mediate(MessageContext synCtx) {
- boolean statsOn = isStatsOn(synCtx);
+ boolean statsOn = SynapseConstants.STATISTICS_ON == statisticsState;
boolean traceOn = isTraceOn(synCtx);
boolean traceOrDebugOn = isTraceOrDebugOn(traceOn);
@@ -89,10 +89,10 @@
// Setting Required property to collect the sequence statistics
if (statsOn) {
StatisticsStack sequenceStack = (StatisticsStack)
- synCtx.getProperty(SynapseConstants.SEQUENCE_STATISTICS_STACK);
+ synCtx.getProperty(SynapseConstants.SEQUENCE_STATS);
if (sequenceStack == null) {
sequenceStack = new SequenceStatisticsStack();
- synCtx.setProperty(SynapseConstants.SEQUENCE_STATISTICS_STACK, sequenceStack);
+ synCtx.setProperty(SynapseConstants.SEQUENCE_STATS, sequenceStack);
}
String seqName = (name == null ? SynapseConstants.ANONYMOUS_SEQUENCES : name);
boolean isFault = synCtx.getEnvelope().getBody().hasFault();
@@ -177,10 +177,6 @@
}
return false;
- }
-
- private boolean isStatsOn(MessageContext synCtx) {
- return SynapseConstants.STATISTICS_ON == statisticsState;
}
/**
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SynapseMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SynapseMediator.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SynapseMediator.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SynapseMediator.java Mon Oct 1 20:27:24 2007
@@ -19,8 +19,6 @@
package org.apache.synapse.mediators.base;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.MessageContext;
import org.apache.synapse.statistics.StatisticsStack;
@@ -66,10 +64,10 @@
//put the required property for the collecttng statistics for the message mediation
StatisticsStack sequenceStack = (StatisticsStack) synCtx.getProperty(
- SynapseConstants.SEQUENCE_STATISTICS_STACK);
+ SynapseConstants.SEQUENCE_STATS);
if (sequenceStack == null) {
sequenceStack = new SequenceStatisticsStack();
- synCtx.setProperty(SynapseConstants.SEQUENCE_STATISTICS_STACK,sequenceStack);
+ synCtx.setProperty(SynapseConstants.SEQUENCE_STATS,sequenceStack);
}
String seqName = "MainSequence";
boolean isFault = synCtx.getEnvelope().getBody().hasFault();
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java Mon Oct 1 20:27:24 2007
@@ -43,12 +43,12 @@
StatisticsCollector statisticsCollector = getStatisticsCollector(synCtx);
boolean isFault = synCtx.getEnvelope().getBody().hasFault();
ProxyServiceStatisticsStack proxyServiceStatisticsStack = (ProxyServiceStatisticsStack)
- synCtx.getProperty(SynapseConstants.PROXYSERVICE_STATISTICS_STACK);
+ synCtx.getProperty(SynapseConstants.PROXY_STATS);
if (proxyServiceStatisticsStack != null) {
proxyServiceStatisticsStack.reportToStatisticsCollector(statisticsCollector,isFault);
}
ProxyServiceStatisticsStack synapseServiceStatisticsStack = (ProxyServiceStatisticsStack)
- synCtx.getProperty(SynapseConstants.SYNAPSESERVICE_STATISTICS_STACK);
+ synCtx.getProperty(SynapseConstants.SERVICE_STATS);
if (synapseServiceStatisticsStack != null) {
synapseServiceStatisticsStack.reportToStatisticsCollector(statisticsCollector,isFault);
}
@@ -63,7 +63,7 @@
StatisticsCollector statisticsCollector = getStatisticsCollector(synCtx);
boolean isFault = synCtx.getEnvelope().getBody().hasFault();
EndPointStatisticsStack endPointStatisticsStack = (EndPointStatisticsStack)
- synCtx.getProperty(SynapseConstants.ENDPOINT_STATISTICS_STACK);
+ synCtx.getProperty(SynapseConstants.ENDPOINT_STATS);
if (endPointStatisticsStack != null) {
Object endpointObj = synCtx.getProperty(SynapseConstants.PROCESSED_ENDPOINT);
if (endpointObj instanceof Endpoint) {
@@ -90,7 +90,7 @@
StatisticsCollector statisticsCollector = getStatisticsCollector(synCtx);
boolean isFault = synCtx.getEnvelope().getBody().hasFault();
SequenceStatisticsStack sequenceStatisticsStack = (SequenceStatisticsStack)
- synCtx.getProperty(SynapseConstants.SEQUENCE_STATISTICS_STACK);
+ synCtx.getProperty(SynapseConstants.SEQUENCE_STATS);
if (sequenceStatisticsStack != null) {
sequenceStatisticsStack.reportToStatisticsCollector(statisticsCollector,isFault);
}
@@ -105,7 +105,7 @@
StatisticsCollector statisticsCollector = getStatisticsCollector(synCtx);
boolean isFault = synCtx.getEnvelope().getBody().hasFault();
SequenceStatisticsStack sequenceStatisticsStack = (SequenceStatisticsStack)
- synCtx.getProperty(SynapseConstants.SEQUENCE_STATISTICS_STACK);
+ synCtx.getProperty(SynapseConstants.SEQUENCE_STATS);
if (sequenceStatisticsStack != null) {
sequenceStatisticsStack.reportAllToStatisticsCollector(statisticsCollector,isFault);
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/resources/log4j.properties?rev=581131&r1=581130&r2=581131&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/resources/log4j.properties (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/resources/log4j.properties Mon Oct 1 20:27:24 2007
@@ -17,42 +17,54 @@
# under the License.
#
-log4j.rootCategory=ERROR,logfile,stdout
+##
+# Apache Synapse is now able to create per-service trace logs at runtime. Thus while a message
+# is being processed through a Proxy service or the Synapse service (i.e. message mediation through
+# the 'main' sequence), tracing may be turned 'on' at any Proxy, Sequence or Mediator level. This
+# trace state 'flows' with the message - i.e from a trace enabled sequence to another sequence etc.
+# and applies to all mediators within a trace enabled sequence etc. unless another sequence or
+# mediator does not override and specify a different trace setting.
+##
+
+# the root category is ERROR (applies for all 3rd party JARs etc) and will be logged to the
+# LOG_APPENDER and the CONSOLE_APPENDER
+log4j.rootCategory=ERROR, LOG_APPENDER, CONSOLE_APPENDER
-# The trace logger runs at TRACE level by default, and appends to the TRACE_APPENDER
-log4j.logger.TRACE_LOGGER=TRACE, TRACE_APPENDER
-
-# The service logger runs at INFO level by default, and appends to the SERVICE_APPENDER for all services
-log4j.logger.SERVICE_LOGGER=INFO, SERVICE_APPENDER
+# Synapse log level is info, so are transports
+log4j.category.org.apache.synapse=INFO
+log4j.category.org.apache.axis2.transport=INFO
-# TRACE_LOGFILE is set to be a DailyRollingFileAppender using a PatternLayout.
+# The console appender is used to display general information at console
+log4j.appender.CONSOLE_APPENDER=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE_APPENDER.layout.ConversionPattern=%d{ISO8601} [%X{ip}-%X{host}] [%t] %5p %C{1} %m%n
+
+# Configure the service logger at INFO level. Writes only run-time/mediation-time audit messages
+log4j.category.SERVICE_LOGGER=INFO, SERVICE_APPENDER
+log4j.additivity.SERVICE_LOGGER=false
+log4j.appender.SERVICE_APPENDER=org.apache.log4j.RollingFileAppender
+log4j.appender.SERVICE_APPENDER.File=logs/service.log
+log4j.appender.SERVICE_APPENDER.MaxFileSize=1000KB
+log4j.appender.SERVICE_APPENDER.MaxBackupIndex=10
+log4j.appender.SERVICE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.SERVICE_APPENDER.layout.ConversionPattern=%d{ISO8601} [%X{ip}-%X{host}] [%t] %5p %C{1} %m%n
+
+# The trace logger dumps enough information @INFO level, but maybe pushed upto TRACE.
+# Writes only run-time/mediation time tracing/debug messages for messages passing through trace
+# enabled sequences, mediators and services. Enabling tracing on these has a performance impact
+log4j.category.TRACE_LOGGER=INFO, TRACE_APPENDER
+log4j.additivity.TRACE_LOGGER=false
log4j.appender.TRACE_APPENDER=org.apache.log4j.DailyRollingFileAppender
-# Log file will be overridden by the configuration setting in the DB
-
log4j.appender.TRACE_APPENDER.File=logs/trace.log
log4j.appender.TRACE_APPENDER.Append=true
log4j.appender.TRACE_APPENDER.layout=org.apache.log4j.PatternLayout
-log4j.appender.TRACE_APPENDER.layout.ConversionPattern=[%X{ip}] [%X{host}] [%t] %-5p %C{1} - %m %n
-
-# Set the level to DEBUG if you want to log all Exceptions (some of them aren't errors)
-#log4j.category.org.apache.axis2=INFO
-log4j.category.org.apache.synapse=INFO
-log4j.category.org.apache.axis2.transport.nhttp=INFO
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-
-log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %C{1} - %m %n
-
-#### appender writes to a file
-log4j.appender.logfile=org.apache.log4j.RollingFileAppender
-log4j.appender.logfile.File=logs/synapse-log.log
-
-
-# Control the maximum log file size
-log4j.appender.logfile.MaxFileSize=1000KB
-# Archive log files (one backup file here)
-log4j.appender.logfile.MaxBackupIndex=10
+log4j.appender.TRACE_APPENDER.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%X{ip}-%X{host}] [%t] %5p %C{1} %m%n
-log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
-log4j.appender.logfile.layout.ConversionPattern=%6r [%t] %5p %C{1} (%F:%L) - %m%n
+# The standard log file that may be set upto DEBUG/TRACE for general purpose logging
+# Logs information at startup/initialization etc. and also could be used as the developer log
+log4j.appender.LOG_APPENDER=org.apache.log4j.RollingFileAppender
+log4j.appender.LOG_APPENDER.File=logs/synapse.log
+log4j.appender.LOG_APPENDER.MaxFileSize=1000KB
+log4j.appender.LOG_APPENDER.MaxBackupIndex=10
+log4j.appender.LOG_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOG_APPENDER.layout.ConversionPattern=%d{ISO8601} [%X{ip}-%X{host}] [%t] %5p %C{1} %m%n
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org