-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* jms * docs: add @krzysztofxkwiecien as a contributor * readme & workflows update * added jms mock to website * test(jms): fix docker-compose setup * test: Add MessageBindingProcessor and OperationBindingProcessor coverage * test(jms): add controller and binding tests * chore: prepare jms artifact --------- Co-authored-by: Timon Back <timonback@users.noreply.github.com> Co-authored-by: sam0r040 <93372330+sam0r040@users.noreply.github.com>
- Loading branch information
1 parent
4668e5e
commit 491e1aa
Showing
57 changed files
with
2,269 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Usage | ||
|
||
### Run with docker compose (recommended) | ||
1. Copy the `docker-compose.yml` file to your machine. | ||
2. Run `$ docker-compose up`. | ||
3. Visit `localhost:8080/springwolf/asyncapi-ui.html` or try the API: `$ curl localhost:8080/springwolf/docs`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
plugins { | ||
id 'java' | ||
|
||
id 'org.springframework.boot' | ||
id 'io.spring.dependency-management' | ||
id 'ca.cutterslade.analyze' | ||
|
||
id 'com.bmuschko.docker-spring-boot-application' | ||
} | ||
|
||
dependencies { | ||
implementation project(":springwolf-core") | ||
implementation project(":springwolf-add-ons:springwolf-generic-binding") | ||
implementation project(":springwolf-plugins:springwolf-jms") | ||
|
||
annotationProcessor project(":springwolf-plugins:springwolf-jms") | ||
runtimeOnly project(":springwolf-ui") | ||
|
||
compileOnly "jakarta.jms:jakarta.jms-api" | ||
|
||
implementation "org.slf4j:slf4j-api:${slf4jApiVersion}" | ||
|
||
implementation "io.swagger.core.v3:swagger-annotations:${swaggerVersion}" | ||
|
||
implementation "org.springframework:spring-context" | ||
implementation "org.springframework:spring-jms" | ||
implementation "org.springframework.boot:spring-boot" | ||
implementation "org.springframework.boot:spring-boot-autoconfigure" | ||
runtimeOnly "org.springframework.boot:spring-boot-starter-web" | ||
runtimeOnly "org.springframework.boot:spring-boot-starter-artemis" | ||
|
||
testRuntimeOnly "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}" | ||
|
||
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}" | ||
|
||
testImplementation "org.mockito:mockito-core:${mockitoCoreVersion}" | ||
|
||
testImplementation "org.springframework.boot:spring-boot-test" | ||
testImplementation "org.springframework:spring-beans" | ||
testImplementation "org.springframework:spring-web" | ||
testImplementation "org.springframework:spring-test" | ||
|
||
testImplementation "org.testcontainers:testcontainers:${testcontainersVersion}" | ||
testImplementation "org.testcontainers:junit-jupiter:${testcontainersVersion}" | ||
} | ||
|
||
docker { | ||
springBootApplication { | ||
maintainer = 'shamir.stav@gmail.com' | ||
baseImage = 'eclipse-temurin:17-jre-focal' | ||
ports = [8080] | ||
images = ["stavshamir/springwolf-jms-example:${project.version}"] | ||
} | ||
|
||
registryCredentials { | ||
username = project.findProperty('DOCKERHUB_USERNAME') ?: '' | ||
password = project.findProperty('DOCKERHUB_TOKEN') ?: '' | ||
} | ||
} | ||
|
||
test { | ||
dependsOn dockerBuildImage | ||
} |
20 changes: 20 additions & 0 deletions
20
springwolf-examples/springwolf-jms-example/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: '3' | ||
services: | ||
app: | ||
image: stavshamir/springwolf-jms-example:${SPRINGWOLF_VERSION} | ||
links: | ||
- activemq | ||
environment: | ||
BOOTSTRAP_SERVER: tcp://activemq:61616 | ||
ports: | ||
- "8080:8080" | ||
depends_on: | ||
- activemq | ||
|
||
activemq: | ||
image: apache/activemq-artemis:2.31.2 | ||
environment: | ||
EXTRA_ARGS: --http-host 0.0.0.0 --relax-jolokia --nio | ||
ports: | ||
- "61616:61616" | ||
- "8161:8161" |
13 changes: 13 additions & 0 deletions
13
...ain/java/io/github/stavshamir/springwolf/example/jms/SpringwolfJmsExampleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.jms; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringwolfJmsExampleApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringwolfJmsExampleApplication.class, args); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ple/src/main/java/io/github/stavshamir/springwolf/example/jms/config/ConverterConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.jms.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.jms.support.converter.MappingJackson2MessageConverter; | ||
import org.springframework.jms.support.converter.MessageConverter; | ||
import org.springframework.jms.support.converter.MessageType; | ||
|
||
@Configuration | ||
class ConverterConfig { | ||
|
||
@Bean | ||
public MessageConverter jacksonJmsMessageConverter() { | ||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); | ||
converter.setTargetType(MessageType.TEXT); | ||
converter.setTypeIdPropertyName("_type"); | ||
return converter; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
.../src/main/java/io/github/stavshamir/springwolf/example/jms/consumers/ExampleConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.jms.consumers; | ||
|
||
import io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto; | ||
import io.github.stavshamir.springwolf.example.jms.dtos.ExamplePayloadDto; | ||
import io.github.stavshamir.springwolf.example.jms.producers.AnotherProducer; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.jms.annotation.JmsListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class ExampleConsumer { | ||
private final AnotherProducer anotherProducer; | ||
|
||
@JmsListener(destination = "example-queue") | ||
public void receiveExamplePayload(ExamplePayloadDto payload) { | ||
log.info("Received new message in example-queue: {}", payload.toString()); | ||
|
||
AnotherPayloadDto example = new AnotherPayloadDto(); | ||
example.setExample(payload); | ||
example.setFoo("foo"); | ||
|
||
anotherProducer.sendMessage(example); | ||
} | ||
|
||
@JmsListener(destination = "another-queue") | ||
public void receiveAnotherPayload(AnotherPayloadDto payload) { | ||
log.info("Received new message in another-queue: {}", payload.toString()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ple/src/main/java/io/github/stavshamir/springwolf/example/jms/dtos/AnotherPayloadDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.jms.dtos; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED; | ||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
@Schema(description = "Another payload model") | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class AnotherPayloadDto { | ||
|
||
@Schema(description = "Foo field", example = "bar", requiredMode = NOT_REQUIRED) | ||
private String foo; | ||
|
||
@Schema(description = "Example field", requiredMode = REQUIRED) | ||
private ExamplePayloadDto example; | ||
} |
30 changes: 30 additions & 0 deletions
30
...ple/src/main/java/io/github/stavshamir/springwolf/example/jms/dtos/ExamplePayloadDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.jms.dtos; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
@Schema(description = "Example payload model") | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ExamplePayloadDto { | ||
@Schema(description = "Some string field", example = "some string value", requiredMode = REQUIRED) | ||
private String someString; | ||
|
||
@Schema(description = "Some long field", example = "5") | ||
private long someLong; | ||
|
||
@Schema(description = "Some enum field", example = "FOO2", requiredMode = REQUIRED) | ||
private ExampleEnum someEnum; | ||
|
||
public enum ExampleEnum { | ||
FOO1, | ||
FOO2, | ||
FOO3 | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../src/main/java/io/github/stavshamir/springwolf/example/jms/producers/AnotherProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.example.jms.producers; | ||
|
||
import io.github.stavshamir.springwolf.addons.generic_binding.annotation.AsyncGenericOperationBinding; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncOperation; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncPublisher; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.JmsAsyncOperationBinding; | ||
import io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.jms.core.JmsTemplate; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class AnotherProducer { | ||
private final JmsTemplate template; | ||
|
||
public static final String QUEUE = "another-queue"; | ||
|
||
@AsyncPublisher( | ||
operation = | ||
@AsyncOperation( | ||
channelName = QUEUE, | ||
description = "Custom, optional description defined in the AsyncPublisher annotation")) | ||
@JmsAsyncOperationBinding | ||
@AsyncGenericOperationBinding( | ||
type = "jms", | ||
fields = {"internal-field=customValue", "nested.key=nestedValue"}) | ||
public void sendMessage(AnotherPayloadDto msg) { | ||
template.convertAndSend(QUEUE, msg); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
springwolf-examples/springwolf-jms-example/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
######### | ||
# Spring configuration | ||
spring.application.name=Springwolf example project - JMS | ||
|
||
|
||
######### | ||
# JMS configuration | ||
spring.artemis.broker-url=${BOOTSTRAP_SERVER:tcp://localhost:61616} | ||
spring.artemis.user=artemis | ||
spring.artemis.password=artemis | ||
|
||
|
||
######### | ||
# Springwolf configuration | ||
springwolf.enabled=true | ||
springwolf.docket.base-package=io.github.stavshamir.springwolf.example.jms | ||
springwolf.docket.info.title=${spring.application.name} | ||
springwolf.docket.info.version=1.0.0 | ||
springwolf.docket.info.description=Springwolf example project to demonstrate springwolfs abilities | ||
springwolf.docket.info.terms-of-service=http://asyncapi.org/terms | ||
springwolf.docket.info.contact.name=springwolf | ||
springwolf.docket.info.contact.email=example@example.com | ||
springwolf.docket.info.contact.url=https://github.com/springwolf/springwolf-core | ||
springwolf.docket.info.license.name=Apache License 2.0 | ||
springwolf.docket.servers.jms.protocol=jms | ||
springwolf.docket.servers.jms.url=${spring.artemis.broker-url} | ||
springwolf.use-fqn=true | ||
|
||
springwolf.plugin.jms.publishing.enabled=true | ||
|
||
|
||
# For debugging purposes | ||
logging.level.io.github.stavshamir.springwolf=DEBUG |
Oops, something went wrong.