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:
James Strachan 2006-09-27 14:19:44 +00:00
parent 91bcbda6e0
commit 833eefb345
2 changed files with 10 additions and 4 deletions

View File

@ -71,7 +71,7 @@ class QueueBridge extends DestinationBridge{
return consumer;
}
protected MessageProducer createProducer() throws JMSException{
protected synchronized MessageProducer createProducer() throws JMSException{
producerSession=producerConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
producer = producerSession.createSender(null);
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);
}

View File

@ -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);
producer = producerSession.createPublisher(null);
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);
}