1 23 package org.objectweb.joram.mom.util; 24 25 import javax.jms.*; 26 import javax.jms.IllegalStateException ; 27 28 import java.util.Vector ; 29 30 31 35 public class BridgePtpModule extends BridgeUnifiedModule 36 { 37 38 private transient QueueSender sender; 39 40 41 42 public BridgePtpModule() 43 { 44 super(); 45 } 46 47 48 56 public void send(org.objectweb.joram.shared.messages.Message message) 57 throws JMSException 58 { 59 if (! usable) 60 throw new IllegalStateException (notUsableMessage); 61 62 try { 63 sender.send(MessageConverterModule.convert(producerSession, message)); 64 acknowledge(message); 65 } 66 catch (javax.jms.MessageFormatException exc) { 67 throw exc; 68 } 69 catch (javax.jms.JMSException exc) { 71 qout.add(message); 72 } 73 } 74 75 81 protected void doConnect() throws JMSException 82 { 83 QueueConnectionFactory queueCnxFact = (QueueConnectionFactory) cnxFact; 84 Queue queue = (Queue) dest; 85 86 if (userName != null && password != null) 87 cnx = queueCnxFact.createQueueConnection(userName, password); 88 else 89 cnx = queueCnxFact.createQueueConnection(); 90 cnx.setExceptionListener(this); 91 92 if (clientID != null) 93 cnx.setClientID(clientID); 94 95 producerSession = 96 ((QueueConnection) cnx).createQueueSession(false, 97 Session.AUTO_ACKNOWLEDGE); 98 sender = ((QueueSession) producerSession).createSender(queue); 99 100 consumerSession = ((QueueConnection) cnx).createQueueSession(true, 0); 101 consumer = ((QueueSession) consumerSession).createReceiver(queue, 102 selector); 103 } 104 } 105 | Popular Tags |