Title: [747] trunk/core/src/main/java/org/servicemix/jbi/nmr/flow/jca/JCAFlow.java: Send back MessageExchange replies to the orignating Container
Revision
747
Author
rajdavies
Date
2005-11-04 03:34:57 -0500 (Fri, 04 Nov 2005)

Log Message

Send back MessageExchange replies to the orignating Container

Modified Paths


Diff

Modified: trunk/core/src/main/java/org/servicemix/jbi/nmr/flow/jca/JCAFlow.java (746 => 747)

--- trunk/core/src/main/java/org/servicemix/jbi/nmr/flow/jca/JCAFlow.java	2005-11-04 08:15:46 UTC (rev 746)
+++ trunk/core/src/main/java/org/servicemix/jbi/nmr/flow/jca/JCAFlow.java	2005-11-04 08:34:57 UTC (rev 747)
@@ -361,7 +361,7 @@
         super.onEvent(event);
         try {
             String componentName = event.getPacket().getComponentNameSpace().getName();
-            if (event.getStatus() == ComponentPacketEvent.ACTIVATED){
+            if (event.getStatus() == ComponentPacketEvent.ACTIVATED){          
             	ActiveMQActivationSpec ac = new ActiveMQActivationSpec();
             	ac.setDestinationType("javax.jms.Queue");
             	ac.setDestination(INBOUND_PREFIX + componentName);
@@ -420,32 +420,32 @@
      * @throws MessagingException
      */
     public void doRouting(final MessageExchangeImpl me) throws MessagingException {
+        
         ComponentNameSpace id = me.getRole() == Role.PROVIDER ? me.getDestinationId() : me.getSourceId();
         ComponentConnector cc = broker.getRegistry().getComponentConnector(id);
         if (cc != null) {
-            if (cc.isLocal() && !isPersistent(me)) {
-                super.doRouting(me);
-            }
-            else {
-            	if (me.getMirror().getSyncState() != MessageExchangeImpl.SYNC_STATE_ASYNC) {
-            		throw new IllegalStateException("sendSync can not be used on jca flow with external components");
-            	}
-                try {
-                    final String componentName = cc.getComponentNameSpace().getName();
-                    JmsTemplate jt = isPersistent(me) ? jmsPersistentTemplate : jmsTemplate;
-                    jt.send(INBOUND_PREFIX + componentName, new MessageCreator() {
-						public Message createMessage(Session session) throws JMSException {
-		                    return session.createObjectMessage(me);
-						}
-					});
+        	if (me.getMirror().getSyncState() != MessageExchangeImpl.SYNC_STATE_ASYNC) {
+        		throw new IllegalStateException("sendSync can not be used on jca flow with external components");
+        	}
+            try {
+                final String componentName = cc.getComponentNameSpace().getName();
+                JmsTemplate jt = isPersistent(me) ? jmsPersistentTemplate : jmsTemplate;
+                String destination = "";
+                if (me.getRole() == Role.PROVIDER){
+                    destination = INBOUND_PREFIX + componentName;
+                }else {
+                    destination = INBOUND_PREFIX + id.getContainerName();
                 }
-                catch (Exception e) {
-                    log.error("Failed to send exchange: " + me + " internal JMS Network", e);
-                    throw new MessagingException(e);
-                }
+                jt.send(destination, new MessageCreator() {
+					public Message createMessage(Session session) throws JMSException {
+	                    return session.createObjectMessage(me);
+					}
+				});
+            } catch (Exception e) {
+                log.error("Failed to send exchange: " + me + " internal JMS Network", e);
+                throw new MessagingException(e);
             }
-        }
-        else {
+        } else {
             throw new MessagingException("No component with id (" + id + ") - Couldn't route MessageExchange " + me);
         }
     }
@@ -610,4 +610,8 @@
 	public void setBootstrapContext(BootstrapContext bootstrapContext) {
 		this.bootstrapContext = bootstrapContext;
 	}
-}
+    
+    public String toString(){
+        return broker.getContainerName() + " JCAFlow";
+    }
+}
\ No newline at end of file

Reply via email to