You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Rob Davies <ra...@gmail.com> on 2008/08/01 08:33:32 UTC

Re: Problems with simple peer:// transport config & Spring

Hi new2mq,

I wonder if you're running into some gotcha's with the Spring  
JmsTemplate - and that you should be using a PooledConnectionFactory -  
see http://activemq.apache.org/spring-support.html
- to avoid the peer:// protocol from having to create its embedded  
broker, establish its network connection, search for other peers etc  
for every message - for every message sent, received etc.

cheers,

Rob
On 31 Jul 2008, at 15:24, new2mq wrote:

>
> 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)
> ///////////////////////
> [goodacre@VM-QA-701-ENT ~]$ /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
> org 
> .springframework 
> .context.support.ClassPathXmlApplicationContext@3eca90:
> display name
> [org 
> .springframework 
> .context.support.ClassPathXmlApplicationContext@3eca90];
> 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
> [org 
> .springframework 
> .context.support.ClassPathXmlApplicationContext@3eca90]:
> org 
> .springframework 
> .beans.factory.support.DefaultListableBeanFactory@1df280b
> Jul 31, 2008 9:15:07 AM
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> preInstantiateSingletons
> INFO: Pre-instantiating singletons in
> org 
> .springframework 
> .beans.factory.support.DefaultListableBeanFactory@1df280b:
> 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)
> ///////////////////////
> [goodacre@dacar-collector ~]$ /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
> org 
> .springframework 
> .context.support.ClassPathXmlApplicationContext@121cc40:
> display name
> [org 
> .springframework 
> .context.support.ClassPathXmlApplicationContext@121cc40];
> 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
> [org 
> .springframework 
> .context.support.ClassPathXmlApplicationContext@121cc40]:
> org 
> .springframework 
> .beans.factory.support.DefaultListableBeanFactory@8acf6e
> Jul 31, 2008 2:03:35 AM
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> preInstantiateSingletons
> INFO: Pre-instantiating singletons in
> org 
> .springframework 
> .beans.factory.support.DefaultListableBeanFactory@8acf6e:
> 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
> com.ssi.exp.TestMessageSender@7eb6e2]
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> 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
> com.ssi.exp.TestMessageListener@8aeb74
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> Sending message 1[New message at Thu Jul 31 02:03:39 CDT 2008 from  
> thread
> com.ssi.exp.TestMessageSender@7eb6e2]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> 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
> com.ssi.exp.TestMessageListener@8aeb74
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> Sending message 2[New message at Thu Jul 31 02:03:42 CDT 2008 from  
> thread
> com.ssi.exp.TestMessageSender@7eb6e2]
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> 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
> com.ssi.exp.TestMessageListener@8aeb74
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> Sending message 3[New message at Thu Jul 31 02:03:45 CDT 2008 from  
> thread
> com.ssi.exp.TestMessageSender@7eb6e2]
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> 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
> com.ssi.exp.TestMessageListener@8aeb74
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> Sending message 4[New message at Thu Jul 31 02:03:48 CDT 2008 from  
> thread
> com.ssi.exp.TestMessageSender@7eb6e2]
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> 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
> com.ssi.exp.TestMessageListener@8aeb74
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>
> 				
> -- 
> 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.
>


Re: Problems with simple peer:// transport config & Spring

Posted by new2mq <ch...@sungard.com>.
Ping to tickle the forum.

Bueller?  ... Bueller?


I made an interesting observation over the weekend that may help explain
what's going on here, but need some assistance.  

I've modified my spring configuration to use a PooledConnectionFactory.  I'm
using ActiveMQ 4.1.1 and the 1.1 JMS APIs (Hence JMSTemplate replacing
JMSTemplate102).   Here's the new spring conf:

<?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="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>   
   
  <bean id="jmsTopicConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL">
            <value>peer://mybrokergroup/mybrokername</value>
        </property>
      </bean>
    </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.DefaultMessageListenerContainer">
        <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.JmsTemplate">
        <property name="connectionFactory">
            <ref bean="jmsTopicConnectionFactory" />
        </property>
        <property name="defaultDestination">
            <ref bean="TestTopic" />
        </property>
        <property name="pubSubDomain">
            <value>true</value>
        </property>
    </bean>
</beans> 		

