GoldenGate JMS Adapter: ActiveMQ Integration

Prepare GoldenGate, Database, Extract Process

* See this post to setup GoldenGate and database.

Install Java Adapter

* See this post to setup GoldenGate Java Adapter.

Overview

* Install ActiveMQ
* Create Data Pump
* Edit Params to point to user exit config file and java user exit config file
* Configure user exit
* Configure Java user exit to point to ActiveMQ.properties file
* Configure ActiveMQ

Install ActiveMQ

* Download ActiveMQ from http://activemq.apache.org/download.html.
* Unzip zip download (e.g. apache-activemq-5.3.1-bin.zip) onto a local directory.
* Set JAVA_HOME (e.g. set JAVA_HOME=C:\prog\java\jdk1.5.0_08)
* Start ActiveMQ by running ‘bin\activemq.bat’
* Open ActiveQ admin page at http://localhost:8161/admin/index.jsp

Create Data Pump

See above.

ADD EXTRACT u_gt, EXTTRAILSOURCE ./dirdat/gt

Edit Data Pump Params

See above.

Setup javaue.properties

# Java application properties for JMS lab using ActiveMQ as JMS server
 
# the handlerlist defines which handlers are active
gg.handlerlist=one,two,foo
 
# the first handler is just a single file
gg.handler.one.type=singlefile
gg.handler.one.format=xml
gg.handler.one.file=output.xml
 
gg.handler.two.type=singlefile
gg.handler.two.format=/dirprm/sample_tx.vm
gg.handler.two.file=output.txt
 
# jms handler: reads in activemq.properties config file too
gg.handler.foo.type=jms
gg.handler.foo.format=xml
gg.handler.foo.properties=/dirprm/activemq.properties
gg.handler.foo.destination=example.A
gg.classpath=C:/prog/apache-activemq-5.3.1/activemq-all-5.3.1.jar
 
# (commented out) set to "true" to turn OFF sending jms messages
# gg.handlerlist.nop=true

* Copy ‘javaue.properties’ to ‘dirprm’ directory.
* Copy ‘sample_tx.vm’ to dirprm directory.

Setup activemq.properties

* Create ‘activemq.properties’ file with content:

# if using queue
gg.jmshandler.queueortopic=queue
gg.jmshandler.destination=example.A
 
# if using topic
# gg.jmshandler.queueortopic=topic
# gg.jmshandler.destination=ggdemo.topicA
 
# if authentication is required
# gg.jmshandler.user=
# gg.jmshandler.password=
 
# session mode (try either: auto or dupsok)
#  auto:   Session.AUTO_ACKNOWLEDGE;
#  client: Session.CLIENT_ACKNOWLEDGE;
#  dupsok: Session.DUPS_OK_ACKNOWLEDGE;
gg.jmshandler.sessionmode=dupsok
 
gg.jmshandler.persistent=false
gg.jmshandler.durabletopic=false
 
# If using JNDI (default=true), 
#   then lookup managed objects from IntialContext.
# Else, if NOT using JNDI,
#   provide classname to instantiate a factory directly
gg.jmshandler.usejndi=false
 
# if using JNDI:  connection factory name to lookup
gg.jmshandler.connectionfactory=ConnectionFactory
 
# if NOT using JNDI: connection info
gg.jmshandler.connection.factoryclass=org.apache.activemq.ActiveMQConnectionFactory
#gg.jmshandler.connection.url=tcp://localhost:61616
gg.jmshandler.connection.url=tcp://localhost:61616?jms.useAsyncSend=true
 
gg.jmshandler.timetolive=50000
# gg.jmshandler.priority ­ JMS Priority
# gg.jmshandler.retry.times - JMS Retry Times
# gg.jmshandler.retry.initdelay - JMS Retry Init Delay MS
# gg.jmshandler.retry.expdelay=[true, false] - JMS Retry Exponential Delay
# gg.jmshandler.connection.url - JMS Url
# gg.jmshandler.connectionfactory - JMS Connection Factory Name
# gg.jmshandler.jndi.properties – Context Properties
# gg.jmshandler.usejndi=[true, false] - JMS Use JNDI
 
 
# ==========================================================
# The rest of the properties are standard JNDI properties
# passed directly to the IntialContext (used when usejndi=true)
# See the ActiveMQ & JMS documentation for settings.
 
java.naming.provider.url=tcp://localhost:61616
 
# embedded broker, eg: 
#  java.naming.provider.url=vm:broker:(tcp://localhost:61616)
#  java.naming.provider.url=vm://localhost
 
# topics can be registered in JNDI using the form
# topic.[jndiName] = [physicalName]
# topic.MyTopic = example.MyTopic
#   Then the topic can be looked up using "MyTopic".
#   The prefix topic/queue is stripped, so the jndi name begins after the prefix.
 
java.naming.factory.url.pkgs=org.apache.activemq.jndi
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
 
#  java.naming.security.principal=my_jndi_username 
#  java.naming.security.credentials=my_jndi_password

* Copy ‘activemq.properties’ to dirprm directory.

Insert Data to Source Table

INSERT INTO GG_SRC.gg_test VALUES ('100','One Hundred');
commit;

Check output.txt

Transaction: numOps=1 (buffer=1) ts='2010-05-08 03:14:28.000000' 
 Operation (seq=3/rba=1525 [W]): INSERT (INSERT) on table "GG_SRC.GG_TEST":
    GG_SRC.GG_TEST, (key=true) ID = "100"
    GG_SRC.GG_TEST, (key=false) NAME = "One Hundred"

Check ActiveMQ Queue

<operation table='GG_SRC.GG_TEST' type='INSERT' ts='2010-05-08 03:14:28.000000' pos='00000000030000001525' numCols='2'>
 <col name='ID' index='0'>
   <before missing='true'/>
   <after><![CDATA[100]]></after>
 </col>
 <col name='NAME' index='1'>
   <before missing='true'/>
   <after><![CDATA[One Hundred]]></after>
 </col>
</operation>
This entry was posted in goldengate. Bookmark the permalink.