Skip to content

Commit

Permalink
Cache JCSMPSessions and provide them as Bean to avoid multiple connec…
Browse files Browse the repository at this point in the history
…tions to the same broker.

## [4.2.3] - 2024-07-19
### Added
- Cache JCSMPSessions and provide them as Bean to avoid multiple connections to the same broker.
- Add .editorconfig and reformat the whole code.

### Changed
- Bump versions of solace jcsmp to 10.24.1
- Use only Slf4j to log.
  • Loading branch information
helios57 committed Jul 19, 2024
1 parent 73ba367 commit f9ac581
Show file tree
Hide file tree
Showing 142 changed files with 22,483 additions and 21,571 deletions.
1,216 changes: 1,216 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions API.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ When set to `true`, messages will be received using local transactions.
+
Default: `false`
+
WARNING: A transacted producer cannot be used by multiple threads.
+
NOTE: The maximum transaction size is 256 messages. +
The size of the transaction is controlled by the batched message's size. See <<Batch Consumers>> for more info.

Expand Down
123 changes: 66 additions & 57 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,67 @@
# Changelog

All notable changes to this project will be documented in this file.

## [4.2.2] - 2024-07-04
### Changed
- Bump versions of solace jcsmp to 10.24.0
-
## [4.2.1] - 2024-06-24
### Changed
- Bump versions to spring boot 3.3.1
### Fixed
- Fix a bug when sending Direct Messages

## [4.2.0] - 2024-06-12
### Changed
- By Solace #290 migrate to producer bindings to use JCSMP producer flows
- By Solace #269 give consumer binding threads readable names
- By Solace #294 DATAGO-76828: add transacted producer support
- Bump versions to spring boot 3.3.0 and spring cloud 2023.0.2

## [4.0.1] - 2024-05-13
### Fixed

- Initialisation error of health indicator resulting in a NPE when checking /actuator/health too early.
- Exception on shutdown after trying to reconnect to the broker for some minutes.

## [4.0.0] - 2024-05-07

### Added

