I have what I think *must* be a simple and common deployment architecture. I have two webapps running on different machines. At any given time, one will receive an http request that generates an MQ message. I want the other webapp on the other machine to automatically receive this message as well.
My understanding is that the peer protocol should fit the bill just fine. My problem is that even in the simplest example I can write, on the same network segment, I can't get it to work (i.e. messages sent by one VM are also received by the that VM, but not by the other). It works if both VMs are on the same box, but that's a deal-breaker for me. I've (obiously) had trouble connecting the dots here. For instance, I see configuration for brokers that allows one to specify the networkConnector and transportConnector; places where discoveryUri looks promising. But I thought that the peer protocol created an embedded broker on the fly -- so how is that configured? Also, connecting Spring config with the activemq config (without xbean) has been frustrating. Here's my Spring config: //////////////////////// // spring-config.xml /////////////////////// <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="jmsTopicConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL"> <value>peer://mygroupname/mybrokername</value> </property> </bean> <bean id="TestTopic" class="org.apache.activemq.command.ActiveMQTopic"> <constructor-arg> <value>TestTopic</value> </constructor-arg> </bean> <bean id="SenderBean" class="com.ssi.exp.TestMessageSender"> <property name="jmsTemplate"> <ref bean="TestTopicJmsTemplate"/> </property> </bean> <bean id="MessageListener" class="com.ssi.exp.TestMessageListener" /> <bean id="TestJmsTopicListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer102"> <property name="concurrentConsumers"> <value>1</value> </property> <property name="connectionFactory" ref="jmsTopicConnectionFactory"/> <property name="destination" ref="TestTopic" /> <property name="messageListener" ref="MessageListener" /> <property name="pubSubDomain"> <value>true</value> </property> </bean> <bean id="TestTopicJmsTemplate" class="org.springframework.jms.core.JmsTemplate102"> <property name="connectionFactory"> <ref bean="jmsTopicConnectionFactory" /> </property> <property name="defaultDestination"> <ref bean="TestTopic" /> </property> <property name="pubSubDomain"> <value>true</value> </property> </bean> </beans> All my test code does is load the Spring context. The test app can be run as listener-only or as sender-listener. //////////////////////// // Test Code: TestAMQPeer.java /////////////////////// package com.ssi.exp; import java.util.Map; import java.util.HashMap; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.ApplicationContext; public class TestAMQPeer { public static void main(String[] cmdArgs) throws Exception { System.out.println("Loading Spring context..."); System.out.println("\tThis should create the activemq listener and sender..."); // load the Spring app ctx // listeners should be registered automatically // per my understanding ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config.xml"); // defaults int numMsgs = 5; // send 10 messages int delay = 3; // seconds // listen only by default if ( cmdArgs.length > 0 && null != cmdArgs[0] && cmdArgs[0].equalsIgnoreCase("send") ) { // if running as a sender, start sending messages // this process should receive them, and any other // in the peer group System.out.println("Executing in SENDER mode..."); TestMessageSender sender = (TestMessageSender) ctx.getBean("SenderBean"); for (int i = 0; i < numMsgs; i++) { sender.send(); try { Thread.sleep(delay * 1000l); } catch (InterruptedException ie) {}; // ignore } } } } //////////////////////// // Listen-only output (on machine A) /////////////////////// [EMAIL PROTECTED] ~]$ /opt/bea/jdk150_06/bin/java -jar test-amq-peer.jar Loading Spring context... This should create the activemq listener and sender... Jul 31, 2008 9:15:07 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing [EMAIL PROTECTED]: display name [EMAIL PROTECTED]; startup date [Thu Jul 31 09:15:07 CDT 2008]; root of context hierarchy Jul 31, 2008 9:15:07 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [spring-config.xml] Jul 31, 2008 9:15:07 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [EMAIL PROTECTED]: [EMAIL PROTECTED] Jul 31, 2008 9:15:07 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in [EMAIL PROTECTED]: defining beans [jmsTopicConnectionFactory,TestTopic,SenderBean,MessageListener,TestJmsTopicListenerContainer,TestTopicJmsTemplate]; root of factory hierarchy Jul 31, 2008 9:15:08 AM org.apache.activemq.broker.BrokerService getBroker INFO: ActiveMQ 4.0.1 JMS Message Broker (mybrokername) is starting Jul 31, 2008 9:15:08 AM org.apache.activemq.broker.BrokerService getBroker INFO: For help or more information please see: http://incubator.apache.org/activemq/ Jul 31, 2008 9:15:08 AM org.apache.activemq.transport.TransportServerThreadSupport doStart INFO: Listening for connections at: tcp://VM-QA-701-ENT:54820 Jul 31, 2008 9:15:08 AM org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgent start WARNING: brokerName not set Jul 31, 2008 9:15:08 AM org.apache.activemq.broker.TransportConnector start INFO: Connector tcp://VM-QA-701-ENT:54820 Started Jul 31, 2008 9:15:08 AM org.apache.activemq.network.NetworkConnector doStart INFO: Network Connector bridge Started Jul 31, 2008 9:15:08 AM org.apache.activemq.broker.BrokerService start INFO: ActiveMQ JMS Message Broker (mybrokername, ID:VM-QA-701-ENT-54819-1217513708221-1:0) started Jul 31, 2008 9:15:08 AM org.apache.activemq.transport.vm.VMTransportFactory bind INFO: binding to broker: mybrokername Jul 31, 2008 9:15:08 AM org.apache.activemq.broker.TransportConnector start INFO: Connector vm://mybrokername Started Jul 31, 2008 9:15:08 AM org.apache.activemq.broker.jmx.ManagementContext$1 run INFO: JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi //////////////////////// // Sender-Listener output (on machine B) /////////////////////// [EMAIL PROTECTED] ~]$ /opt/java/bin/java -jar test-amq-peer.jar send Loading Spring context... This should create the activemq listener and sender... Jul 31, 2008 2:03:35 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing [EMAIL PROTECTED]: display name [EMAIL PROTECTED]; startup date [Thu Jul 31 02:03:35 CDT 2008]; root of context hierarchy Jul 31, 2008 2:03:35 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [spring-config.xml] Jul 31, 2008 2:03:35 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [EMAIL PROTECTED]: [EMAIL PROTECTED] Jul 31, 2008 2:03:35 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in [EMAIL PROTECTED]: defining beans [jmsTopicConnectionFactory,TestTopic,SenderBean,MessageListener,TestJmsTopicListenerContainer,TestTopicJmsTemplate]; root of factory hierarchy Jul 31, 2008 2:03:36 AM org.apache.activemq.broker.BrokerService getBroker INFO: ActiveMQ 4.0.1 JMS Message Broker (mybrokername) is starting Jul 31, 2008 2:03:36 AM org.apache.activemq.broker.BrokerService getBroker INFO: For help or more information please see: http://incubator.apache.org/activemq/ Jul 31, 2008 2:03:36 AM org.apache.activemq.transport.TransportServerThreadSupport doStart INFO: Listening for connections at: tcp://dacar-collector:55707 Jul 31, 2008 2:03:36 AM org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgent start WARNING: brokerName not set Jul 31, 2008 2:03:36 AM org.apache.activemq.broker.TransportConnector start INFO: Connector tcp://dacar-collector:55707 Started Jul 31, 2008 2:03:36 AM org.apache.activemq.network.NetworkConnector doStart INFO: Network Connector bridge Started Jul 31, 2008 2:03:36 AM org.apache.activemq.broker.BrokerService start INFO: ActiveMQ JMS Message Broker (mybrokername, ID:dacar-collector-35217-1217487816143-1:0) started Jul 31, 2008 2:03:36 AM org.apache.activemq.transport.vm.VMTransportFactory bind INFO: binding to broker: mybrokername Jul 31, 2008 2:03:36 AM org.apache.activemq.broker.TransportConnector start INFO: Connector vm://mybrokername Started Jul 31, 2008 2:03:36 AM org.apache.activemq.broker.jmx.ManagementContext$1 run INFO: JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi Executing in SENDER mode... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Sending message 0[New message at Thu Jul 31 02:03:36 CDT 2008 from thread [EMAIL PROTECTED] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Received message # 0 Received [ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId = null, originalDestination = null, originalTransactionId = null, producerId = null, destination = null, transactionId = null, expiration = 0, timestamp = 0, arrival = 0, correlationId = null, replyTo = null, persistent = false, type = null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody = false}] at Thu Jul 31 02:03:36 CDT 2008 in listener [EMAIL PROTECTED] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Sending message 1[New message at Thu Jul 31 02:03:39 CDT 2008 from thread [EMAIL PROTECTED] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Received message # 1 Received [ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId = null, originalDestination = null, originalTransactionId = null, producerId = null, destination = null, transactionId = null, expiration = 0, timestamp = 0, arrival = 0, correlationId = null, replyTo = null, persistent = false, type = null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody = false}] at Thu Jul 31 02:03:39 CDT 2008 in listener [EMAIL PROTECTED] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Sending message 2[New message at Thu Jul 31 02:03:42 CDT 2008 from thread [EMAIL PROTECTED] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Received message # 2 Received [ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId = null, originalDestination = null, originalTransactionId = null, producerId = null, destination = null, transactionId = null, expiration = 0, timestamp = 0, arrival = 0, correlationId = null, replyTo = null, persistent = false, type = null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody = false}] at Thu Jul 31 02:03:42 CDT 2008 in listener [EMAIL PROTECTED] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Sending message 3[New message at Thu Jul 31 02:03:45 CDT 2008 from thread [EMAIL PROTECTED] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Received message # 3 Received [ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId = null, originalDestination = null, originalTransactionId = null, producerId = null, destination = null, transactionId = null, expiration = 0, timestamp = 0, arrival = 0, correlationId = null, replyTo = null, persistent = false, type = null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody = false}] at Thu Jul 31 02:03:45 CDT 2008 in listener [EMAIL PROTECTED] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Sending message 4[New message at Thu Jul 31 02:03:48 CDT 2008 from thread [EMAIL PROTECTED] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Received message # 4 Received [ActiveMQObjectMessage {commandId = 0, responseRequired = false, messageId = null, originalDestination = null, originalTransactionId = null, producerId = null, destination = null, transactionId = null, expiration = 0, timestamp = 0, arrival = 0, correlationId = null, replyTo = null, persistent = false, type = null, priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = false, readOnlyBody = false}] at Thu Jul 31 02:03:48 CDT 2008 in listener [EMAIL PROTECTED] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -- View this message in context: http://www.nabble.com/Problems-with-simple-peer%3A---transport-config---Spring-tp18755772p18755772.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.