1 17 package org.apache.servicemix.components.pojo; 18 19 import javax.jbi.JBIException; 20 import javax.jbi.component.ComponentContext; 21 import javax.jbi.component.ComponentLifeCycle; 22 import javax.jbi.messaging.DeliveryChannel; 23 import javax.jbi.messaging.InOnly; 24 import javax.jbi.messaging.MessageExchangeFactory; 25 import javax.jbi.messaging.MessagingException; 26 import javax.jbi.messaging.NormalizedMessage; 27 import javax.management.ObjectName ; 28 29 import org.apache.servicemix.jbi.jaxp.StringSource; 30 31 34 public class MySender implements ComponentLifeCycle { 36 private ComponentContext context; 37 private ObjectName extensionMBeanName; 38 39 40 43 public void sendMessages(int count) throws MessagingException { 44 DeliveryChannel deliveryChannel = context.getDeliveryChannel(); 45 MessageExchangeFactory factory = deliveryChannel.createExchangeFactory(); 46 47 for (int i = 0; i < count; i++) { 48 InOnly exchange = factory.createInOnlyExchange(); 49 NormalizedMessage message = exchange.createMessage(); 50 exchange.setInMessage(message); 51 52 message.setProperty("id", new Integer (i)); 53 message.setContent(new StringSource("<example id='" + i + "'/>")); 54 55 deliveryChannel.send(exchange); 56 } 57 } 58 59 public ObjectName getExtensionMBeanName() { 62 return extensionMBeanName; 63 } 64 65 public void init(ComponentContext context) throws JBIException { 66 this.context = context; 67 } 68 69 public void shutDown() throws JBIException { 70 } 71 72 public void start() throws JBIException { 73 } 74 75 public void stop() throws JBIException { 76 } 77 78 79 public void setExtensionMBeanName(ObjectName extensionMBeanName) { 82 this.extensionMBeanName = extensionMBeanName; 83 } 84 } 85 86 | Popular Tags |