Asankha,
You have karma in Axis2. Please feel free to apply the patch yourself.
thanks,
dims
On 6/13/06, Asankha C. Perera <[EMAIL PROTECTED]> wrote:
Can someone please apply this patch to Axis2
This includes a fix to support JMS Text messages in addition to Binary messages
(else, on the server side a class cast exception was thrown) and to make the
JMS sender uses the TRANSPORT_URL property if set, and use the To address only
if
its not specified. This would be required for Synapse.
thanks
asankha
Index: modules/core/src/org/apache/axis2/transport/jms/JMSSender.java
===================================================================
--- modules/core/src/org/apache/axis2/transport/jms/JMSSender.java
(revision 413826)
+++ modules/core/src/org/apache/axis2/transport/jms/JMSSender.java
(working copy)
@@ -22,10 +22,12 @@
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.client.Options;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.MessageContextConstants;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.handlers.AbstractHandler;
@@ -199,7 +201,16 @@
}
}
- String endpointAddress = msgContext.getTo() != null ?
msgContext.getTo().getAddress() : null;
+ String endpointAddress = (String) msgContext
+ .getProperty(MessageContextConstants.TRANSPORT_URL);
+ if (endpointAddress == null &&
+ msgContext.getTo() != null &&
+ !AddressingConstants.Submission.WSA_ANONYMOUS_URL
+ .equals(msgContext.getTo().getAddress()) &&
+ !AddressingConstants.Final.WSA_ANONYMOUS_URL
+ .equals(msgContext.getTo().getAddress())) {
+ endpointAddress = msgContext.getTo().getAddress();
+ }
boolean waitForResponse = false;
if (dest == null) {
Index: modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java
===================================================================
--- modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java
(revision 413826)
+++ modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java
(working copy)
@@ -184,8 +184,8 @@
public void onMessage(javax.jms.Message message) {
try {
// pass off the message to a worker as a BytesMessage
- SimpleJMSWorker worker = new SimpleJMSWorker(configurationContext,
this,
- (BytesMessage) message);
+ SimpleJMSWorker worker = new SimpleJMSWorker
+ (configurationContext, this, message);
// do we allow multi-threaded workers?
if (doThreads) {
Index: modules/core/src/org/apache/axis2/transport/jms/SimpleJMSWorker.java
===================================================================
--- modules/core/src/org/apache/axis2/transport/jms/SimpleJMSWorker.java
(revision 413826)
+++ modules/core/src/org/apache/axis2/transport/jms/SimpleJMSWorker.java
(working copy)
@@ -41,6 +41,8 @@
import org.apache.commons.logging.LogFactory;
import javax.jms.BytesMessage;
+import javax.jms.Message;
+import javax.jms.TextMessage;
import javax.xml.namespace.QName;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.stream.XMLInputFactory;
@@ -59,10 +61,10 @@
private static final Log log = LogFactory.getLog(SimpleJMSWorker.class);
private ConfigurationContext configurationContext;
SimpleJMSListener listener;
- BytesMessage message;
+ Message message;
public SimpleJMSWorker(ConfigurationContext configurationContext,
SimpleJMSListener listener,
- BytesMessage message) {
+ Message message) {
this.listener = listener;
this.message = message;
this.configurationContext = configurationContext;
@@ -179,20 +181,38 @@
* This is where the incoming message is processed.
*/
public void run() {
- InputStream in ;
+ InputStream in = null;
try {
-
// get the incoming msg content into a byte array
- byte[] buffer = new byte[8 * 1024];
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ if (message instanceof BytesMessage) {
+ byte[] buffer = new byte[8 * 1024];
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
- for (int bytesRead = message.readBytes(buffer); bytesRead != -1;
- bytesRead = message.readBytes(buffer)) {
- out.write(buffer, 0, bytesRead);
+ BytesMessage byteMsg = (BytesMessage) message;
+ for (int bytesRead = byteMsg.readBytes(buffer); bytesRead !=
-1;
+ bytesRead = byteMsg.readBytes(buffer)) {
+ out.write(buffer, 0, bytesRead);
+ }
+ in = new ByteArrayInputStream(out.toByteArray());
+
+ } else if (message instanceof TextMessage) {
+ TextMessage txtMsg = (TextMessage) message;
+ String contentType = message.getStringProperty("contentType");
+ if (contentType != null) {
+ String charSetEnc =
+ TransportUtils.getCharSetEncoding(contentType);
+ in = new
ByteArrayInputStream(txtMsg.getText().getBytes(charSetEnc));
+ } else {
+ in = new ByteArrayInputStream(txtMsg.getText().getBytes());
+ }
+
+ } else {
+ log.error("Unsupported JMS Message type : " + message);
+ log.error(Messages.getMessage("exception00"));
}
- in = new ByteArrayInputStream(out.toByteArray());
+
} catch (Exception e) {
log.error(Messages.getMessage("exception00"), e);
e.printStackTrace();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Davanum Srinivas : http://wso2.com/blogs/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]