Skip to content

Instantly share code, notes, and snippets.

@cemartins
Last active August 29, 2015 13:56
Show Gist options
  • Save cemartins/0a7c12da85936f8c553f to your computer and use it in GitHub Desktop.
Save cemartins/0a7c12da85936f8c553f to your computer and use it in GitHub Desktop.
Node 1 setup - wildfly 8 hosting application 1 that holds a durable subscription to the event messages topic through a remote connection to Node 2
<!-- Local connection factory that "points" to Node2's hornetq broker -->
<bean id="jmsEventsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/Node2Broker" />
</bean>
<!-- Listener container to establish a durable subscrition to the EventsTopic in Node2 -->
<bean id="node2EventListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="concurrentConsumers" value="1"/>
<property name="connectionFactory" ref="jmsEventsConnectionFactory"/>
<property name="destinationName" value="EventsTopic"/> <!-- Note: must use this name and not "jms/topic/SunsetEventsTopic" -->
<property name="sessionTransacted" value="true"/>
<property name="pubSubDomain" value="true"/>
<property name="subscriptionDurable" value="true"/>
<property name="durableSubscriptionName" value="SunsetIntegration"/>
</bean>
<!-- the channel that receives input from the node2 events topic -->
<jms:message-driven-channel-adapter id="jmsEventsIn" channel="fromnode2Events" container="node2EventListenerContainer" />
<int:channel id="fromNormaEvents">
<int:interceptors>
<int:wire-tap channel="loggingChannel"/>
</int:interceptors>
</int:channel>
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
<hornetq-server>
<persistence-enabled>false</persistence-enabled>
<journal-file-size>102400</journal-file-size>
<journal-min-files>2</journal-min-files>
<connectors>
<!-- Remote Connector "pointing" to node2's broker -->
<netty-connector name="netty-node2" socket-binding="node2-jms-broker">
</netty-connector>
<in-vm-connector name="in-vm" server-id="0"/>
</connectors>
<acceptors>
<in-vm-acceptor name="in-vm" server-id="0"/>
</acceptors>
<security-settings>
<security-setting match="#">
<permission type="send" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
</security-setting>
</security-settings>
<address-settings>
<address-setting match="#">
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
<expiry-address>jms.queue.ExpiryQueue</expiry-address>
<redelivery-delay>0</redelivery-delay>
<max-size-bytes>10485760</max-size-bytes>
<page-size-bytes>2097152</page-size-bytes>
<address-full-policy>PAGE</address-full-policy>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
</address-setting>
</address-settings>
<jms-connection-factories>
<connection-factory name="InVmConnectionFactory">
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/ConnectionFactory"/>
</entries>
</connection-factory>
<!-- Connection factory allowing spring applications to access the Node 2 broker transparently -->
<pooled-connection-factory name="node2-broker">
<client-id>node1-messaging</client-id>
<user>Guest</user>
<password>Guest</password>
<transaction mode="xa"/>
<connectors>
<connector-ref connector-name="netty-node2"/>
</connectors>
<entries>
<entry name="java:/Node2Broker"/>
<entry name="java:jboss/Node2Broker"/>
</entries>
</pooled-connection-factory>
</jms-connection-factories>
</hornetq-server>
</subsystem>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:8080}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<!-- Socket to plug into node2's embedded hornetq broker -->
<outbound-socket-binding name="node2-jms-broker">
<remote-destination host="${node2.broker.host:127.0.0.1}" port="${node2.broker.port:5445}"/>
</outbound-socket-binding>
</socket-binding-group>
@cemartins
Copy link
Author

Spring integration App that runs on a wildfly 8 application server and listens to event messages published on a remote wildfly server, through a durable subscription.

See also Node 2, the spring app that is deployed to another wildfly standalone instance and publishes event messages to it's local hornetq subsystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment