Message Transformer for Aerospike Connect for JMS
For the complete documentation index see: llms.txt
All documentation pages available in markdown.
You can use the Message Transformer to write custom code that reads incoming JMS messages, perform Aerospike commands or other transformations on them, and convert them into AerospikeRecordOperation objects.
Develop and bundle your Java SDK code as a .jar file, then add it to the Aerospike JMS Inbound Connector’s classpath. Use the configuration file to specify parameters for seamless, pluggable integration.
Example use cases
-
Modify maps or lists in JMS messages before writing the output Aerospike records to your Aerospike databases. For example, you could add an element from incoming messages to maps or lists, or create maps of maps.
-
Filter messages for compliance use cases. For example, you can filter out records containing Personally Identifiable Information (PII), or you can mask fields with sensitive data prior to writing records to an Aerospike database.
-
Create Aerospike records with bins generated by tweaking JMS message values. You can even extend your message transformer to create Aerospike keys.
What does it not do?
- It’s not meant for heavy-weight processing or calling external APIs (outside the Aerospike JMS Inbound Connector). Consider using Apache Spark for these use cases.
- It does not support transactions with several commands isolated from commands outside of the transaction and executed atomically. However, it does support a read/write command that does one or more operations on the same record, as well as reads from the database during the transformation.
- It does not transform messages outbound from Aerospike to JMS. Consider using XDR filtering for such messages.
Developing a message transformer
Add the Maven SDK dependency
The dependency looks like this:
<dependency> <groupId>com.aerospike</groupId> <artifactId>aerospike-connect-inbound-sdk</artifactId> <version>1.4.2</version></dependency>For full details, see the Maven repository, and an example pom.xml file that includes this dependency is available in the GitHub repository.
Implement the InboundMessageTransformer interface
There are two ways to implement the InboundMessageTransformer interface:
Using InboundMessage<K, M>
The generic type K represents your nullable JMS record key class. M is the JMS Message. The fields of the JMS message are parsed as a map. The key and the sink record are sent separately.
You have the option to inject the following objects in your message-transformer class using Java Dependency Injection.
| Class | Usage |
|---|---|
| AerospikeReader | An object to read a record from the Aerospike Database. |
| InboundMessageTransformerConfig | The custom parameters provided in the configuration file as params. |
Using JMS Message
If you use Message directly in your implementation, your code must handle the parsing of messages.
Thread safety
- If you annotate your implementation with @Singleton, it has to be thread safe because one instance can be used by multiple threads.
- If you do not annotate your implementation with @Singleton, a new instance of your message transformer is created for every incoming message.
Configure the connector to use your message transformer
Include the message-transformer stanza in the topics or queues stanza in the aerospike-jms-inbound.yml file.
Here is an example:
topics: users: ..... message-transformer: class: com.aerospike.connect.inbound.CasCDTCustomTransformer params: cdtListLimit: 10 fieldNamePrefix: 'cdt_impl'The stanza takes these parameters:
| Parameter | Required | Description |
|---|---|---|
class | Yes | Fully-qualified name of the class that implements InboundMessageTransformer. |
params | No | Additional parameters that you want to use in your implementation. You need to inject InboundMessageTransformerConfig in your message-transformer class to set up your parameters. |
Deploy your message transformer
Deploy your .jar file, along with any dependencies it might have, by copying it to the /opt/aerospike-jms-inbound/usr-lib/ folder of the directory where the Aerospike JMS inbound connector is installed.
Look through example transformers
See here for a few examples of Message Transformers for Aerospike.