activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MartyH <martin.hender...@singularity.co.uk>
Subject broker network with both way communication
Date Tue, 20 Mar 2007 12:08:02 GMT

Hi folks,
Having some diffs with a network of brokers and communication both ways in
it.  I have a master that receives updates from a slave, but the slave also
gets the odd message from the master.

I configured it like this for the slave:
[code]
<beans>
  <broker xmlns="http://activemq.org/config/1.0" brokerName="slave"
persistent="true" useJmx="false">
    
    <transportConnectors>
      <transportConnector uri="tcp://localhost:62003"/>
    </transportConnectors>

    <networkConnectors>
	  <networkConnector uri="static:(tcp://localhost:62002)" failover="true"/>      
    </networkConnectors>

    <persistenceAdapter>
      <memoryPersistenceAdapter/>
    </persistenceAdapter>
  </broker> 
</beans>

  <bean id="jmsFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker2">
    <property name="brokerURL" value="tcp://localhost:62003" />
  </bean>
  
  <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory">
      <bean
class="org.springframework.jms.connection.SingleConnectionFactory">
        <property name="targetConnectionFactory">
          <ref local="jmsFactory" />
        </property>
      </bean>
    </property>
    <property name="defaultDestinationName" value="data.queue"/>
  </bean>  

  <bean id="jencks" class="org.jencks.JCAContainer">
    <property name="bootstrapContext">
      <bean class="org.jencks.factory.BootstrapContextFactoryBean">
        <property name="threadPoolSize" value="25"/>
      </bean>
    </property>
    <property name="resourceAdapter">
      <bean id="activeMQResourceAdapter"
class="org.apache.activemq.ra.ActiveMQResourceAdapter">
        <property name="serverUrl" value="tcp://localhost:62003"/>
      </bean>
    </property>
  </bean>

  <!-- Inbound message connector wired to the message listener  -->
  <bean id="inboundConnectorA" class="org.jencks.JCAConnector">
    <property name="jcaContainer" ref="jencks" />
    <property name="activationSpec">
      <bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
        <property name="destinationType" value="javax.jms.Queue"/>
		<property name="destination" value="update.queue"/>     
      </bean>
    </property>
    <property name="ref" value="listenerService"/>
  </bean>
[/code]

so that the slave should receive updates on the update.queue.

The master is configured like so:

[code]
<beans>

  <broker xmlns="http://activemq.org/config/1.0" brokerName="master"
persistent="true" useJmx="false" deleteAllMessagesOnStartup="false">
     
    <transportConnectors>
      <transportConnector uri="tcp://localhost:62002"/>
    </transportConnectors>
     
    <networkConnectors>
    </networkConnectors>

    <persistenceAdapter>
		<journaledJDBC journalLogFiles="5" dataDirectory="/activemq-data"/>
    </persistenceAdapter>
  </broker>
</beans>  

  <bean id="jmsFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker1">
    <property name="brokerURL" value="tcp://localhost:62002" />
  </bean>
  
  <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory">
      <bean
class="org.springframework.jms.connection.SingleConnectionFactory">
        <property name="targetConnectionFactory">
          <ref local="jmsFactory" />
        </property>
      </bean>
    </property>
    <property name="defaultDestinationName" value="update.queue"/>
  </bean>



  <bean id="jencks" class="org.jencks.JCAContainer">
    <property name="bootstrapContext">
      <bean class="org.jencks.factory.BootstrapContextFactoryBean">
        <property name="threadPoolSize" value="25"/>
      </bean>
    </property>
    <property name="resourceAdapter">
      <bean id="activeMQResourceAdapter"
class="org.apache.activemq.ra.ActiveMQResourceAdapter">
        <property name="serverUrl" value="tcp://localhost:62002"/>
      </bean>
    </property>
  </bean>

  <bean id="inboundConnectorA" class="org.jencks.JCAConnector">
    <property name="jcaContainer" ref="jencks" />
    <property name="activationSpec">
      <bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
        <property name="destinationType" value="javax.jms.Queue"/>
		<property name="destination" value="data.queue"/>
      </bean>
    </property>
    <property name="ref" value="listenerService"/>
  </bean>

[/code]
so it sends to the update queue and listens on the data queue.

I also register the slave broker programmatically... using a message
listener 
[code]
NetworkConnector connector = this.broker.addNetworkConnector(address);
connector.setName(address);
connector.start();
[/code]

and this fires up the log messages:
[code]
svi INFO [Thread-1] NetworkConnector.onServiceAdd(96) | Establishing network
connection between from vm://master?network=true to
failover:tcp://localhost:62003
svi INFO [ActiveMQ Task] FailoverTransport.iterate(190) | Successfully
reconnected to tcp://localhost:62003
svi INFO [Thread-1] TransportConnector.start(232) | Connector vm://master
Started
svi INFO [Thread-1] NetworkConnector.doStart(279) | Network Connector
static:(failover:tcp://localhost:62003) Started

[/code]

now, the master seems to get messages from the slave, but the slave doesn't
seem to get messages from the master.... is there something dull in the
config i'm missing?

thanks

Marty
-- 
View this message in context: http://www.nabble.com/broker-network-with-both-way-communication-tf3433284s2354.html#a9571094
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message