added an example and test case of configuring the JMS to JMS bridge using the XBean format rather than the pure Spring version thats currently on the wiki - see http://incubator.apache.org/activemq/jms-to-jms-bridge.html

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@419058 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-07-04 18:04:50 +00:00
parent 466ccddc1f
commit 4383d00d81
4 changed files with 133 additions and 8 deletions

View File

@ -257,7 +257,6 @@
<!-- this one is a little flaky and can fail on some platforms randomly -->
<exclude>**/QuickJournalRecoveryBrokerTest.*</exclude>
<exclude>**/RendezvousDiscoverTransportTest.*</exclude>
<exclude>**/QueueBridgeXBeanTest.*</exclude>
<!-- UDP related tests someimes fail on some platforms -->
<exclude>**/UdpTransportTest.*</exclude>

View File

@ -51,23 +51,35 @@ public class QueueBridgeTest extends TestCase implements MessageListener {
protected MessageProducer requestServerProducer;
protected void setUp() throws Exception {
super.setUp();
context = new ClassPathXmlApplicationContext("org/apache/activemq/network/jms/queue-config.xml");
ActiveMQConnectionFactory fac = (ActiveMQConnectionFactory) context.getBean("localFactory");
localConnection = fac.createQueueConnection();
localConnection.start();
context = createApplicationContext();
createConnections();
requestServerSession = localConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
Queue theQueue = requestServerSession.createQueue(getClass().getName());
requestServerConsumer = requestServerSession.createConsumer(theQueue);
requestServerConsumer.setMessageListener(this);
requestServerProducer = requestServerSession.createProducer(null);
QueueSession session = remoteConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
requestor = new QueueRequestor(session,theQueue);
}
protected void createConnections() throws JMSException {
ActiveMQConnectionFactory fac = (ActiveMQConnectionFactory) context.getBean("localFactory");
localConnection = fac.createQueueConnection();
localConnection.start();
fac = (ActiveMQConnectionFactory) context.getBean("remoteFactory");
remoteConnection = fac.createQueueConnection();
remoteConnection.start();
QueueSession session = remoteConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
requestor = new QueueRequestor(session,theQueue);
}
protected AbstractApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("org/apache/activemq/network/jms/queue-config.xml");
}

View File

@ -0,0 +1,48 @@
/**
*
* Copyright 2005-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.network.jms;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import javax.jms.JMSException;
/**
*
* @version $Revision$
*/
public class QueueBridgeXBeanTest extends QueueBridgeTest {
protected AbstractApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("org/apache/activemq/network/jms/queue-xbean.xml");
}
/*
protected void createConnections() throws JMSException {
ActiveMQConnectionFactory fac = (ActiveMQConnectionFactory) context.getBean("localFactory");
localConnection = fac.createQueueConnection();
localConnection.start();
fac = (ActiveMQConnectionFactory) context.getBean("remoteFactory");
remoteConnection = fac.createQueueConnection();
remoteConnection.start();
}
*/
}

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2005-2006 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans>
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
<!-- remote broker -->
<broker xmlns="http://activemq.org/config/1.0" id="remotebroker"
brokerName="remotebroker" persistent="false">
<transportConnectors>
<transportConnector uri="tcp://localhost:61666" />
</transportConnectors>
</broker>
<!-- local broker with embedded Jms to Jms bridge (ok - it's contrived) -->
<!-- START SNIPPET: example -->
<broker xmlns="http://activemq.org/config/1.0" id="localbroker"
brokerName="localBroker" persistent="false">
<transportConnectors>
<transportConnector uri="tcp://localhost:61234" />
</transportConnectors>
<jmsBridgeConnectors>
<jmsQueueConnector
outboundQueueConnectionFactory="#remoteFactory">
<inboundQueueBridges>
<inboundQueueBridge
inboundQueueName="org.apache.activemq.network.jms.QueueBridgeXBeanTest" />
</inboundQueueBridges>
</jmsQueueConnector>
</jmsBridgeConnectors>
</broker>
<!-- JMS ConnectionFactory to use remote -->
<bean id="remoteFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61666" />
</bean>
<!-- END SNIPPET: example -->
<!-- JMS ConnectionFactory to use local broker (the one with the bridge) -->
<bean id="localFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61234" />
</bean>
</beans>