Decided to post a solution to this based on suggestions. I created a cache,
for testing purposes in a form of a Map. Created 3 LW Components:
StoreMessage, RetrieveMessage and ClearMessage. They use CORRELATION_ID,
which is a unique ID that correlates all the components of a flow, to save
and get the message from a cache.

Here is a small snippet from RetrieveMessage:

/* (non-Javadoc)
         * @see
org.apache.servicemix.components.util.TransformComponentSupport#transform(javax.jbi.messaging.MessageExchange,
javax.jbi.messaging.NormalizedMessage,
javax.jbi.messaging.NormalizedMessage)
         */
        @Override
        protected boolean transform(MessageExchange exchange, NormalizedMessage 
in,
NormalizedMessage out) throws Exception {
                String operationName = exchange.getOperation().getLocalPart();
                if (operationName == null) {
                        throw new JBIException("Operations name was NOT set in
MessageExchange!");
                }
                String exchangeId = exchange.getExchangeId();
                String correlationId =
(String)exchange.getProperty(JbiConstants.CORRELATION_ID);
                String key = exchangeId;
                if(StringUtils.isNotBlank(correlationId)){
                        key = correlationId;
                }
                logger.debug("Retrieving message with key:" + (key + "_" +
operationName));
                String content = (String)cache.get(key + "_" + operationName);
                if(content != null){
                        logger.debug("RetrieveMessageComponent: Source is not 
null");
                        out.setContent(new StringSource(content));
                }
                else{
                        logger.debug("RetrieveMessageComponent: Source is 
null");
                        out.setContent(in.getContent());
                }
                return true;
        }
-- 
View this message in context: 
http://www.nabble.com/State-management-between-components-%28nodes%29-of-a-flow-tp9859826p17496818.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to