This package will contain Java samples that demonstrate how to Serialize and Deserialize Messages with the Solace JCSMP API.
For information about how to deploy and configure the Solace Schema Registry, please refer to our documentation here: https://docs.solace.com/Schema-Registry/schema-registry-overview.htm
To upload a schema in the Solace Schema Registry, follow these steps:
-
Begin by logging into an account with write access and click on the "Create Artifact" button.
-
Leave the Group Id field empty.
- Artifact Id: Use a unique identifier for each schema:
- For
user.avsc, usesolace/samples/avro - For
clock-in-out.avsc, usesolace/samples/clock-in-out/avro - For
create-user.avsc, usesolace/samples/create-user/avro - For
create-user-response.avsc, usesolace/samples/create-user-response/avro - Type: Select
Avro Schema.
- For
- Artifact Id: Use a unique identifier for each schema:
- For
user.json, usesolace/samples/json - For
clock-in-out.json, usesolace/samples/clock-in-out/json - For
create-user.json, usesolace/samples/create-user/json - For
create-user-response.json, usesolace/samples/create-user-response/json - Type: Select
JSON Schema.
- For
- Artifact Id: Use a unique identifier for each schema:
Note: Each schema must be uploaded separately with its own unique Artifact Id to avoid conflicts.
After setting the Artifact ID and Type, follow these steps:
-
Click the "Next" button to proceed.
-
You can skip the Artifact Metadata section as it's not required. Simply press "Next" to continue.
-
On the Version Content Page, leave the version set to auto, or if preferred, enter a specific value of your choice.
- On the Version Content Page, upload the appropriate schema file from the
jcsmp/src/main/resources/avro-schema/directory:- When using Artifact Id
solace/samples/avro, uploaduser.avsc - When using Artifact Id
solace/samples/clock-in-out/avro, uploadclock-in-out.avsc - When using Artifact Id
solace/samples/create-user/avro, uploadcreate-user.avsc - When using Artifact Id
solace/samples/create-user-response/avro, uploadcreate-user-response.avsc
- When using Artifact Id
-
On the Version Content Page, upload the appropriate schema file from the
jcsmp/src/main/resources/json-schema/directory:- When using Artifact Id
solace/samples/json, uploaduser.json - When using Artifact Id
solace/samples/clock-in-out/json, uploadclock-in-out.json - When using Artifact Id
solace/samples/create-user/json, uploadcreate-user.json - When using Artifact Id
solace/samples/create-user-response/json, uploadcreate-user-response.json
- When using Artifact Id
-
Click "Next" to move forward.
-
The Version Metadata is not necessary and can be skipped.
-
Finally, click the "Create" button to complete the process.
NOTE: The registry URL, username, and password can be customized by setting environment variables. If not set, the application will use default values. To override the defaults, set the following environment variables before running the application: The values shown below are the default settings. Modify these as needed for your specific registry configuration.
export REGISTRY_URL="http://localhost:8081/apis/registry/v3"
export REGISTRY_USERNAME="sr-readonly"
export REGISTRY_PASSWORD="roPassword"The Solace Schema Registry Serdes provider uses the Vert.x framework for making REST API calls to the Schema Registry. Vert.x has its own logging abstraction layer and will automatically detect and delegate to a logging backend on the classpath. The order of preference is SLF4J, Log4j2, and then Java Util Logging (JUL). For more information on Vert.x logging, take a look at the documentation https://vertx.io/docs/vertx-core/java/#_logging.
This project is configured to use Log4j2. To enable detailed network-level logging for SERDES samples, you can use JVM system variables (recommended) or modify the log4j2.xml file.
The easiest way to enable network logging is with JVM system variables:
Using JAVA_OPTS environment variable
# Enable detailed network logging for Schema Registry communication
export JAVA_OPTS="-Dschema_registry_network_log_level=debug"
# Then run your SERDES samples normally
cd build/staged
bin/HelloWorldJCSMPJsonSchemaSerde brokerUrl default defaultIf you prefer to permanently enable network logging, you can modify the src/dist/config/log4j2.xml file:
-
Open the
src/dist/config/log4j2.xmlfile. -
Find the io.netty logger and change the level from
warntodebug:<!-- Change this line --> <Logger name="io.netty" level="${sys:schema_registry_network_log_level:-debug}" additivity="false">