-
Notifications
You must be signed in to change notification settings - Fork 0
sample application spring activemq
tikalk/fuse.dbsynch.sample
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
dbsynch sample app this sample demonstrates a spring , activemq and MySql application using XA(JTA) transactions. the application is meant to copy a database table from one database to another using JMS as the transport. there are three components: * server - this is the activemq broker, activemq is embedded in a spring context. * producer - this is a client to the broker, it reads rows from a database table,source_table, and for every row sends a JMS message to a queue called source-queue. * collector - this is a client that reads messages from source-queue and for every message creates a database row in a table called dest_table. The stack used in the sample: Spring as a container. Activemq MySql Atomikos XA tansactions: this sample shows two implementations to manage jms and jdbc resources in one transaction. * A non xa transaction where both resources are just committed one after the other in a way that if one of them fails it will not create a lot of damage, maybe a message will be processed twice. * JTA XA transactions using Atomikos, http://www.atomikos.com/Main/WebHome see the spring files in producer and collector projects , nonxa-XX and atomikos-xa-XX. things to remember with JTA: the data base ,driver and data source must be XA enabled. Performance is poor with XA. Many data bases do not fully implement JTA. build: this is a maven project. to build the project, from the top most directory,where the parent pom is, execute 'mvn clean install' the projects are: * server - this is the server project mainly used to embed activemq in a spring context.activemq can also be run out of the box, but embedding it in a spring application will make it easier to add functionality, for example we can add beans that connect to the broker with VM transport ,more control on activemq properties. * server-runtime - creates a runtime directory for the server. * common - a project with common classes for the three components. * producer - this is the client that reads the source table and sends a JMS message for every row. * producer-runtime - creates a runtime directory for the producer.collector - this is the client that reads the messages with the source rows and inserts rows to the dest_table. * collector – the client that reads the jms queue and inserts rows to the DB * collector-runtime - creates the runtime directory for the collector. IDE: to load to intelij IDEA just do: file -> open project , and select the parent pom, idea will do the rest. to load to eclipse execute 'mvn eclipse:eclipse' from the top directory and load the projects to eclipse. or use m2eclipse plugin. Unit tests: Unit tests with xa will work only with a data base that supports xa, also, an activemq broker must run in order for the unit tests to run. To build without unit tests run maven with -Dmaven.test.skip=true PubSub to demonstrait pubsub domain: the server publishes a notification to notification.topic every some interval. see: /server/src/main/resources/spring/spring-config-notifier.xml both the producer and collector subscribe to this topic and receive notifications. see: /collector/src/main/resources/spring/spring-config-notification.xml /producer/src/main/resources/spring/spring-config-notification.xml the collector can also be a durable subscriber,set the property durable=true in collector.properties the client id for the collector durable subscription is passed in the collector.properties file. to run two instances change the client id for each execution.
About
sample application spring activemq
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published