1 17 package org.apache.servicemix.jbi.nmr.flow.jms; 18 19 import javax.jbi.messaging.ExchangeStatus; 20 import javax.jbi.messaging.MessageExchange; 21 import javax.jbi.messaging.MessagingException; 22 import javax.jbi.messaging.NormalizedMessage; 23 24 import org.apache.servicemix.MessageExchangeListener; 25 import org.apache.servicemix.components.util.ComponentSupport; 26 import org.apache.servicemix.jbi.jaxp.StringSource; 27 28 31 public class PingService extends ComponentSupport implements MessageExchangeListener{ 32 public void onMessageExchange(MessageExchange exchange) throws MessagingException{ 33 if (exchange.getStatus() == ExchangeStatus.ACTIVE) { 34 System.out.println("GOT A MESSAGE; exchange.status="+exchange.getStatus()); 35 NormalizedMessage out=exchange.createMessage(); 36 out.setContent(new StringSource("<response>Ping back at ya!</response>")); 37 System.out.println("SENDING RESPONSE; exchange.status="+exchange.getStatus()); 38 exchange.setMessage(out, "out"); 39 getDeliveryChannel().sendSync(exchange); 40 System.out.println("RESPONSE SENT; exchange.status="+exchange.getStatus()); 41 } else { 42 System.out.println("GOT A MESSAGE; exchange.status="+exchange.getStatus()); 43 } 44 } 45 } | Popular Tags |