- Support for non-persistent publish and subscribe.
- Support for groups in direct subscription using #share subscription on topics. (https://docs.solace.com/Messaging/Direct-Msg/Direct-Messages.htm -> Shared Subscriptions )
- NACK Support for Consumer bindings (by solace https://github.com/SolaceProducts/solace-spring-cloud/pull/270).
- Reapply subscriptions on temporary queues after reconnect with more than 60 sec interruption.

### Fixed

- Startup error with anonymous queues when broker is under load (fix: https://github.com/SolaceProducts/solace-spring-cloud/issues/266).

### Changed

- Flatten maven structure into a single project (no need for dependency management or starter).
- Upgrade dependencies:
- spring-boot: 3.2.5
- spring-cloud: 2023.0.1
- sol-jcsmp: 10.23.0
- others: to latest version
- Deprecated batch messaging processing.

### Removed

- git submodule: solace-integration-test-support (integrated into the test now).
- multimodule with starter (integrated into then main project).

## before 4.0.0

# Changelog

All notable changes to this project will be documented in this file.

## [4.2.3] - 2024-07-19
### Added
- Cache JCSMPSessions and provide them as Bean to avoid multiple connections to the same broker.
- Add .editorconfig and reformat the whole code.

### Changed
- Bump versions of solace jcsmp to 10.24.1
- Use only Slf4j to log.

## [4.2.2] - 2024-07-04
### Changed
- Bump versions of solace jcsmp to 10.24.0

## [4.2.1] - 2024-06-24
### Changed
- Bump versions to spring boot 3.3.1
### Fixed
- Fix a bug when sending Direct Messages

## [4.2.0] - 2024-06-12
### Changed
- By Solace #290 migrate to producer bindings to use JCSMP producer flows
- By Solace #269 give consumer binding threads readable names
- By Solace #294 DATAGO-76828: add transacted producer support
- Bump versions to spring boot 3.3.0 and spring cloud 2023.0.2

## [4.0.1] - 2024-05-13
### Fixed

- Initialisation error of health indicator resulting in a NPE when checking /actuator/health too early.
- Exception on shutdown after trying to reconnect to the broker for some minutes.

## [4.0.0] - 2024-05-07

### Added

- Support for non-persistent publish and subscribe.
- Support for groups in direct subscription using #share subscription on topics. (https://docs.solace.com/Messaging/Direct-Msg/Direct-Messages.htm -> Shared Subscriptions )
- NACK Support for Consumer bindings (by solace https://github.com/SolaceProducts/solace-spring-cloud/pull/270).
- Reapply subscriptions on temporary queues after reconnect with more than 60 sec interruption.

### Fixed

- Startup error with anonymous queues when broker is under load (fix: https://github.com/SolaceProducts/solace-spring-cloud/issues/266).

### Changed

- Flatten maven structure into a single project (no need for dependency management or starter).
- Upgrade dependencies:
- spring-boot: 3.2.5
- spring-cloud: 2023.0.1
- sol-jcsmp: 10.23.0
- others: to latest version
- Deprecated batch messaging processing.

### Removed

- git submodule: solace-integration-test-support (integrated into the test now).
- multimodule with starter (integrated into then main project).

## before 4.0.0

Check forked repository https://github.com/SolaceProducts/solace-spring-cloud
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Consult the table below to determine which version of the BOM you need to use:

| Spring Cloud | Spring Cloud Stream Binder Solace | Spring Boot | sol-jcsmp |
|--------------|-----------------------------------|-------------|-----------|
| 2023.0.2 | 4.2.3 | 3.3.1 | 10.24.1 |
| 2023.0.2 | 4.2.2 | 3.3.1 | 10.24.0 |
| 2023.0.2 | 4.2.1 | 3.3.1 | 10.23.0 |
| 2023.0.2 | 4.2.0 | 3.3.0 | 10.23.0 |
Expand All @@ -47,7 +48,7 @@ Check out the difference between this fork and the original solace spring cloud
<dependency>
<groupId>ch.sbb</groupId>
<artifactId>spring-cloud-stream-binder-solace</artifactId>
<version>4.2.1</version>
<version>4.2.3</version>
</dependency>
</dependencies>
```
Expand Down
33 changes: 10 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>ch.sbb</groupId>
<artifactId>spring-cloud-stream-binder-solace</artifactId>
<version>4.2.2</version>
<version>4.2.3</version>

<name>Spring Cloud Stream Binder Solace</name>
<description>A Spring Cloud Stream Binder implementation using the Solace Java API (JCSMP)</description>
Expand All @@ -24,8 +24,8 @@

<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.2</spring-cloud.version>
<solace.jcsmp.version>10.24.0</solace.jcsmp.version>
<spring-cloud.version>2023.0.3</spring-cloud.version>
<solace.jcsmp.version>10.24.1</solace.jcsmp.version>
<maven.test.skip>true</maven.test.skip>
<build.timestamp>${maven.build.timestamp}</build.timestamp>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
Expand Down Expand Up @@ -134,16 +134,6 @@
<artifactId>junit-pioneer</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down Expand Up @@ -179,15 +169,6 @@
<artifactId>toxiproxy</artifactId>
<version>1.19.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
Expand Down Expand Up @@ -220,6 +201,11 @@
<artifactId>gson-fire</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -290,7 +276,8 @@
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/test/resources/semp/semp-v2-swagger-action.yaml</inputSpec>
<inputSpec>${project.basedir}/src/test/resources/semp/semp-v2-swagger-action.yaml
</inputSpec>
<apiPackage>com.solace.test.integration.semp.v2.action.api</apiPackage>
<modelPackage>com.solace.test.integration.semp.v2.action.model</modelPackage>
<modelNamePrefix>Action</modelNamePrefix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import com.solacesystems.jcsmp.impl.client.ClientInfoProvider;

class SolaceBinderClientInfoProvider extends ClientInfoProvider {
public String getSoftwareVersion() {
return String.format("@project.version@ (%s)", super.getSoftwareVersion());
}
public String getSoftwareVersion() {
return String.format("@project.version@ (%s)", super.getSoftwareVersion());
}

public String getSoftwareDate() {
return String.format("@build.timestamp@ (%s)", super.getSoftwareDate());
}
public String getSoftwareDate() {
return String.format("@build.timestamp@ (%s)", super.getSoftwareDate());
}

public String getPlatform() {
return this.getPlatform("@project.name@ (JCSMP SDK)");
}
public String getPlatform() {
return this.getPlatform("@project.name@ (JCSMP SDK)");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.solace.spring.cloud.stream.binder.util.*;
import com.solacesystems.jcsmp.*;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.cloud.stream.binder.*;
import org.springframework.cloud.stream.provisioning.ConsumerDestination;
Expand All @@ -29,6 +30,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;

@Slf4j
public class SolaceMessageChannelBinder
extends AbstractMessageChannelBinder<ExtendedConsumerProperties<SolaceConsumerProperties>,
ExtendedProducerProperties<SolaceProducerProperties>,
Expand Down Expand Up @@ -69,7 +71,7 @@ public String getBinderIdentity() {

@Override
public void destroy() {
logger.info(String.format("Closing JCSMP session %s", jcsmpSession.getSessionName()));
log.info(String.format("Closing JCSMP session %s", jcsmpSession.getSessionName()));
sessionProducerManager.release(errorHandlerProducerKey);
consumersRemoteStopFlag.set(true);
jcsmpSession.closeSession();
Expand Down Expand Up @@ -102,13 +104,13 @@ protected MessageProducer createConsumerEndpoint(ConsumerDestination destination
if (properties.getExtension() != null && properties.getExtension().getQualityOfService() == QualityOfService.AT_MOST_ONCE) {
return createTopicMessageProducer(destination, group, properties);
}
if (!properties.isBatchMode() && properties.getExtension().isTransacted()) {
throw new IllegalArgumentException("Non-batched, transacted consumers are not supported");
}
if (!properties.isBatchMode() && properties.getExtension().isTransacted()) {
throw new IllegalArgumentException("Non-batched, transacted consumers are not supported");
}

if (properties.getExtension().isTransacted() && properties.getExtension().isAutoBindErrorQueue()) {
throw new IllegalArgumentException("transacted consumers do not support error queues");
}
if (properties.getExtension().isTransacted() && properties.getExtension().isAutoBindErrorQueue()) {
throw new IllegalArgumentException("transacted consumers do not support error queues");
}
return createQueueMessageProducer(destination, group, properties);
}

Expand Down Expand Up @@ -164,17 +166,17 @@ protected MessageProducer createTopicMessageProducer(ConsumerDestination destina
protected PolledConsumerResources createPolledConsumerResources(String name, String group,
ConsumerDestination destination,
ExtendedConsumerProperties<SolaceConsumerProperties> consumerProperties) {
if (!consumerProperties.isBatchMode() && consumerProperties.getExtension().isTransacted()) {
throw new IllegalArgumentException("Non-batched, transacted consumers are not supported");
}
if (consumerProperties.getExtension().isTransacted() && consumerProperties.getExtension().isAutoBindErrorQueue()) {
throw new IllegalArgumentException("transacted consumers do not support error queues");
}
if (!consumerProperties.isBatchMode() && consumerProperties.getExtension().isTransacted()) {
throw new IllegalArgumentException("Non-batched, transacted consumers are not supported");
}
if (consumerProperties.getExtension().isTransacted() && consumerProperties.getExtension().isAutoBindErrorQueue()) {
throw new IllegalArgumentException("transacted consumers do not support error queues");
}
if (consumerProperties.getConcurrency() > 1) {
logger.warn("Polled consumers do not support concurrency > 1, it will be ignored...");
log.warn("Polled consumers do not support concurrency > 1, it will be ignored...");
}
if (consumerProperties.isBatchMode()) {
logger.error("BatchMode is deprecated and should not be used.");
log.error("BatchMode is deprecated and should not be used.");
}

SolaceConsumerDestination solaceDestination = (SolaceConsumerDestination) destination;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
@Configuration
public class ExtendedBindingHandlerMappingsProviderConfiguration {

@Bean
public MappingsProvider solaceExtendedPropertiesDefaultMappingsProvider() {
return () -> {
Map<ConfigurationPropertyName, ConfigurationPropertyName> mappings = new HashMap<>();
mappings.put(ConfigurationPropertyName.of("spring.cloud.stream.solace.bindings"),
ConfigurationPropertyName.of("spring.cloud.stream.solace.default"));
return mappings;
};
}
@Bean
public MappingsProvider solaceExtendedPropertiesDefaultMappingsProvider() {
return () -> {
Map<ConfigurationPropertyName, ConfigurationPropertyName> mappings = new HashMap<>();
mappings.put(ConfigurationPropertyName.of("spring.cloud.stream.solace.bindings"),
ConfigurationPropertyName.of("spring.cloud.stream.solace.default"));
return mappings;
};
}
}
Loading

0 comments on commit f9ac581

Please sign in to comment.