Skip to content

Commit

Permalink
Merge pull request #66 from SolaceLabs/tracing
Browse files Browse the repository at this point in the history
Client Side Tracing & OAuth implementation
  • Loading branch information
SravanThotakura05 authored Mar 15, 2024
2 parents 4aa0b61 + 42a7b1e commit f1e53a9
Show file tree
Hide file tree
Showing 41 changed files with 7,019 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,20 @@ Timeout in milliseconds to wait for messages to finish processing before shutdow
--|long
|`10000`

a| [[quarkus-solace_quarkus.client.tracing-enabled]]`link:#quarkus-solace_quarkus.client.tracing-enabled[client.tracing-enabled]`


[.description]
--
Whether to enable or disable tracing for consumer or producer.

// ifdef::add-copy-button-to-env-var[]
// Environment variable: env_var_with_copy_button:+++QUARKUS_SOLACE_DEVSERVICES_ENABLED+++[]
// endif::add-copy-button-to-env-var[]
// ifndef::add-copy-button-to-env-var[]
// Environment variable: `+++QUARKUS_SOLACE_DEVSERVICES_ENABLED+++`
// endif::add-copy-button-to-env-var[]
--|boolean
|`false`

|===
78 changes: 71 additions & 7 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The https://solace.com/products/platform/[Solace PubSub+ Platform]'s https://sol

== Quarkus Extension for Solace

Solace Quarkus Extension for integrating with Solace PubSub+ message brokers. The extension provides the ability to publish or consume events from event mesh.
Solace Quarkus Extension provides the ability to integrate with Solace PubSub+ message brokers. The events generated by this extension will be available on event mesh and in the same way the extension can subscribe to any event available on event mesh.

Users have the choice to use the extension in two ways

