axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers/jms WSIFOperation_Jms.java
Date Tue, 15 Oct 2002 09:22:58 GMT
antelder    2002/10/15 02:22:58

  Modified:    java/src/org/apache/wsif/util/jms WSIFJMSDestination.java
               java/src/org/apache/wsif/providers/jms
                        WSIFOperation_Jms.java
  Log:
  Enhance JMS operations to allow timouts to be specified for each operation request
  
  Revision  Changes    Path
  1.12      +25 -1     xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSDestination.java
  
  Index: WSIFJMSDestination.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSDestination.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- WSIFJMSDestination.java	10 Oct 2002 14:51:44 -0000	1.11
  +++ WSIFJMSDestination.java	15 Oct 2002 09:22:57 -0000	1.12
  @@ -341,7 +341,18 @@
        */
       public String receiveString(String id) throws WSIFException {
           Trc.entry(this, id);
  -        Message msg = receive(id);
  +        String s = receiveString( id, timeout );
  +        Trc.exit(s);
  +        return s;
  +    }
  +
  +    /**
  +     * Blocking receive waits for the specified timeout
  +     * @return the received message
  +     */
  +    public String receiveString(String id, long timeout) throws WSIFException {
  +        Trc.entry(this, id);
  +        Message msg = receive(id, timeout);
           String s = null;
           try {
               if (msg instanceof TextMessage)
  @@ -364,6 +375,19 @@
        * @return the received message
        */
       public Message receive(String id) throws WSIFException {
  +        Trc.entry(this, id);
  +        Message msg = receive(id, timeout);
  +        Trc.exit(msg);
  +        return msg;
  +    }
  +
  +    /**
  +     * Blocking receive waits for a message for the specified timeout
  +     * @param id is the correlation id that the received message must have
  +     * @param timeout how long in milliseconds to wait
  +     * @return the received message
  +     */
  +    public Message receive(String id, long timeout) throws WSIFException {
           Trc.entry(this, id);
           areWeClosed();
           QueueReceiver rec = null;
  
  
  
  1.33      +55 -18    xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java
  
  Index: WSIFOperation_Jms.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- WSIFOperation_Jms.java	15 Oct 2002 09:12:55 -0000	1.32
  +++ WSIFOperation_Jms.java	15 Oct 2002 09:22:57 -0000	1.33
  @@ -137,7 +137,9 @@
   	private WSIFResponseHandler handler;
   	private boolean asyncOperation;
   	private JMSFormatter formatter;
  -	private static final long ASYNC_TIMEOUT = WSIFProperties.getAsyncTimeout();
  +
  +	private long syncTimeout;
  +	private long asyncTimeout;
   	transient private WSIFJMSDestination jmsDest;
   
   	/**
  @@ -157,6 +159,9 @@
   		fieldJmsPort = jmsPort;
   		this.jmsDest = jmsDest;
   
  +		syncTimeout = WSIFProperties.getSyncTimeout();
  +		asyncTimeout = WSIFProperties.getAsyncTimeout();
  +
   		if (Trc.ON)
   			Trc.exit(deep());
   	}
  @@ -205,7 +210,7 @@
   			// send the jms message	  
   			String correlId = sendJmsMessage(input);
   
  -			javax.jms.Message response = jmsDest.receive(correlId);
  +			javax.jms.Message response = jmsDest.receive(correlId, syncTimeout);
   			operationSucceeded = receiveJmsMessage(response, output, fault);
   
   		} catch (Exception ex) {
  @@ -302,7 +307,7 @@
   						correlId =
   							new WSIFJMSCorrelationId(sendJmsMessage(input));
   						//register it to the correlation service
  -						cs.put(correlId, this, ASYNC_TIMEOUT);
  +						cs.put(correlId, this, asyncTimeout);
   					}
   				}
   			}
  @@ -419,9 +424,11 @@
   		for (Iterator i = input.getPartNames(); i.hasNext();) {
   			partName = (String) i.next();
   			if (propertyParts.containsKey(partName)) {
  -				jmsDest.setProperty(
  -					(String) propertyParts.get(partName),
  -					input.getObjectPart(partName));
  +				String name = (String) propertyParts.get(partName);
  +				Object value = input.getObjectPart(partName);
  +				if (!timeoutProperty(name, value)) {
  +					jmsDest.setProperty(name, value);
  +				}
   			} else if (wsdlInputParts.contains(partName)) {
   				wsdlInputParts.remove(partName);
   				if (fieldInput == null) {
  @@ -687,7 +694,9 @@
   				JMSPropertyValue pv = (JMSPropertyValue) i.next();
   				if (pv != null) {
   					Object o = getObjectValue(pv.getType(), pv.getValue());
  -					jmsDest.setProperty(pv.getName(), o);
  +					if (!timeoutProperty(pv.getName(), o)) {
  +						jmsDest.setProperty(pv.getName(), o);
  +					}
   				}
   			}
   		}
  @@ -707,9 +716,34 @@
   
   			if (value != null) {
   				Object o = getObjectValue(value.getType(), value.getValue());
  -				jmsDest.setProperty(attName, o);
  +				if (!timeoutProperty(attName, o)) {
  +					jmsDest.setProperty(attName, o);
  +				}
  +			}
  +		}
  +	}
  +
  +	private boolean timeoutProperty(String propertyName, Object value) {
  +		boolean isTimeoutProperty = false;
  +		if (WSIFConstants.WSIF_PROP_SYNC_TIMEOUT.equals(propertyName)) {
  +			isTimeoutProperty = true;
  +			try {
  +				syncTimeout = Long.parseLong(value.toString());
  +				Trc.event(this, "overridding syncTimeout to " + syncTimeout);
  +			} catch (NumberFormatException ex) {
  +				Trc.ignoredException(ex);
  +			}
  +		} else if (
  +			WSIFConstants.WSIF_PROP_ASYNC_TIMEOUT.equals(propertyName)) {
  +			isTimeoutProperty = true;
  +			try {
  +				asyncTimeout = Long.parseLong(value.toString());
  +				Trc.event(this, "overridding asyncTimeout to " + syncTimeout);
  +			} catch (NumberFormatException ex) {
  +				Trc.ignoredException(ex);
   			}
   		}
  +		return isTimeoutProperty;
   	}
   
   	/**
  @@ -905,19 +939,22 @@
   		if (context == null || jmsDest == null) {
   			return;
   		}
  -		String partName;
   		HashMap jmsProps = new HashMap();
   		for (Iterator i = context.getPartNames(); i.hasNext();) {
  -			partName = (String) i.next();
  -			if (partName.startsWith(WSIFConstants.CONTEXT_JMS_PREFIX)) {
  -				try {
  -					jmsProps.put(
  -						partName.substring(
  -							WSIFConstants.CONTEXT_JMS_PREFIX.length()),
  -						context.getObjectPart(partName));
  -				} catch (WSIFException ex) {
  -					Trc.ignoredException(ex);
  +			String partName = (String) i.next();
  +			try {
  +				Object value = context.getObjectPart(partName);
  +				if (!timeoutProperty(partName, value)) {
  +					if (partName
  +						.startsWith(WSIFConstants.CONTEXT_JMS_PREFIX)) {
  +						jmsProps.put(
  +							partName.substring(
  +								WSIFConstants.CONTEXT_JMS_PREFIX.length()),
  +							value);
  +					}
   				}
  +			} catch (WSIFException ex) {
  +				Trc.ignoredException(ex);
   			}
   		}
   		if (jmsProps.size() > 0) {
  
  
  

Mime
View raw message