Skip to content

Commit

Permalink
Upgrade smallrye-reactive-messaging-camel to 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Oct 2, 2020
1 parent 3b654ba commit 8768517
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
class SmallRyeReactiveMessagingProcessor {

private static final DotName CAMEL_CONNECTOR_DOTNAME = DotName.createSimple(CamelConnector.class.getName());

private static final String FEATURE = "camel-smallrye-reactive-messaging";

@BuildStep
Expand Down Expand Up @@ -68,14 +67,6 @@ void overrideSmallRyeReactiveMessagingConfiguration(BuildProducer<AnnotationsTra
.remove(annotationInstance -> annotationInstance.target().equals(producesAnnotation.target()))
.done();
}

// Remove @PostConstruct from the init method as the configuration logic is handled by the reactive-streams extension
if (methodInfo.name().equals("init")) {
AnnotationInstance postConstructAnnotation = getAnnotationInstance(DotNames.POST_CONSTRUCT, methodInfo);
context.transform()
.remove(methodAnnotation -> methodAnnotation.target().equals(postConstructAnnotation.target()))
.done();
}
}
}
}));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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
*
* http://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.apache.camel.quarkus.component.smallrye.reactive.messaging.it;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletionStage;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.apache.camel.CamelContext;
import org.apache.camel.component.file.GenericFile;
import org.eclipse.microprofile.reactive.messaging.Incoming;
import org.eclipse.microprofile.reactive.messaging.Message;

@Singleton
public class FilesMessageConsumer {

private List<String> fileBodies = new ArrayList<>();

@Inject
CamelContext context;

@Incoming("files")
public CompletionStage<Void> consumeFile(Message<GenericFile<File>> msg) {
try {
GenericFile<File> file = msg.getPayload();
String content = context.getTypeConverter().convertTo(String.class, file);
fileBodies.add(content);
return msg.ack();
} catch (Exception e) {
e.printStackTrace();
return msg.nack(e);
}
}

public List<String> getFileBodies() {
return fileBodies;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class SmallRyeReactiveMessagingResource {
@Inject
ResultsBean results;

@Inject
FilesMessageConsumer filesMessageConsumer;

@Path("/post")
@Consumes(MediaType.TEXT_PLAIN)
@POST
Expand All @@ -58,4 +61,12 @@ public String getValues() {
Collections.sort(values);
return String.join(",", values);
}

@Path("/file")
@Produces(MediaType.TEXT_PLAIN)
@GET
public String getFiles() {
List<String> bodies = filesMessageConsumer.getFileBodies();
return String.join(",", bodies);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mp.messaging.incoming.files.connector=smallrye-camel
mp.messaging.incoming.files.endpoint-uri=file:./target/test/?delete=true&charset=utf-8
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.camel.quarkus.component.smallrye.reactive.messaging.it;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -69,4 +71,20 @@ public void testSmallRyeReactiveMessagingCamelRoutePublisher() {
return response.equals("A,B,C,D");
});
}

@Test
public void testPropertiesConfiguredFileConsumer() throws IOException {
String content = "Hello Camel Quarkus Reactive Streams Messaging";
Files.write(Paths.get("target/test/test.txt"), content.getBytes(StandardCharsets.UTF_8));

await().atMost(10, TimeUnit.SECONDS).until(() -> {
String response = RestAssured.get("/smallrye-reactive-messaging/file")
.then()
.statusCode(200)
.extract()
.body()
.asString();
return response.equals(content);
});
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<quarkus-qpid-jms.version>0.18.0</quarkus-qpid-jms.version>
<protobuf.version>3.11.1</protobuf.version>
<retrofit.version>2.5.0</retrofit.version>
<smallrye.reactive.messaging.camel.version>2.2.1</smallrye.reactive.messaging.camel.version>
<smallrye.reactive.messaging.camel.version>2.4.0</smallrye.reactive.messaging.camel.version>
<soap-api.version>1.4.0</soap-api.version><!-- keep in sync with Camel -->
<!-- Keep spring.version aligned with the version used by Camel -->
<spring.version>5.2.8.RELEASE</spring.version>
Expand Down

0 comments on commit 8768517

Please sign in to comment.