I start the listener and it waits patiently.   I start the sender-listener
and it sends (receives) its 5 messages.  Then, somewhat later (approx. 5
minutes, I see a message that DiscoveryNetworkConnector.onServiceAdd has
been invoked, and it looks like it finds the listener process.

Here is the output of the sender-listener process:

[goodacre@dacar-collector ~]$ /opt/java/bin/java -jar test-amq-peer.jar send
Loading Spring context...
        This should create the activemq listener and sender...
Aug 4, 2008 2:59:32 AM
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing
org.springframework.context.support.ClassPathXmlApplicationContext@1174b07:
display name
[org.springframework.context.support.ClassPathXmlApplicationContext@1174b07];
startup date [Mon Aug 04 02:59:32 CDT 2008]; root of context hierarchy
Aug 4, 2008 2:59:33 AM
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[spring-config.xml]
Aug 4, 2008 2:59:33 AM
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory
INFO: Bean factory for application context
[org.springframework.context.support.ClassPathXmlApplicationContext@1174b07]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@1e59128
Aug 4, 2008 2:59:33 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1e59128:
defining beans
[propertyConfigurer,jmsTopicConnectionFactory,TestTopic,SenderBean,MessageListener,TestJmsTopicListenerContainer,TestTopicJmsTemplate];
root of factory hierarchy
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.BrokerService getBroker
INFO: ActiveMQ 4.1.1 JMS Message Broker (mybrokername) is starting
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.BrokerService getBroker
INFO: For help or more information please see:
http://incubator.apache.org/activemq/
Aug 4, 2008 2:59:33 AM
org.apache.activemq.transport.TransportServerThreadSupport doStart
INFO: Listening for connections at: tcp://dacar-collector:46775
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.TransportConnector start
INFO: Connector tcp://dacar-collector:46775 Started
Aug 4, 2008 2:59:33 AM org.apache.activemq.network.NetworkConnector doStart
INFO: Network Connector bridge Started
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.BrokerService start
INFO: ActiveMQ JMS Message Broker (mybrokername,
ID:dacar-collector-53258-1217836773407-1:0) started
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.TransportConnector start
INFO: Connector vm://mybrokername Started


Waiting 1 minute to allow initiation to complete.
Aug 4, 2008 2:59:33 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 Mon Aug 04 03:00:33 CDT 2008 from thread
com.ssi.exp.TestMessageSender@8b8a47]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
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, droppable = false}] at Mon Aug 04 03:00:33 CDT 2008 in listener
com.ssi.exp.TestMessageListener@3a1834
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

{ ... messages 2 -4 sent and received within about 12 seconds -- snipped
from this log ..}
Aug 4, 2008 3:04:14 AM org.apache.activemq.network.DiscoveryNetworkConnector
onServiceAdd
INFO: Establishing network connection between from
vm://mybrokername?network=true to tcp://DACAR-ENGINE1:33096
Aug 4, 2008 3:04:14 AM
org.apache.activemq.network.DemandForwardingBridgeSupport startLocalBridge
INFO: Network connection between vm://mybrokername#4 and
tcp://DACAR-ENGINE1/10.15.2.104:33096(mybrokername) has been established.
Aug 4, 2008 3:09:14 AM org.apache.activemq.network.DiscoveryNetworkConnector
onServiceAdd
INFO: Establishing network connection between from
vm://mybrokername?network=true to tcp://DACAR-ENGINE1:33096
Aug 4, 2008 3:09:14 AM
org.apache.activemq.network.DemandForwardingBridgeSupport startLocalBridge
INFO: Network connection between vm://mybrokername#6 and
tcp://DACAR-ENGINE1/10.15.2.104:33096(mybrokername) has been established.


What I'm not sure about is, why so long?    I actually tried a version of
this test where I wait 6 minutes between the 4th and 5th message, and this
message still pops up several minutes after the last message.   So, to me,
that seems like it is somehow related not just purely to time, but to that
last message being delivered.

Note that when I run the listener and sender-listener on the same machine, I
get the "discovery" messages immediately:

Waiting 1 minute to allow initiation to complete.
Aug 4, 2008 3:22:21 AM org.apache.activemq.network.DiscoveryNetworkConnector
onServiceAdd
INFO: Establishing network connection between from
vm://mybrokername?network=true to tcp://dacar-collector:51954
Aug 4, 2008 3:22:21 AM
org.apache.activemq.network.DemandForwardingBridgeSupport startLocalBridge
INFO: Network connection between vm://mybrokername#2 and
tcp://localhost/127.0.0.1:51954(mybrokername) has been established.
Executing in SENDER mode...


Also, this looks like there are two brokers in play even within the
sender-listener process when they are on separate machines, but only one
when they are on the same machine.   Is that the way it's supposed to be?



-- 
View this message in context: http://www.nabble.com/Problems-with-simple-peer%3A---transport-config---Spring-tp18755772p18931248.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Problems with simple peer:// transport config & Spring

Posted by new2mq <ch...@sungard.com>.
I made an interesting observation over the weekend that may help explain
what's going on here, but need some assistance.  

