You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by "Ron Gavlin (JIRA)" <ji...@apache.org> on 2008/07/05 10:09:00 UTC
[jira] Commented: (SM-1411) EIP Aggregators should propagate
properties/attachments by default and allow this behavior to be
configurable
[ https://issues.apache.org/activemq/browse/SM-1411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43978#action_43978 ]
Ron Gavlin commented on SM-1411:
--------------------------------
Here is a proposed patch:
Index: src/main/java/org/apache/servicemix/eip/support/AbstractAggregator.java
===================================================================
--- src/main/java/org/apache/servicemix/eip/support/AbstractAggregator.java (revision 674147)
+++ src/main/java/org/apache/servicemix/eip/support/AbstractAggregator.java (working copy)
@@ -17,6 +17,7 @@
package org.apache.servicemix.eip.support;
import java.util.Date;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.Lock;
@@ -21,9 +22,11 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.Lock;
+import javax.activation.DataHandler;
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.InOnly;
import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.jbi.messaging.RobustInOnly;
@@ -30,6 +33,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.eip.EIPEndpoint;
+import org.apache.servicemix.jbi.messaging.PojoMarshaler;
import org.apache.servicemix.jbi.util.MessageUtil;
import org.apache.servicemix.timers.Timer;
import org.apache.servicemix.timers.TimerListener;
@@ -59,6 +63,10 @@
private ConcurrentMap<String, Boolean> closedAggregates = new ConcurrentHashMap<String, Boolean>();
+ private boolean copyProperties = true;
+
+ private boolean copyAttachments = true;
+
/**
* @return the synchronous
*/
@@ -101,6 +109,22 @@
this.target = target;
}
+ public boolean isCopyProperties() {
+ return copyProperties;
+ }
+
+ public void setCopyProperties(boolean copyProperties) {
+ this.copyProperties = copyProperties;
+ }
+
+ public boolean isCopyAttachments() {
+ return copyAttachments;
+ }
+
+ public void setCopyAttachments(boolean copyAttachments) {
+ this.copyAttachments = copyAttachments;
+ }
+
/* (non-Javadoc)
* @see org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
*/
@@ -248,6 +272,39 @@
}
/**
+ * Copies properties from one message to another that do not already exist
+ *
+ * @param from the message containing the properties
+ * @param to the destination message where the properties are set
+ */
+ protected void copyProperties(NormalizedMessage from, NormalizedMessage to) {
+ for (String propertyName : (Set<String>) from.getPropertyNames()) {
+ // Do not copy existing properties or transient properties
+ if (to.getProperty(propertyName) == null && !PojoMarshaler.BODY.equals(propertyName)) {
+ Object value = from.getProperty(propertyName);
+ to.setProperty(propertyName, value);
+ }
+ }
+ }
+
+ /**
+ * Copies attachments from one message to another that do not already exist
+ *
+ * @param from the message with the attachments
+ * @param to the destination message where the attachments are to be added
+ * @throws MessagingException if an attachment could not be added
+ */
+ protected void copyAttachments(NormalizedMessage from, NormalizedMessage to) throws MessagingException {
+ for (String attachmentName : (Set<String>) from.getAttachmentNames()) {
+ // Do not copy existing attachments
+ if (to.getAttachment(attachmentName) == null) {
+ DataHandler value = from.getAttachment(attachmentName);
+ to.addAttachment(attachmentName, value);
+ }
+ }
+ }
+
+ /**
* Retrieve the correlation ID of the given exchange
* @param exchange
* @param message
Index: src/main/java/org/apache/servicemix/eip/patterns/SplitAggregator.java
===================================================================
--- src/main/java/org/apache/servicemix/eip/patterns/SplitAggregator.java (revision 674147)
+++ src/main/java/org/apache/servicemix/eip/patterns/SplitAggregator.java (working copy)
@@ -252,6 +252,12 @@
} else {
root.appendChild(doc.importNode(elem, true));
}
+ if (isCopyProperties()) {
+ copyProperties(messages[i], message);
+ }
+ if (isCopyAttachments()) {
+ copyAttachments(messages[i], message);
+ }
}
}
message.setContent(new DOMSource(doc));
> EIP Aggregators should propagate properties/attachments by default and allow this behavior to be configurable
> -------------------------------------------------------------------------------------------------------------
>
> Key: SM-1411
> URL: https://issues.apache.org/activemq/browse/SM-1411
> Project: ServiceMix
> Issue Type: Improvement
> Components: servicemix-eip
> Reporter: Ron Gavlin
>
> The default SplitAggregator behavior should be to propagate both properties
> and attachments.
> Also, the AbstractAggregator or SplitAggregator should to allow this behavior
> to be configurable by adding booleans for isCopyAttachments and
> isCopyProperties.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.