mirror of https://github.com/apache/activemq.git
ensure that producer & consumers are created lazily
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@450451 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
91bcbda6e0
commit
833eefb345
|
@ -71,7 +71,7 @@ class QueueBridge extends DestinationBridge{
|
||||||
return consumer;
|
return consumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MessageProducer createProducer() throws JMSException{
|
protected synchronized MessageProducer createProducer() throws JMSException{
|
||||||
producerSession=producerConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
|
producerSession=producerConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
|
||||||
producer = producerSession.createSender(null);
|
producer = producerSession.createSender(null);
|
||||||
return producer;
|
return producer;
|
||||||
|
@ -80,7 +80,10 @@ class QueueBridge extends DestinationBridge{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void sendMessage(Message message) throws JMSException{
|
protected synchronized void sendMessage(Message message) throws JMSException{
|
||||||
|
if (producer == null) {
|
||||||
|
createProducer();
|
||||||
|
}
|
||||||
producer.send(producerQueue,message);
|
producer.send(producerQueue,message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,13 +79,16 @@ class TopicBridge extends DestinationBridge{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected MessageProducer createProducer() throws JMSException{
|
protected synchronized MessageProducer createProducer() throws JMSException{
|
||||||
producerSession=producerConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
|
producerSession=producerConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
|
||||||
producer = producerSession.createPublisher(null);
|
producer = producerSession.createPublisher(null);
|
||||||
return producer;
|
return producer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendMessage(Message message) throws JMSException{
|
protected synchronized void sendMessage(Message message) throws JMSException{
|
||||||
|
if (producer == null) {
|
||||||
|
createProducer();
|
||||||
|
}
|
||||||
producer.publish(producerTopic,message);
|
producer.publish(producerTopic,message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue