5.4. Configuring the Post Office

The post office routes messages to their destination or destinations. It maintains the mappings between the addresses to which a message can be sent, and the final queue. For example, when sending a message with an address that represents a JMS queue, the post office routes the message to that JMS queue. When sending a message with an address that represents a JMS topic, the post office routes the message to a set of queues — one for each JMS subscription.
The post office also handles the persistence for address mapping.
JBoss Messaging post offices are cluster-aware. In a cluster, they automatically route (push) and pull messages between nodes in order to provide fully-distributed JMS queues and topics.
Configure the post office in the <database type>-persistence-service.xml file. For example:
<mbean code="org.jboss.messaging.core.jmx.MessagingPostOfficeService"
  name="jboss.messaging:service=PostOffice"
  xmbean-dd="xmdesc/MessagingPostOffice-xmbean.xml">
      
  <depends optional-attribute-name="ServerPeer">
    jboss.messaging:service=ServerPeer
  </depends>
                
  <depends>
    jboss.jca:service=DataSourceBinding,name=DefaultDS
  </depends>
      
  <depends optional-attribute-name="TransactionManager">
    jboss:service=TransactionManager
  </depends>
      
  <!-- The name of the post office -->                  
    
  <attribute name="PostOfficeName">JMS post office</attribute>
      
  <!-- The datasource used by the post office to access it's 
       binding information -->                     
      
  <attribute name="DataSource">java:/DefaultDS</attribute>
      
  <!-- If true will attempt to create tables and indexes on 
       every start-up -->
                        
  <attribute name="CreateTablesOnStartup">true</attribute>
      
  <!-- If true then we will automatically detect and reject 
       duplicate messages sent during failover -->
      
  <attribute name="DetectDuplicates">true</attribute>
      
  <!-- The size of the id cache to use when detecting duplicate 
       messages -->
      
  <attribute name="IDCacheSize">500</attribute>
      
  <attribute name="SqlProperties">
    CREATE_POSTOFFICE_TABLE=CREATE TABLE JBM_POSTOFFICE 
      (POSTOFFICE_NAME VARCHAR(255), 
      NODE_ID INTEGER, QUEUE_NAME VARCHAR(255), COND VARCHAR(1023), 
      SELECTOR VARCHAR(1023), CHANNEL_ID BIGINT, CLUSTERED CHAR(1), 
      ALL_NODES CHAR(1), 
      PRIMARY KEY(POSTOFFICE_NAME, NODE_ID, QUEUE_NAME)) ENGINE = INNODB

    INSERT_BINDING=INSERT INTO JBM_POSTOFFICE 
      (POSTOFFICE_NAME, NODE_ID, QUEUE_NAME, COND, SELECTOR, 
       CHANNEL_ID, CLUSTERED, ALL_NODES) 
      VALUES (?, ?, ?, ?, ?, ?, ?, ?)

    DELETE_BINDING=DELETE FROM JBM_POSTOFFICE WHERE 
      POSTOFFICE_NAME=? AND NODE_ID=? AND QUEUE_NAME=?

    LOAD_BINDINGS=SELECT QUEUE_NAME, COND, SELECTOR, 
      CHANNEL_ID, CLUSTERED, ALL_NODES FROM 
   JBM_POSTOFFICE WHERE POSTOFFICE_NAME=? AND NODE_ID=?
  </attribute>
      
  <!-- This post office is clustered. If you don't want a clustered post 
       office then set to false -->
      
  <attribute name="Clustered">true</attribute>
      
  <!-- All the remaining properties only have to be specified if the post 
       office is clustered. You can safely comment them out if your post 
       office is non clustered -->
      
  <!-- The JGroups group name that the post office will use -->            
      
  <attribute name="GroupName">
    ${jboss.messaging.groupname:MessagingPostOffice}
  </attribute>
      
  <!-- Max time to wait for state to arrive when the post office 
       joins the cluster -->            
                  
  <attribute name="StateTimeout">5000</attribute>
      
  <!-- Max time to wait for a synchronous call to node members using 
       the MessageDispatcher -->            
                  
  <attribute name="CastTimeout">50000</attribute>
      
  <!-- Set this to true if you want failover of connections to occur 
       when a node is shut down -->
      
  <attribute name="FailoverOnNodeLeave">false</attribute>
      
  <!-- JGroups stack configuration for the data channel - used for sending 
       data across the cluster --> 
                   
  <!-- By default we use the TCP stack for data -->                  
  <attribute name="DataChannelConfig">
    <config>
      <TCP start_port="7900"
        loopback="true"
        recv_buf_size="20000000"
        send_buf_size="640000"
        discard_incompatible_packets="true"
        max_bundle_size="64000"
        max_bundle_timeout="30"
        use_incoming_packet_handler="true"
        use_outgoing_packet_handler="false"
        down_thread="false" up_thread="false"
        enable_bundling="false"
        use_send_queues="false"
        sock_conn_timeout="300"
        skip_suspected_members="true"/>
      <MPING timeout="4000"
        bind_to_all_interfaces="true"
        mcast_addr="${jboss.messaging.datachanneludpaddress:228.6.6.6}"
        mcast_port="${jboss.messaging.datachanneludpport:45567}"
        ip_ttl="8"
        num_initial_members="2"
        num_ping_requests="1"/>                     
      <MERGE2 max_interval="100000"
        down_thread="false" up_thread="false" min_interval="20000"/>
      <FD_SOCK down_thread="false" up_thread="false"/>            
      <VERIFY_SUSPECT timeout="1500" down_thread="false" 
       up_thread="false"/>
      <pbcast.NAKACK max_xmit_size="60000"
        use_mcast_xmit="false" gc_lag="0"
        retransmit_timeout="300,600,1200,2400,4800"
        down_thread="false" up_thread="false"
        discard_delivered_msgs="true"/>
      <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
        down_thread="false" up_thread="false"
        max_bytes="400000"/>
      <pbcast.GMS print_local_addr="true" join_timeout="3000"
        down_thread="false" up_thread="false"
        join_retry_timeout="2000" shun="false"
        view_bundling="true"/>
    </config>        
  </attribute>
      
  <!-- JGroups stack configuration to use for 
       the control channel - used for control messages -->         
              
  <!-- We use udp stack for the control channel -->
  <attribute name="ControlChannelConfig">
    <config>
      <UDP
        mcast_addr="${jboss.messaging.controlchanneludpaddress:228.7.7.7}"
        mcast_port="${jboss.messaging.controlchanneludpport:45568}"
        tos="8"
        ucast_recv_buf_size="20000000"
        ucast_send_buf_size="640000"
        mcast_recv_buf_size="25000000"
        mcast_send_buf_size="640000"
        loopback="false"
        discard_incompatible_packets="true"
        max_bundle_size="64000"
        max_bundle_timeout="30"
        use_incoming_packet_handler="true"
        use_outgoing_packet_handler="false"
        ip_ttl="2"
        down_thread="false" up_thread="false"
        enable_bundling="false"/>
      <PING timeout="2000"
        down_thread="false" up_thread="false" num_initial_members="3"/>
      <MERGE2 max_interval="100000"
        down_thread="false" up_thread="false" min_interval="20000"/>
      <FD_SOCK down_thread="false" up_thread="false"/>
      <FD timeout="10000" max_tries="5" down_thread="false" 
        up_thread="false" shun="true"/>
      <VERIFY_SUSPECT timeout="1500" down_thread="false" 
       up_thread="false"/>
      <pbcast.NAKACK max_xmit_size="60000"
        use_mcast_xmit="false" gc_lag="0"
        retransmit_timeout="300,600,1200,2400,4800"
        down_thread="false" up_thread="false"
        discard_delivered_msgs="true"/>
      <UNICAST timeout="300,600,1200,2400,3600"
        down_thread="false" up_thread="false"/>
      <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
        down_thread="false" up_thread="false"
        max_bytes="400000"/>
      <pbcast.GMS print_local_addr="true" join_timeout="3000" 
        use_flush="true" flush_timeout="3000"
        down_thread="false" up_thread="false"
        join_retry_timeout="2000" shun="false"
        view_bundling="true"/>
      <FRAG2 frag_size="60000" down_thread="false" up_thread="false"/>
      <pbcast.STATE_TRANSFER down_thread="false" up_thread="false" 
        use_flush="true" flush_timeout="3000"/>
      <pbcast.FLUSH down_thread="false" up_thread="false" timeout="20000" 
        auto_flush_conf="false"/>
    </config>
  </attribute>    
      
</mbean>

5.4.1. Post Office Attributes

The following attributes are available to configure the Messaging Post Office:
DataSource
Specifies the data source used to persist post office mapping data.
SQLProperties
Specifies the DDL and DML for a particular database. If this attribute is not overridden, the default Hypersonic configuration will be used.

Important

Hypersonic is not supported for production environments. This value should be changed for production use.
CreateTablesOnStartup
Specifies whether tables and index are created when the post office service is started. When set to true, the post office will create tables and indexes on startup. If tables or indexes already exist, a SQLException is thrown by the JDBC driver, but this is ignored by the Persistence Manager and the operation continues unhindered. The default value is true.
DetectDuplicates
Specifies whether the post office will detect duplicate messages sent when delivery is restricted on a new node after server failure. When set to true, the post office detects duplicate messages . The default value is true.
IDCacheSize
Specifies the number of messages IDs the ID Cache should hold. If server failover occurs, the ID Cache is accessed as part of the process to prevent duplicate messages being sent after failover occurs. The default value is 500 (messages).
PostOfficeName
Specifies the name of the post office.
NodeIDView
Returns the node IDs of all nodes in a cluster as a set.
GroupName
Specifies the post office name to link with other identically named post offices.

Note

Post offices with the same group name will form a cluster together. Match post office group names to form a cluster with particular post offices.
Clustered
Specifies whether the post office will join a cluster to form distributed queues and topics. If set to false, all cluster-related attributes will be ignored.
StateTimeout
Specifies the maximum period of time the post office will wait to receive group state when a node joins a pre-existing cluster. The default value is 30000 milliseconds.
CastTimeout
Specifies the maximum time the post office will wait for a reply casting message synchronously. The default value is 30000 milliseconds.
FailoverOnNodeLeave
Specifies how connections are handled when a server node shuts down. If set to true, connections associated with the cleanly-terminated server node will failover onto another node. The default value is false.
MaxConcurrentReplications
Specifies the maximum number of concurrent replication reply requests to return before requests are blocked . This prevents JGroups overloading. The default value is 50.

Note

You should not alter the default value for MaxConcurrentReplications. The default value is the optimal setting.
ControlChannelConfig
Specifies JGroups stack configuration for the control channel. The control channel sends requests to and receives responses from other nodes in the cluster.

Note

JBoss Messaging uses JGroups for all group management. Standard JGroups configuration is used.
DataChannelConfig
Specifies JGroups stack configuration for the data channel. The data channel sends and receives messages to and from other nodes in the cluster, and replicates session data.

Note

JBoss Messaging uses JGroups for all group management. Standard JGroups configuration is used.