Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLLP Native support #2428

Merged
merged 1 commit into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions docs/modules/ROOT/pages/reference/extensions/mllp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
= MLLP
:cq-artifact-id: camel-quarkus-mllp
:cq-native-supported: false
:cq-status: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-description: Communicate with external systems using the MLLP protocol.
:cq-deprecated: false
:cq-jvm-since: 1.1.0
:cq-native-since: n/a
:cq-native-since: 1.9.0

[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.9.0##

Communicate with external systems using the MLLP protocol.

Expand All @@ -31,3 +31,8 @@ Please refer to the above link for usage and configuration details.
----

Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.

== Additional Camel Quarkus configuration

* Check the xref:user-guide/native-mode.adoc#charsets[Character encodings section] of the Native mode guide if you wish to use the `defaultCharset` component option.

6 changes: 3 additions & 3 deletions docs/modules/ROOT/partials/reference/components/mllp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
:cq-artifact-id: camel-quarkus-mllp
:cq-artifact-id-base: mllp
:cq-native-supported: false
:cq-status: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.1.0
:cq-native-since: n/a
:cq-native-since: 1.9.0
:cq-camel-part-name: mllp
:cq-camel-part-title: MLLP
:cq-camel-part-description: Communicate with external systems using the MLLP protocol.
Expand Down
1 change: 0 additions & 1 deletion extensions-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<module>lucene</module>
<module>management</module>
<module>milo</module>
<module>mllp</module>
<module>mvel</module>
<module>mybatis</module>
<module>ognl</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,14 @@
package org.apache.camel.quarkus.component.mllp.deployment;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.pkg.steps.NativeBuild;
import org.apache.camel.quarkus.core.JvmOnlyRecorder;
import org.jboss.logging.Logger;

class MllpProcessor {

private static final Logger LOG = Logger.getLogger(MllpProcessor.class);
private static final String FEATURE = "camel-mllp";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

/**
* Remove this once this extension starts supporting the native mode.
*/
@BuildStep(onlyIf = NativeBuild.class)
@Record(value = ExecutionTime.RUNTIME_INIT)
void warnJvmInNative(JvmOnlyRecorder recorder) {
JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
recorder.warnJvmInNative(FEATURE); // warn at runtime
}
}
1 change: 0 additions & 1 deletion extensions-jvm/mllp/pom.xml → extensions/mllp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@
<modules>
<module>deployment</module>
<module>runtime</module>
<module>integration-test</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

<properties>
<camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
<camel.quarkus.nativeSince>1.9.0</camel.quarkus.nativeSince>
</properties>

<dependencyManagement>
Expand Down
1 change: 1 addition & 0 deletions extensions/mllp/runtime/src/main/doc/configuration.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Check the xref:user-guide/native-mode.adoc#charsets[Character encodings section] of the Native mode guide if you wish to use the `defaultCharset` component option.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
name: "Camel MLLP"
description: "Communicate with external systems using the MLLP protocol"
metadata:
unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/mllp.html"
categories:
- "integration"
status:
- "preview"
- "stable"
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<module>microprofile-health</module>
<module>microprofile-metrics</module>
<module>minio</module>
<module>mllp</module>
<module>mock</module>
<module>mongodb</module>
<module>mongodb-gridfs</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-build-parent-it</artifactId>
<artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.9.0-SNAPSHOT</version>
<relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-mllp-integration-test</artifactId>
<name>Camel Quarkus :: MLLP :: Integration Test</name>
<artifactId>camel-quarkus-integration-test-mllp</artifactId>
<name>Camel Quarkus :: Integration Tests :: MLLP</name>
<description>Integration tests for Camel Quarkus MLLP extension</description>

<dependencyManagement>
Expand All @@ -43,6 +42,14 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mock</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mllp</artifactId>
Expand All @@ -51,6 +58,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-support</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
Expand All @@ -65,6 +76,32 @@
</dependency>

<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mock-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mllp-deployment</artifactId>
Expand All @@ -80,4 +117,34 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,41 @@

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.apache.camel.CamelContext;
import org.jboss.logging.Logger;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;

@Path("/mllp")
@ApplicationScoped
public class MllpResource {

private static final Logger LOG = Logger.getLogger(MllpResource.class);
@Inject
ProducerTemplate producerTemplate;

private static final String COMPONENT_MLLP = "mllp";
@Inject
CamelContext context;

@Path("/load/component/mllp")
@GET
@Path("/send")
@POST
@Produces(MediaType.TEXT_PLAIN)
public String sendMessageToMllp(String message) {
return producerTemplate.requestBody("direct:validMessage", message, String.class);
}

@Path("/send/invalid")
@POST
@Produces(MediaType.TEXT_PLAIN)
public Response loadComponentMllp() throws Exception {
/* This is an autogenerated test */
if (context.getComponent(COMPONENT_MLLP) != null) {
return Response.ok().build();
}
LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_MLLP);
return Response.status(500, COMPONENT_MLLP + " could not be loaded from the Camel context").build();
public void sendInvalidMessageToMllp(String message) throws Exception {
MockEndpoint mockEndpoint = context.getEndpoint("mock:invalid", MockEndpoint.class);
mockEndpoint.expectedMessageCount(1);

producerTemplate.sendBody("direct:invalidMessage", message);

mockEndpoint.assertIsSatisfied(5000);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.mllp.it;

import io.quarkus.runtime.annotations.RegisterForReflection;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mllp.MllpConstants;
import org.apache.camel.component.mllp.MllpInvalidMessageException;
import org.apache.camel.quarkus.test.AvailablePortFinder;

@RegisterForReflection(targets = MllpInvalidMessageException.class, fields = false)
public class MllpRoutes extends RouteBuilder {

private static final String MLLP_HOST = "localhost";
private static final int MLLP_PORT = AvailablePortFinder.getNextAvailable();

@Override
public void configure() throws Exception {
onException(MllpInvalidMessageException.class)
.to("mock:invalid");

fromF("mllp://%s:%d?validatePayload=true", MLLP_HOST, MLLP_PORT)
.convertBodyTo(String.class);

from("direct:validMessage")
.toF("mllp://%s:%d", MLLP_HOST, MLLP_PORT)
.setBody(header(MllpConstants.MLLP_ACKNOWLEDGEMENT));

from("direct:invalidMessage")
.toF("mllp://%s:%d?exchangePattern=InOnly", MLLP_HOST, MLLP_PORT)
.setBody(header(MllpConstants.MLLP_ACKNOWLEDGEMENT));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,9 @@
*/
package org.apache.camel.quarkus.component.mllp.it;

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.NativeImageTest;

@QuarkusTest
class MllpTest {

@Test
public void loadComponentMllp() {
/* A simple autogenerated test */
RestAssured.get("/mllp/load/component/mllp")
.then()
.statusCode(200);
}
@NativeImageTest
class MllpIT extends MllpTest {

}