Java Message Service (JMS)
The Java Message Service (JMS) Handler allows operations from a trail file to be formatted in messages, and then published to JMS providers like Oracle Weblogic Server, Websphere, and ActiveMQ.
This chapter describes how to use the JMS Handler.
Overview
The Java Message Service is a Java API that allows applications to create, send, receive, and read messages. The JMS API defines a common set of interfaces and associated semantics that allow programs written in the Java programming language to communicate with other messaging implementations.
The JMS Handler captures the Oracle GoldenGate trail and sends those messages to the configured JMS providers. Note: The Java Message Service (JMS) Handler does not support DDL operations. In case of DDL operations, replicat/extract is expected to fail.
Setting Up and Running the JMS Handler
The JMS Handler setup (JNDI configuration) depends on the JMS provider that you use.
The following sections provide instructions for configuring the JMS Handler components and running the handler.
Runtime Prerequisites
The JMS provider should be up and running with the required ConnectionFactory and QueueConnectionFactory and TopicConnectionFactory configured.
Security
Configure the SSL according to the JMS Provider used.
-
Classpath Configuration Oracle recommends that you store the JMS Handler properties file in the Oracle GoldenGate
dirprmdirectory.
Classpath Configuration
Oracle recommends that you store the JMS Handler properties file in the Oracle GoldenGate dirprm directory.
The JMS Handler requires the JMS Provider client JARs are in the classpath in order to execute. Additionally, in Java 8, the Java EE Specification classes have been moved out of the JDK to an independent project. JMS is a part of the Java EE Specification so the Java EE Specification jar is an additional depdendency. For more information to download the jar, see JMS Dependencies.
The location of the providers client JARs is similar to:
gg.classpath= path_to_the_providers_client_jars
Java Naming and Directory Interface Configuration
You configure the Java Naming and Directory Interface (JNDI) properties to connect to an Initial Context to look up the connection factory and initial destination.
Table 38 JNDI Configuration Properties
| Properties | Required/ Optional | Legal Values | Default | Explanation |
|---|---|---|---|---|
java.naming.provider.url |
Required | Valid provider URL with port | None | Specifies the URL that the handler uses to look up objects on the server. For example, t3://localhost:7001 or if SSL is enabled t3s://localhost:7002. |
java.naming.factory.initial |
Required | Initial Context factory class name | None | Specifies which initial context factory to use when creating a new initial context object. For Oracle WebLogic Server, the value is weblogic.jndi.WLInitialContextFactory. |
java.naming.security.principal |
Required | Valid user name | None | Specifies the user name to use. |
java.naming.security.credentials |
Required | Valid password | None | Specifies the password for the user. |
Topic/Queue Name Selection
The destination is resolved at runtime using this configuration parameter: gg.handler.name.destinationTemplate. You can configure a static string, keywords, or a combination of static strings and keywords to dynamically resolve the topic/queue name at runtime based on the context of the current operation, see Using Templates to Resolve the Topic Name and Message Key for sample templates.
The replicat will autocreate the target Queue/Topic if not already present. Note: Auto creation of Queue/Topic is not supported for the Oracle WebLogic Server.
Handler Configuration
You configure the JMS Handler operation using the properties file. These properties are located in the Java Adapter properties file (not in the Replicat properties file).
To enable the selection of the JMS Handler, you must first configure the handler type by specifying gg.handler.name.type=jms and the other JMS properties as follows:
Table 39 JMS Handler Configuration
| Properties | Required/ Optional | Legal Values | Default | Explanation |
| — | — | — | — | — |
| gg.handler.name.type | Required | JMS | None | Set to jms to send transactions, operations, and metadata as formatted text messages to a JMS provider. Set to jms_map to send JMS map messages. |
| gg.handler.name.destinationTemplate | Required | Valid queue or topic name template | None | Sets the queue or topic to which the message is sent. This must be correctly configured on the JMS server. For example, for a static queue/topic queue/A, queue.Test, example.MyTopic. For example, queue/A, queue.Test, example.MyTopic. |
| gg.handler.name.destinationType | Optional | queue | topic | queue | Specifies whether the handler is sending to a queue (a single receiver) or a topic (publish/subscribe). The gg.handler.name.queueOrTopic property is an alias of this property. Set to queue removes a message from the queue once it has been read. Set to topic publishes messages and can be delivered to multiple subscribers. |
| gg.handler.name.connectionFactory | Required | Valid connection factory name | None | Specifies the name of the connection factory to lookup using JNDI. The gg.handler.name.ConnectionFactoryJNDIName property is an alias of this property. . |
| gg.handler.name.useJndi | Optional | true | false | true | Set to false, then JNDI is not used to configure the JMS client. Instead, factories and connections are explicitly constructed. |
| gg.handler.name.connectionUrl | Optional | Valid connection URL | None | Specify only when you are not using JNDI to explicitly create the connection. |
| gg.handler.name.connectionFactoryClass | Optional | Valid connectionFactoryClass | None | Set to access a factory only when not using JNDI. The value of this property is the Java class name to instantiate, which constructs a factory object explicitly. |
| gg.handler.name.physicalDestination | Optional | Name of the queue or topic object obtained through the ConnectionFactory API instead of the JNDI provider | None | The physical destination is important when JMS is configured to use JNDI. The ConnectionFactory is resolved through a JNDI lookup. Setting the physical destination means that the queue or topic is resolved by invoking a method on the ConnectionFactory instead of invoking JNDI. |
| gg.handler.name.user | Optional | Valid user name | None | The user name to send messages to the JMS server. |
| gg.handler.name.password | Optional | Valid password | None | The password to send messages to the JMS server. |
| gg.handler.name.sessionMode | Optional | auto | client | dupsok | auto | <p>Sets the JMS session mode, these values equate to the standard JMS values:</p><dl> <dt class="dlterm">Session.AUTO_ACKNOWLEDGE</dt><p><p>The session automatically acknowledges a client’s receipt of a message either when the session has successfully returned from a call to receive or when the message listener the session has called to process the message successfully returns.</p></p><dt class="dlterm">Session.CLIENT_ACKNOWLEDGE</dt><p><p>The client acknowledges a consumed message by calling the message’s acknowledge method.</p></p><dt class="dlterm">Session.DUPS_OK_ACKNOWLEDGE</dt><p><p>This acknowledgment mode instructs the session to lazily acknowledge the delivery of messages.</p></p></dl> |
| gg.handler.name.localTX | Optional | true | false | true | Sets whether local transactions are used when sending messages. Local transactions are enabled by default, unless sending and committing single messages one at a time. Set to false to disable local transactions. |
| gg.handler.name.persistent | Optional | true | false | true | Sets the delivery mode to persistent or not. If you want the messages to be persistent, the JMS provider must be configured to log the message to stable storage as part of the client’s send operation. |
| gg.handler.name.priority | Optional | Valid integer between 0-10 | 4 | The JMS server defines a 10 level priority value, with 0 as the lowest and 9 as the highest. |
| gg.handler.name.timeToLive | Optional | Time in milliseconds | 0 | Sets the length of time in milliseconds from its dispatch time that a produced message is retained by the message system. Set to zero specifies that the time is unlimited. |
| gg.handler.name.custom | Optional | Class names implementing ` oracle.goldengate.messaging.handler.GGMessageLifeCycleListener | None | Configures a message listener allowing properties to be set on the message before it is delivered. |
| gg.handler.*name.*format | Optional | xml \| tx2ml \| xml2 \| minxml \| csv \| fixed \| text \| logdump \| json \| json_op \| json_row \| delimitedtext \| Velocity template | delimitedtext | {::nomarkdown}<p>Specifies the format used to transform operations and transactions into messages sent to the JMS server.</p><p>The velocity template should point to the location of the template file. Samples are available under: <code>AdapterExamples/java-delivery/sample-dirprm</code>/.</p><p>Example: <code class="codeph">format_op2xml.vm </code></p><pre class="pre codeblock"><code><$op.TableName sqlType='$op.sqlType' opType='$op.opType' txInd='$op.txState' ts='$op.Timestamp' numCols='$op.NumColumns' pos='$op.Position'> #foreach( $col in $op ) #if( ! $col.isMissing()) <$col.Name colIndex='$col.Index'> #if( $col.hasBefore()) #if( $col.isBeforeNull()) <before><isNull/></before> #else <before><![CDATA[$col.before]]></before> #{end}## if col has 'before' value #{end}## if col 'before' is null #if( $col.hasValue()) #if( $col.isNull()) <after><isNull/></after> #{else} <after><![CDATA[$col.value]]></after> #{end}## if col is null #{end}## if col has value </$col.Name> #{end}## if column is not missing #{end}## for loop over columns </$op.TableName> </code></pre> {:/} |
| gg.handler.*name.*includeTables | Optional | List of valid table names | None | {::nomarkdown}<p>Specifies a list of tables the handler will include.</p><p>If the schema (or owner) of the table is specified, then only that schema matches the table name. Otherwise, the table name matches any schema. A comma separated list of tables can be specified. For example, to have the handler only process tables <code class="codeph">foo.customer</code> and <code class="codeph">bar.orders</code>.</p><p>If the catalog and schema (or owner) of the table are specified, then only that catalog and schema matches the table name. Otherwise, the table name matches any catalog and schema. A comma separated list of tables can be specified. For example, to have the handler only process tables <code class="codeph">dbo.foo.customer</code> and <code class="codeph">dbo.bar.orders</code>.</p><p>If any table matches the include list of tables, the transaction is included.</p><p>The list of table names specified are case sensitive.</p> {:/} |
| gg.handler.*name.*excludeTables | Optional | List of valid table names | None | {::nomarkdown}<p>Specifies a list of tables the handler will exclude.</p><p>To selectively process operations on a table by table basis, the handler must be processing in operation mode. If the handler is processing in transaction mode, then when a single transaction contains several operations spanning several tables. If any table matches the exclude list of tables, the transaction is excluded.</p><p>The list of table names specified are case sensitive.</p> {:/} |
| gg.handler.*name.*mode | Optional | op \| tx | op | Specifies whether to output one operation per message (op) or one transaction per message (tx). |
| gg.handler.name.metaHeadersTemplate | Optional | Comma delimited list of metacolumn keywords. | None | Allows you to select metacolumns to inject context-based key value pairs into JMS message header properties using the metacolumn keyword syntax. JMS metacolumn Headers are not supported in transactional mode. <p>Example:</p>gg.handler.sample_jms.metaHeadersTemplate=${primarykeys[JMSXGroupID]}` |
Sample Configuration Using Oracle WebLogic Server
#JMS Handler Template
gg.handlerlist=jms
gg.handler.jms.type=jms
#TODO: Set the message formatter type
gg.handler.jms.format=
#TODO: Set the destination for resolving the queue/topic name.
gg.handler.jms.destinationTemplate=
#Start of JMS handler properties when JNDI is used.
gg.handler.jms.useJndi=true
#TODO: Set the connectionFactory for resolving the queue/topic name.
gg.handler.jms.connectionFactory=
#TODO: Set the standard JNDI properties url, initial factory name, principal and credentials.
java.naming.provider.url=
java.naming.factory.initial=
java.naming.security.principal=
java.naming.security.credentials=
End of JMS handler properties when JNDI is used.
#Start of JMS handler properties when JNDI is not used.
#TODO: Comment the above properties related to useJndi is true.
#TODO: Uncomment the below properties to configure when useJndi is false.
#gg.handler.jms.useJndi=false
#TODO: Set connectionURL of MQ.
#gg.handler.jms.connectionUrl=
#TODO: Set the connection Factory Class of the MQ.
#gg.handler.jms.connectionFactoryClass=
#TODO: Set the path the jms client library wlthint3client.jar
gg.classpath=
jvm.bootoptions=-Xmx512m -Xms32m
JMS Dependencies
The Java EE Specification APIs have moved out of the JDK in Java 8. JMS is a part of this specification, and therefore this dependency is required.
Maven groupId: javax
Maven artifactId: javaee-api
Version: 8.0
You can download the jar from Maven Central Repository.
JMS 8.0
javaee-api-8.0.jar