Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up a few syntax complaints Added samples parent pom Added second level target to git ignore Cleaned up code so that it is working based on the sample
- Loading branch information
Stephen Asbury
committed
Jun 24, 2019
1 parent
beea4c6
commit d12e734
Showing
18 changed files
with
198 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ Thumbs.db | |
# Build output directies | ||
/target | ||
*/target | ||
*/*/target | ||
/build | ||
*/build | ||
|
||
|
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,37 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>nats-binder-sample</artifactId> | ||
<version>0.0.1.BUILD-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>multi-binder-sample</name> | ||
<description>A simple sample for the nats cloud stream binder</description> | ||
|
||
<parent> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>nats-samples</artifactId> | ||
<version>0.0.1.BUILD-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
|
||
<properties> | ||
<main.basedir>${basedir}/..</main.basedir> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-stream-binder-nats</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
29 changes: 29 additions & 0 deletions
29
...-sample/src/main/java/org/springframework/cloud/stream/binder/nats/MultiBinderSample.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,29 @@ | ||
/* | ||
* Copyright 2017-2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.cloud.stream.binder.nats; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class MultiBinderSample { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(MultiBinderSample.class, args); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...le/src/main/java/org/springframework/cloud/stream/binder/nats/MultiBinderTransformer.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,45 @@ | ||
/* | ||
* Copyright 2017-2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.cloud.stream.binder.nats; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import org.springframework.cloud.stream.annotation.EnableBinding; | ||
import org.springframework.cloud.stream.annotation.StreamListener; | ||
import org.springframework.cloud.stream.messaging.Processor; | ||
import org.springframework.messaging.handler.annotation.SendTo; | ||
|
||
@EnableBinding(Processor.class) | ||
public class MultiBinderTransformer { | ||
private static final Log logger = LogFactory.getLog(MultiBinderTransformer.class); | ||
|
||
@StreamListener(Processor.INPUT) | ||
@SendTo(Processor.OUTPUT) | ||
public Object transform(Object message) { | ||
if (message instanceof byte[]) { | ||
String value = new String((byte[]) message, StandardCharsets.UTF_8); | ||
message = value.toUpperCase().getBytes(StandardCharsets.UTF_8); | ||
} | ||
else if (message instanceof String) { | ||
message = ((String) message).toUpperCase(); | ||
} | ||
return message; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
nats-samples/multi-binder-sample/src/main/resources/application.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,10 @@ | ||
spring: | ||
cloud: | ||
stream: | ||
bindings: | ||
input: | ||
destination: dataIn | ||
binder: nats | ||
output: | ||
destination: dataOut | ||
binder: nats |
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,37 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>nats-samples</artifactId> | ||
<version>0.0.1.BUILD-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<parent> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-nats-parent</artifactId> | ||
<version>0.0.1.BUILD-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
|
||
<properties> | ||
<spring-boot.version>2.1.6.RELEASE</spring-boot.version> | ||
<spring-cloud-stream.version>2.2.0.RELEASE</spring-cloud-stream.version> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<modules> | ||
<module>multi-binder-sample</module> | ||
</modules> | ||
|
||
<dependencyManagement> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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
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