You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/02/03 10:47:37 UTC

[GitHub] [camel-quarkus] jamesnetherton opened a new pull request #2197: Syslog native support

jamesnetherton opened a new pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197


   Fixes #595
   
   I had to register a couple of classes for reflection to make this work. I didn't bother raising issues to fix since the issue with `NettyConfiguration` is fixed in [CAMEL-16129](https://issues.apache.org/jira/browse/CAMEL-16129), so I can remove that on the `camel-master` branch. And I opened https://github.com/quarkusio/quarkus/pull/14786 to get `NioDatagramChannel` added on the Quarkus side, hence I can hopefully clean it up on the `quarkus-master` branch once merged.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton commented on a change in pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on a change in pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197#discussion_r569443514



##########
File path: integration-tests/syslog/src/main/java/org/apache/camel/quarkus/component/syslog/it/SyslogResource.java
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.syslog.it;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.syslog.SyslogMessage;
+import org.apache.camel.component.syslog.netty.Rfc5425Encoder;
+import org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/syslog")
+public class SyslogResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = "camel.netty.rfc5425.port")
+    int syslogRfc5425ServerPort;
+
+    @ConfigProperty(name = "camel.netty.rfc3164.port")
+    int syslogRfc3164ServerPort;
+
+    @Path("/send/{version}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    public Response sendSendMessage(@PathParam("version") String version, String message) throws Exception {

Review comment:
       Thanks - fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197#discussion_r569432001



##########
File path: integration-tests/syslog/src/main/java/org/apache/camel/quarkus/component/syslog/it/SyslogResource.java
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.syslog.it;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.syslog.SyslogMessage;
+import org.apache.camel.component.syslog.netty.Rfc5425Encoder;
+import org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/syslog")
+public class SyslogResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = "camel.netty.rfc5425.port")
+    int syslogRfc5425ServerPort;
+
+    @ConfigProperty(name = "camel.netty.rfc3164.port")
+    int syslogRfc3164ServerPort;
+
+    @Path("/send/{version}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    public Response sendSendMessage(@PathParam("version") String version, String message) throws Exception {

Review comment:
       Maybe sendMessage here




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197#discussion_r569548988



##########
File path: integration-tests/syslog/src/main/java/org/apache/camel/quarkus/component/syslog/it/SyslogResource.java
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.syslog.it;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.syslog.SyslogMessage;
+import org.apache.camel.component.syslog.netty.Rfc5425Encoder;
+import org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/syslog")
+public class SyslogResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = "camel.netty.rfc5425.port")
+    int syslogRfc5425ServerPort;
+
+    @ConfigProperty(name = "camel.netty.rfc3164.port")
+    int syslogRfc3164ServerPort;
+
+    @Path("/send/{version}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    public Response sendMessage(@PathParam("version") String version, String message) throws Exception {
+        int port = version.equals("rfc5425") ? syslogRfc5425ServerPort : syslogRfc3164ServerPort;
+        producerTemplate.sendBody(
+                "netty:udp://127.0.0.1:" + port + "?sync=false&allowDefaultCodec=false&useByteBuf=true",
+                message.getBytes(StandardCharsets.UTF_8));
+        return Response.created(new URI("https://camel.apache.org/")).build();
+    }
+
+    @Path("/messages")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getSyslogMessage() {
+        SyslogMessage syslogMessage = consumerTemplate.receiveBodyNoWait("seda:syslog-unmarshalled", SyslogMessage.class);

Review comment:
       yeah, the potential issue must be sorted then. Well done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197#discussion_r569530856



##########
File path: integration-tests/syslog/src/main/java/org/apache/camel/quarkus/component/syslog/it/SyslogResource.java
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.syslog.it;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.syslog.SyslogMessage;
+import org.apache.camel.component.syslog.netty.Rfc5425Encoder;
+import org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/syslog")
+public class SyslogResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = "camel.netty.rfc5425.port")
+    int syslogRfc5425ServerPort;
+
+    @ConfigProperty(name = "camel.netty.rfc3164.port")
+    int syslogRfc3164ServerPort;
+
+    @Path("/send/{version}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    public Response sendMessage(@PathParam("version") String version, String message) throws Exception {
+        int port = version.equals("rfc5425") ? syslogRfc5425ServerPort : syslogRfc3164ServerPort;
+        producerTemplate.sendBody(
+                "netty:udp://127.0.0.1:" + port + "?sync=false&allowDefaultCodec=false&useByteBuf=true",
+                message.getBytes(StandardCharsets.UTF_8));
+        return Response.created(new URI("https://camel.apache.org/")).build();
+    }
+
+    @Path("/messages")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getSyslogMessage() {
+        SyslogMessage syslogMessage = consumerTemplate.receiveBodyNoWait("seda:syslog-unmarshalled", SyslogMessage.class);

Review comment:
       I think I've read it right. I've simulated a slow data format with `.process(sleep(1000))` and it turns out sysLogMessage is null. `receiveBody` may do the job, or perhaps better a kind of `receiveBody` with timeout if possible.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
aldettinger commented on a change in pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197#discussion_r569451940



##########
File path: integration-tests/syslog/src/main/java/org/apache/camel/quarkus/component/syslog/it/SyslogResource.java
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.syslog.it;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.syslog.SyslogMessage;
+import org.apache.camel.component.syslog.netty.Rfc5425Encoder;
+import org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/syslog")
+public class SyslogResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = "camel.netty.rfc5425.port")
+    int syslogRfc5425ServerPort;
+
+    @ConfigProperty(name = "camel.netty.rfc3164.port")
+    int syslogRfc3164ServerPort;
+
+    @Path("/send/{version}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    public Response sendMessage(@PathParam("version") String version, String message) throws Exception {
+        int port = version.equals("rfc5425") ? syslogRfc5425ServerPort : syslogRfc3164ServerPort;
+        producerTemplate.sendBody(
+                "netty:udp://127.0.0.1:" + port + "?sync=false&allowDefaultCodec=false&useByteBuf=true",
+                message.getBytes(StandardCharsets.UTF_8));
+        return Response.created(new URI("https://camel.apache.org/")).build();
+    }
+
+    @Path("/messages")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getSyslogMessage() {
+        SyslogMessage syslogMessage = consumerTemplate.receiveBodyNoWait("seda:syslog-unmarshalled", SyslogMessage.class);

Review comment:
       I read the from("netty...) routes as one-way asynchronous, is there any chance that sysLogMessage be null from time to time ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton commented on pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197#issuecomment-773088075


   Merging despite unrelated build failures. Syslog tests passed.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton commented on a change in pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on a change in pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197#discussion_r569508635



##########
File path: integration-tests/syslog/src/main/java/org/apache/camel/quarkus/component/syslog/it/SyslogResource.java
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.syslog.it;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.syslog.SyslogMessage;
+import org.apache.camel.component.syslog.netty.Rfc5425Encoder;
+import org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/syslog")
+public class SyslogResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = "camel.netty.rfc5425.port")
+    int syslogRfc5425ServerPort;
+
+    @ConfigProperty(name = "camel.netty.rfc3164.port")
+    int syslogRfc3164ServerPort;
+
+    @Path("/send/{version}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    public Response sendMessage(@PathParam("version") String version, String message) throws Exception {
+        int port = version.equals("rfc5425") ? syslogRfc5425ServerPort : syslogRfc3164ServerPort;
+        producerTemplate.sendBody(
+                "netty:udp://127.0.0.1:" + port + "?sync=false&allowDefaultCodec=false&useByteBuf=true",
+                message.getBytes(StandardCharsets.UTF_8));
+        return Response.created(new URI("https://camel.apache.org/")).build();
+    }
+
+    @Path("/messages")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getSyslogMessage() {
+        SyslogMessage syslogMessage = consumerTemplate.receiveBodyNoWait("seda:syslog-unmarshalled", SyslogMessage.class);

Review comment:
       You mean we should block & use `consumerTemplate.receiveBody`?
   
   I've not see the null scenario but maybe it could happen with `receiveBodyNoWait`.
   
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton merged pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
jamesnetherton merged pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton commented on a change in pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on a change in pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197#discussion_r569545661



##########
File path: integration-tests/syslog/src/main/java/org/apache/camel/quarkus/component/syslog/it/SyslogResource.java
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.syslog.it;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.syslog.SyslogMessage;
+import org.apache.camel.component.syslog.netty.Rfc5425Encoder;
+import org.apache.camel.component.syslog.netty.Rfc5425FrameDecoder;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+@Path("/syslog")
+public class SyslogResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
+
+    @ConfigProperty(name = "camel.netty.rfc5425.port")
+    int syslogRfc5425ServerPort;
+
+    @ConfigProperty(name = "camel.netty.rfc3164.port")
+    int syslogRfc3164ServerPort;
+
+    @Path("/send/{version}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    public Response sendMessage(@PathParam("version") String version, String message) throws Exception {
+        int port = version.equals("rfc5425") ? syslogRfc5425ServerPort : syslogRfc3164ServerPort;
+        producerTemplate.sendBody(
+                "netty:udp://127.0.0.1:" + port + "?sync=false&allowDefaultCodec=false&useByteBuf=true",
+                message.getBytes(StandardCharsets.UTF_8));
+        return Response.created(new URI("https://camel.apache.org/")).build();
+    }
+
+    @Path("/messages")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getSyslogMessage() {
+        SyslogMessage syslogMessage = consumerTemplate.receiveBodyNoWait("seda:syslog-unmarshalled", SyslogMessage.class);

Review comment:
       Latest commit uses `receiveBody` with a timeout. I tested by adding the `delayer` EIP into the routes and it seems to work ok now, where it failed before the change.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton merged pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
jamesnetherton merged pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] jamesnetherton commented on pull request #2197: Syslog native support

Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on pull request #2197:
URL: https://github.com/apache/camel-quarkus/pull/2197#issuecomment-773088075


   Merging despite unrelated build failures. Syslog tests passed.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org