I've modified my spring configuration to use a PooledConnectionFactory.  I'm
using ActiveMQ 4.1.1 and the 1.1 JMS APIs (Hence JMSTemplate replacing
JMSTemplate102).   Here's the new spring conf:

<?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="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>   
   
  <bean id="jmsTopicConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL">
            <value>peer://mybrokergroup/mybrokername</value>
        </property>
      </bean>
    </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.DefaultMessageListenerContainer">
        <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.JmsTemplate">
        <property name="connectionFactory">
            <ref bean="jmsTopicConnectionFactory" />
        </property>
        <property name="defaultDestination">
            <ref bean="TestTopic" />
        </property>
        <property name="pubSubDomain">
            <value>true</value>
        </property>
    </bean>
</beans> 		

I start the listener and it waits patiently.   I start the sender-listener
and it sends (receives) its 5 messages.  Then, somewhat later (approx. 5
minutes, I see a message that DiscoveryNetworkConnector.onServiceAdd has
been invoked, and it looks like it finds the listener process.

Here is the output of the sender-listener process:

[goodacre@dacar-collector ~]$ /opt/java/bin/java -jar test-amq-peer.jar send
Loading Spring context...
        This should create the activemq listener and sender...
Aug 4, 2008 2:59:32 AM
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing
org.springframework.context.support.ClassPathXmlApplicationContext@1174b07:
display name
[org.springframework.context.support.ClassPathXmlApplicationContext@1174b07];
startup date [Mon Aug 04 02:59:32 CDT 2008]; root of context hierarchy
Aug 4, 2008 2:59:33 AM
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[spring-config.xml]
Aug 4, 2008 2:59:33 AM
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory
INFO: Bean factory for application context
[org.springframework.context.support.ClassPathXmlApplicationContext@1174b07]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@1e59128
Aug 4, 2008 2:59:33 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1e59128:
defining beans
[propertyConfigurer,jmsTopicConnectionFactory,TestTopic,SenderBean,MessageListener,TestJmsTopicListenerContainer,TestTopicJmsTemplate];
root of factory hierarchy
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.BrokerService getBroker
INFO: ActiveMQ 4.1.1 JMS Message Broker (mybrokername) is starting
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.BrokerService getBroker
INFO: For help or more information please see:
http://incubator.apache.org/activemq/
Aug 4, 2008 2:59:33 AM
org.apache.activemq.transport.TransportServerThreadSupport doStart
INFO: Listening for connections at: tcp://dacar-collector:46775
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.TransportConnector start
INFO: Connector tcp://dacar-collector:46775 Started
Aug 4, 2008 2:59:33 AM org.apache.activemq.network.NetworkConnector doStart
INFO: Network Connector bridge Started
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.BrokerService start
INFO: ActiveMQ JMS Message Broker (mybrokername,
ID:dacar-collector-53258-1217836773407-1:0) started
Aug 4, 2008 2:59:33 AM org.apache.activemq.broker.TransportConnector start
INFO: Connector vm://mybrokername Started


Waiting 1 minute to allow initiation to complete.
Aug 4, 2008 2:59:33 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 Mon Aug 04 03:00:33 CDT 2008 from thread
com.ssi.exp.TestMessageSender@8b8a47]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
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, droppable = false}] at Mon Aug 04 03:00:33 CDT 2008 in listener
com.ssi.exp.TestMessageListener@3a1834
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

{ ... messages 2 -4 sent and received within about 12 seconds -- snipped
from this log ..}
Aug 4, 2008 3:04:14 AM org.apache.activemq.network.DiscoveryNetworkConnector
onServiceAdd
INFO: Establishing network connection between from
vm://mybrokername?network=true to tcp://DACAR-ENGINE1:33096
Aug 4, 2008 3:04:14 AM
org.apache.activemq.network.DemandForwardingBridgeSupport startLocalBridge
INFO: Network connection between vm://mybrokername#4 and
tcp://DACAR-ENGINE1/10.15.2.104:33096(mybrokername) has been established.
Aug 4, 2008 3:09:14 AM org.apache.activemq.network.DiscoveryNetworkConnector
onServiceAdd
INFO: Establishing network connection between from
vm://mybrokername?network=true to tcp://DACAR-ENGINE1:33096
Aug 4, 2008 3:09:14 AM
org.apache.activemq.network.DemandForwardingBridgeSupport startLocalBridge
INFO: Network connection between vm://mybrokername#6 and
tcp://DACAR-ENGINE1/10.15.2.104:33096(mybrokername) has been established.


What I'm not sure about is, why so long?    I actually tried a version of
this test where I wait 6 minutes between the 4th and 5th message, and this
message still pops up several minutes after the last message.   So, to me,
that seems like it is somehow related not just purely to time, but to that
last message being delivered.

Also, this looks like there are two brokers in play even within the
sender-listener process.   Is that the way it's supposed to be?




I gave that a try with rather mixed results.

The very time I deployed the new jar, it looked like discovery may have
succeeded between machine A (listen/send) and machine B(listen-only),
because machine B  complained that it could not resolve machine A's
hostname:

INFO: JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
Aug 1, 2008 8:35:15 AM org.apache.activemq.network.DiscoveryNetworkConnector
onServiceAdd
INFO: Establishing network connection between from
vm://mybrokername?network=true to tcp://dacar-collector:44832
Aug 1, 2008 8:35:15 AM org.apache.activemq.network.DiscoveryNetworkConnector
onServiceAdd
WARNING: Could not start network bridge between:
vm://mybrokername?network=true and: tcp://dacar-collector:44832 due to:
java.net.UnknownHostException: dacar-collector


I'm close!  I thought, and promptly added an  /etc/hosts file entry on both
boxes (each for the other).   

However, subsequent tests failed to give any indication that discovery had
completed -- in fact I never see a line after this (when running as listener
only):
INFO: JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi

What logging can I turn up (and how do I do it with or without Spring) to
get better visibility into the discovery process?    

-chris


I will give that a try and post back with the results.   Am I correct in
assuming that, at least after a cursory review, it looks like this *should*
work?  For example, there's nothing flagrantly wrong with the peer URI?  
Should it be the same URI in both peers (I assume so).  There's no explicit
broker configuration that needs be done? 

Thanks for taking a look at this, Rob.

-chris


-- 
View this message in context: http://www.nabble.com/Problems-with-simple-peer%3A---transport-config---Spring-tp18755772p18813600.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Problems with simple peer:// transport config & Spring

Posted by new2mq <ch...@sungard.com>.
I gav e that a try with rather mixed results.

The very time I deployed the new jar, it looked like discovery may have
succeeded between machine A (listen/send) and machine B(listen-only),
because machine B  complained that it could not resolve machine A's
hostname:

INFO: JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
Aug 1, 2008 8:35:15 AM org.apache.activemq.network.DiscoveryNetworkConnector
onServiceAdd
INFO: Establishing network connection between from
vm://mybrokername?network=true to tcp://dacar-collector:44832
Aug 1, 2008 8:35:15 AM org.apache.activemq.network.DiscoveryNetworkConnector
onServiceAdd
WARNING: Could not start network bridge between:
vm://mybrokername?network=true and: tcp://dacar-collector:44832 due to:
java.net.UnknownHostException: dacar-collector


I'm close!  I thought, and promptly added an  /etc/hosts file entry on both
boxes (each for the other).   

However, subsequent tests failed to give any indication that discovery had
completed -- in fact I never see a line after this (when running as listener
only):
INFO: JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi

What logging can I turn up (and how do I do it with or without Spring) to
get better visibility into the discovery process?    

-chris


I will give that a try and post back with the results.   Am I correct in
assuming that, at least after a cursory review, it looks like this *should*
work?  For example, there's nothing flagrantly wrong with the peer URI?  
Should it be the same URI in both peers (I assume so).  There's no explicit
broker configuration that needs be done? 

Thanks for taking a look at this, Rob.

-chris


Hi new2mq,

I wonder if you're running into some gotcha's with the Spring  
JmsTemplate - and that you should be using a PooledConnectionFactory -  
see http://activemq.apache.org/spring-support.html
- to avoid the peer:// protocol from having to create its embedded  
broker, establish its network connection, search for other peers etc  
for every message - for every message sent, received etc.

cheers,

Rob

-- 
View this message in context: http://www.nabble.com/Problems-with-simple-peer%3A---transport-config---Spring-tp18755772p18775033.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Problems with simple peer:// transport config & Spring

Posted by new2mq <ch...@sungard.com>.
I will give that a try and post back with the results.   Am I correct in
assuming that, at least after a cursory review, it looks like this *should*
work?  For example, there's nothing flagrantly wrong with the peer URI?  
Should it be the same URI in both peers (I assume so).  There's no explicit
broker configuration that needs be done? 

Thanks for taking a look at this, Rob.

-chris


Hi new2mq,

I wonder if you're running into some gotcha's with the Spring  
JmsTemplate - and that you should be using a PooledConnectionFactory -  
see http://activemq.apache.org/spring-support.html
- to avoid the peer:// protocol from having to create its embedded  
broker, establish its network connection, search for other peers etc  
for every message - for every message sent, received etc.

cheers,

Rob

{ ... intro snipped .. }
> 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> 		
>
{ ... code sample snipped .. }
-- 
View this message in context: http://www.nabble.com/Problems-with-simple-peer%3A---transport-config---Spring-tp18755772p18774090.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.