Expand Down Expand Up @@ -69,7 +69,7 @@ include::includes/quarkus-solace-extension-common.adoc[leveloffset=+1, opts=opti
[[configuring-quarkus-solace-client]]
== Configuring Quarkus Solace Client

Solace Broker supports different ways to connect and authenticate users. This section shows how to pass <<quarkus-solace_quarkus.solace-extra, extra properties>> to quarkus solace client in different scenarios.
Solace Broker supports different ways to connect and authenticate users. This section shows how to pass <<quarkus-solace_quarkus.solace-extra, extra properties>> to quarkus solace client in different scenarios. Please refer to https://docs.solace.com/API-Developer-Online-Ref-Documentation/pubsubplus-java/constant-values.html#com.solace.messaging.config.SolaceProperties[Solace Properties] for supported properties and definitions.

{empty}1. Connecting to a standalone broker with basic authentication
[source,yaml]
Expand Down Expand Up @@ -101,7 +101,7 @@ quarkus.solace.tls.trust-store-type=
quarkus.solace.tls.trust-store-password=
----

{empty}3. Connecting to a standalone broker with TLS, trust store and client certificate authentication. In case of client certificate authentication broker will read from configured username source(ex: Common Name, Subject Alt Name etc...). Refer to https://docs.solace.com/Security/Configuring-Client-Authentication.htm#Client-Cert[Solace Client Certificate Authentication].
{empty}4. Connecting to a standalone broker with TLS, trust store and client certificate authentication. In case of client certificate authentication broker will read from configured username source(ex: Common Name, Subject Alt Name etc...). Refer to https://docs.solace.com/Security/Configuring-Client-Authentication.htm#Client-Cert[Solace Client Certificate Authentication].
[source,yaml]
----
quarkus.solace.host=tcps://localhost:55443
Expand All @@ -115,7 +115,49 @@ quarkus.solace.authentication.client-cert.keystore-password=
quarkus.solace.authentication.client-cert.keystore-format=
----

{empty}4. Connecting to a HA broker. Here you can configure both active and standby URL and the client will switch connectivity based on availability.
{empty}5. Connecting to a standalone broker with OAUTH authentication scheme.
[source,yaml]
----
quarkus.solace.host=tcp://localhost:55555
quarkus.solace.vpn=default
quarkus.solace.authentication.scheme=AUTHENTICATION_SCHEME_OAUTH2
quarkus.solace.oidc.client-name=solace // client name provided in oidc client config below
quarkus.solace.oidc.refresh.interval=50s // Refresh interval should be less than access token expiry time. Otherwise extension will fail to update access token in solace session.
quarkus.oidc-client.solace.auth-server-url=http://localhost:7777/auth/realms/master
quarkus.oidc-client.solace.client-id=<client-id>
quarkus.oidc-client.solace.credentials.secret=<client-secret>
# 'client' is a shortcut for `client_credentials`
quarkus.oidc-client.solace.grant.type=client
----

{empty}6. Connecting to a standalone broker with TLS and OAUTH authentication scheme.
[source,yaml]
----
quarkus.solace.host=tcps://localhost:55443
quarkus.solace.vpn=default
quarkus.solace.authentication.scheme=AUTHENTICATION_SCHEME_OAUTH2
quarkus.solace.tls.trust-store-path=
quarkus.solace.tls.trust-store-type=
quarkus.solace.tls.trust-store-password=
quarkus.solace.oidc.client-name=solace // client name provided in oidc client config below
quarkus.solace.oidc.refresh.interval=50s // Refresh interval should be less than access token expiry time. Otherwise extension will fail to update access token in solace session.
quarkus.oidc-client.solace.auth-server-url=http://localhost:7777/auth/realms/master
quarkus.oidc-client.solace.client-id=<client-id>
quarkus.oidc-client.solace.credentials.secret=<client-secret>
# 'client' is a shortcut for `client_credentials`
quarkus.oidc-client.solace.grant.type=client
quarkus.oidc-client.solace.tls.trust-store-file=<path-to-truststore-file>
quarkus.oidc-client.solace.tls.key-store-password=
quarkus.oidc-client.solace.tls.verification=<enable-or-disable-tls-verification>
----

For more details on Quarkus OIDC client supported configuration please refer to https://quarkus.io/guides/security-openid-connect-client-reference[OPENID CONNECT (OIDC) AND OAUTH2 CLIENT AND FILTERS] and https://quarkus.io/guides/security-oidc-configuration-properties-reference[OIDC configuration reference]

NOTE: The current version is tested with client_credentials grant type where Solace broker is configured as Resource Server.

{empty}7. Connecting to a HA broker. Here you can configure both active and standby URL and the client will switch connectivity based on availability. Remaining configurations and authentication mechanisms can be used as-is.
[source,yaml]
----
quarkus.solace.host=tcp://active-host-name:55555,tcp://standby-host-name:55555
Expand Down Expand Up @@ -269,8 +311,8 @@ quarkus.solace.vpn=default
quarkus.solace.authentication.basic.username=basic
quarkus.solace.authentication.basic.password=basic
mp.messaging.incoming.temperatures-out.connector=quarkus-solace
mp.messaging.incoming.temperatures-out.producer.topic=temperatures
mp.messaging.outgoing.temperatures-out.connector=quarkus-solace
mp.messaging.outgoing.temperatures-out.producer.topic=temperatures
----

1. When running in dev mode or tests dev services will automatically start a Solace PubSub+ broker and if broker configuration details are not provided the extension automatically picks up the details of broker started by dev services.
Expand Down Expand Up @@ -427,6 +469,28 @@ public class TemperaturesProcessor {
}
----

[[open-telemetry-tracing]]
== Open Telemetry Tracing

Extension supports generating trace messages for th messages consumed and published by the extension. To enabling tracing for consumers and producers use the below configuration.
[source,yaml]
----
quarkus.solace.host=tcp://localhost:55555
quarkus.solace.vpn=default
quarkus.solace.authentication.basic.username=test
quarkus.solace.authentication.basic.password=test
mp.messaging.incoming.temperatures.connector=quarkus-solace
mp.messaging.incoming.temperatures.consumer.queue.name=temperatures
mp.messaging.incoming.temperatures.client.tracing-enabled=true
mp.messaging.outgoing.temperatures-out.connector=quarkus-solace
mp.messaging.outgoing.temperatures-out.producer.topic=temperatures
mp.messaging.outgoing.temperatures-out.client.tracing-enabled=true
----

NOTE: Context Propagation is not fully supported in current version.

[[health-checks]]
== Health Checks

Expand All @@ -443,7 +507,7 @@ The liveness check captures any unrecoverable failure happening during the commu
The readiness check verifies that the Quarkus Solace Messaging Connector is ready to consume/produce messages to the configured Solace queues/topics.

[[dev-services]]
Dev Services
== Dev Services

Solace Dev Services for Quarkus will spin up latest version of Solace PubSub standard with label `solace` when running tests or in dev mode. Solace Dev Services are enabled by default and will check for any existing containers with same label to reuse. If none is present a new container is started.

Expand Down
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<packaging>pom</packaging>
<modules>
<module>solace-client-integration-tests</module>
<module>solace-client-oauth-integration-tests</module>
</modules>
</project>
128 changes: 128 additions & 0 deletions integration-tests/solace-client-oauth-integration-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.solace.quarkus</groupId>
<artifactId>quarkus-solace-integration-tests-parent</artifactId>
<version>${revision}${sha1}${changelist}</version>
</parent>

<artifactId>solace-client-oauth-integration-tests</artifactId>
<name>Quarkus Solace Client - OAuth Integration Tests</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>com.solace.quarkus</groupId>
<artifactId>quarkus-solace-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native-image</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>
${project.build.directory}/${project.build.finalName}-runner
</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager
</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.solace.quarkus;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;

import com.solace.messaging.MessagingService;
import com.solace.messaging.config.MissingResourcesCreationConfiguration;
import com.solace.messaging.receiver.DirectMessageReceiver;
import com.solace.messaging.receiver.PersistentMessageReceiver;
import com.solace.messaging.resources.Queue;
import com.solace.messaging.resources.TopicSubscription;

import io.quarkus.runtime.ShutdownEvent;

@ApplicationScoped
public class SolaceConsumer {

private final DirectMessageReceiver directReceiver;
private final PersistentMessageReceiver persistentReceiver;
List<String> direct = new CopyOnWriteArrayList<>();
List<String> persistent = new CopyOnWriteArrayList<>();

public SolaceConsumer(MessagingService solace) {
directReceiver = solace.createDirectMessageReceiverBuilder()
.withSubscriptions(TopicSubscription.of("hello/direct"))
.build().start();
persistentReceiver = solace.createPersistentMessageReceiverBuilder()
.withMissingResourcesCreationStrategy(
MissingResourcesCreationConfiguration.MissingResourcesCreationStrategy.CREATE_ON_START)
.withSubscriptions(TopicSubscription.of("hello/persistent"))
.build(Queue.durableExclusiveQueue("hello/persistent")).start();

directReceiver.receiveAsync(h -> consumeDirect(h.getPayloadAsString()));
persistentReceiver.receiveAsync(h -> consumePersistent(h.getPayloadAsString()));
}

public void shutdown(@Observes ShutdownEvent event) {
directReceiver.terminate(1);
persistentReceiver.terminate(1);
}

public void consumeDirect(String message) {
direct.add(message);
}

public void consumePersistent(String message) {
persistent.add(message);
}

public List<String> direct() {
return direct;
}

public List<String> persistent() {
return persistent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.solace.quarkus;

import jakarta.enterprise.context.ApplicationScoped;

import com.solace.messaging.MessagingServiceClientBuilder;

@ApplicationScoped
public class SolaceCustomizer implements MessagingServiceClientCustomizer {
@Override
public MessagingServiceClientBuilder customize(MessagingServiceClientBuilder builder) {
return builder;
}
}
Loading

0 comments on commit f1e53a9

Please sign in to comment.