mirror of https://github.com/apache/activemq.git
separate JndiTemplate into local and outbound
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@374729 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c146def464
commit
e1bc55dafe
|
@ -24,6 +24,7 @@ import javax.jms.MessageListener;
|
|||
import javax.jms.MessageProducer;
|
||||
|
||||
import org.apache.activemq.Service;
|
||||
import org.apache.activemq.command.ActiveMQMessage;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -94,6 +95,9 @@ abstract class DestinationBridge implements Service,MessageListener{
|
|||
message.setJMSReplyTo(null);
|
||||
}
|
||||
Message converted=jmsMessageConvertor.convert(message);
|
||||
if (converted == message && converted instanceof ActiveMQMessage){
|
||||
converted = (Message) ((ActiveMQMessage)converted).copy();
|
||||
}
|
||||
sendMessage(converted);
|
||||
message.acknowledge();
|
||||
}catch(JMSException e){
|
||||
|
|
|
@ -38,7 +38,8 @@ import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
|
|||
*/
|
||||
public abstract class JmsConnector implements Service{
|
||||
private static final Log log=LogFactory.getLog(JmsConnector.class);
|
||||
protected JndiTemplate jndiTemplate;
|
||||
protected JndiTemplate jndiLocalTemplate;
|
||||
protected JndiTemplate jndiOutboundTemplate;
|
||||
protected JmsMesageConvertor jmsMessageConvertor;
|
||||
private List inboundBridges = new CopyOnWriteArrayList();
|
||||
private List outboundBridges = new CopyOnWriteArrayList();
|
||||
|
@ -67,8 +68,11 @@ public abstract class JmsConnector implements Service{
|
|||
public boolean init(){
|
||||
boolean result=initialized.compareAndSet(false,true);
|
||||
if(result){
|
||||
if(jndiTemplate==null){
|
||||
jndiTemplate=new JndiTemplate();
|
||||
if(jndiLocalTemplate==null){
|
||||
jndiLocalTemplate=new JndiTemplate();
|
||||
}
|
||||
if(jndiOutboundTemplate==null){
|
||||
jndiOutboundTemplate=new JndiTemplate();
|
||||
}
|
||||
if(jmsMessageConvertor==null){
|
||||
jmsMessageConvertor=new SimpleJmsMessageConvertor();
|
||||
|
@ -117,16 +121,30 @@ public abstract class JmsConnector implements Service{
|
|||
/**
|
||||
* @return Returns the jndiTemplate.
|
||||
*/
|
||||
public JndiTemplate getJndiTemplate(){
|
||||
return jndiTemplate;
|
||||
public JndiTemplate getJndiLocalTemplate(){
|
||||
return jndiLocalTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jndiTemplate
|
||||
* The jndiTemplate to set.
|
||||
*/
|
||||
public void setJndiTemplate(JndiTemplate jndiTemplate){
|
||||
this.jndiTemplate=jndiTemplate;
|
||||
public void setJndiLocalTemplate(JndiTemplate jndiTemplate){
|
||||
this.jndiLocalTemplate=jndiTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the jndiOutboundTemplate.
|
||||
*/
|
||||
public JndiTemplate getJndiOutboundTemplate(){
|
||||
return jndiOutboundTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jndiOutboundTemplate The jndiOutboundTemplate to set.
|
||||
*/
|
||||
public void setJndiOutboundTemplate(JndiTemplate jndiOutboundTemplate){
|
||||
this.jndiOutboundTemplate=jndiOutboundTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -269,7 +269,7 @@ public class JmsQueueConnector extends JmsConnector{
|
|||
if(outboundQueueConnectionFactory==null){
|
||||
// look it up from JNDI
|
||||
if(outboundQueueConnectionFactoryName!=null){
|
||||
outboundQueueConnectionFactory=(QueueConnectionFactory) jndiTemplate.lookup(
|
||||
outboundQueueConnectionFactory=(QueueConnectionFactory) jndiOutboundTemplate.lookup(
|
||||
outboundQueueConnectionFactoryName,QueueConnectionFactory.class);
|
||||
if(outboundUsername!=null){
|
||||
outboundQueueConnection=outboundQueueConnectionFactory.createQueueConnection(outboundUsername,
|
||||
|
@ -299,7 +299,7 @@ public class JmsQueueConnector extends JmsConnector{
|
|||
if(embeddedConnectionFactory==null){
|
||||
// look it up from JNDI
|
||||
if(localConnectionFactoryName!=null){
|
||||
localQueueConnectionFactory=(QueueConnectionFactory) jndiTemplate.lookup(
|
||||
localQueueConnectionFactory=(QueueConnectionFactory) jndiLocalTemplate.lookup(
|
||||
localConnectionFactoryName,QueueConnectionFactory.class);
|
||||
if(localUsername!=null){
|
||||
localQueueConnection=localQueueConnectionFactory.createQueueConnection(localUsername,
|
||||
|
@ -418,7 +418,7 @@ public class JmsQueueConnector extends JmsConnector{
|
|||
}catch(JMSException e){
|
||||
//look-up the Queue
|
||||
try{
|
||||
result = (Queue) jndiTemplate.lookup(queueName, Queue.class);
|
||||
result = (Queue) jndiOutboundTemplate.lookup(queueName, Queue.class);
|
||||
}catch(NamingException e1){
|
||||
String errStr = "Failed to look-up Queue for name: " + queueName;
|
||||
log.error(errStr,e);
|
||||
|
|
|
@ -269,7 +269,7 @@ public class JmsTopicConnector extends JmsConnector{
|
|||
if(outboundTopicConnectionFactory==null){
|
||||
// look it up from JNDI
|
||||
if(outboundTopicConnectionFactoryName!=null){
|
||||
outboundTopicConnectionFactory=(TopicConnectionFactory) jndiTemplate.lookup(
|
||||
outboundTopicConnectionFactory=(TopicConnectionFactory) jndiOutboundTemplate.lookup(
|
||||
outboundTopicConnectionFactoryName,TopicConnectionFactory.class);
|
||||
if(outboundUsername!=null){
|
||||
outboundTopicConnection=outboundTopicConnectionFactory.createTopicConnection(outboundUsername,
|
||||
|
@ -299,7 +299,7 @@ public class JmsTopicConnector extends JmsConnector{
|
|||
if(embeddedConnectionFactory==null){
|
||||
// look it up from JNDI
|
||||
if(localConnectionFactoryName!=null){
|
||||
localTopicConnectionFactory=(TopicConnectionFactory) jndiTemplate.lookup(
|
||||
localTopicConnectionFactory=(TopicConnectionFactory) jndiLocalTemplate.lookup(
|
||||
localConnectionFactoryName,TopicConnectionFactory.class);
|
||||
if(localUsername!=null){
|
||||
localTopicConnection=localTopicConnectionFactory.createTopicConnection(localUsername,
|
||||
|
@ -418,7 +418,7 @@ public class JmsTopicConnector extends JmsConnector{
|
|||
}catch(JMSException e){
|
||||
//look-up the Topic
|
||||
try{
|
||||
result = (Topic) jndiTemplate.lookup(topicName, Topic.class);
|
||||
result = (Topic) jndiOutboundTemplate.lookup(topicName, Topic.class);
|
||||
}catch(NamingException e1){
|
||||
String errStr = "Failed to look-up Topic for name: " + topicName;
|
||||
log.error(errStr,e);
|
||||
|
|
Loading…
Reference in New Issue