davsclaus commented on a change in pull request #6323: URL: https://github.com/apache/camel/pull/6323#discussion_r734242104
########## File path: components/camel-mllp/src/main/java/org/apache/camel/component/mllp/internal/IdleTimeoutStrategy.java ########## @@ -0,0 +1,50 @@ +/* + * 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.component.mllp.internal; Review comment: Can we move this out of an internal package as it should be a public api. ########## File path: components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpIdleTimeoutStrategyTest.java ########## @@ -0,0 +1,198 @@ +/* + * 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.component.mllp.internal; + +import java.lang.reflect.Field; +import java.util.concurrent.TimeUnit; + +import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; +import org.apache.camel.EndpointInject; +import org.apache.camel.LoggingLevel; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mllp.MllpComponent; +import org.apache.camel.component.mllp.MllpEndpoint; +import org.apache.camel.component.mllp.MllpTcpClientProducer; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.AvailablePortFinder; +import org.apache.camel.test.junit.rule.mllp.MllpServerResource; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.apache.camel.test.mllp.Hl7TestMessageGenerator; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.mockito.Mockito; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class MllpIdleTimeoutStrategyTest extends CamelTestSupport { + + static final int IDLE_TIMEOUT = 500; + + @RegisterExtension + public MllpServerResource mllpServer = new MllpServerResource("localhost", AvailablePortFinder.getNextAvailable()); + + @EndpointInject("direct://sourcedefault") + ProducerTemplate defaultStrategySource; + + @EndpointInject("direct://sourcereset") + ProducerTemplate resetStrategySource; + + @EndpointInject("direct://sourceclose") + ProducerTemplate closeStrategySource; + + @EndpointInject("mock://target") + MockEndpoint target; + + private MllpEndpoint defaultStrategyEndpoint; + + private MllpEndpoint resetStrategyEndpoint; + + private MllpEndpoint closeStrategyEndpoint; + + private MllpSocketBuffer defaultStrategyMllpSocketBuffer; + + private MllpSocketBuffer resetStrategyMllpSocketBuffer; + + private MllpSocketBuffer closeStrategyMllpSocketBuffer; + + private MllpTcpClientProducer defaultStrategyProducer; + + private MllpTcpClientProducer resetStrategyProducer; + + private MllpTcpClientProducer closeStrategyProducer; + + @Override + protected CamelContext createCamelContext() throws Exception { + if (context != null) { + return context; + } + return super.createCamelContext(); + } + + @Override + protected void doPreSetup() throws Exception { + MllpComponent mllpComponent = new MllpComponent(createCamelContext()); Review comment: You should not create it via new, but use camelContext.getComponent("mllp", MllpComponent.class) so its created by Camel to be correctly initialized ########## File path: components/camel-mllp/src/main/java/org/apache/camel/component/mllp/internal/IdleTimeoutStrategy.java ########## @@ -0,0 +1,50 @@ +/* + * 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.component.mllp.internal; + +import java.util.HashMap; +import java.util.Map; + +public enum IdleTimeoutStrategy { Review comment: This is overkill will lookup map etc when there are 2 values. Keep it just as simple enum ########## File path: components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpEndpoint.java ########## @@ -287,6 +288,17 @@ public void setMaxConcurrentConsumers(int maxConcurrentConsumers) { configuration.setMaxConcurrentConsumers(maxConcurrentConsumers); } + public void setIdleTimeoutStrategy(String strategy) { Review comment: Camel has automatic conversion to enums, so this is not needed. ########## File path: components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpConfiguration.java ########## @@ -106,6 +107,9 @@ @UriParam(label = "codec") String charsetName; + @UriParam(label = "advanced,producer,tcp", defaultValue = "RESET") Review comment: Remove tcp as its not a label category we use, and we should limit this to 2 -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
