ramu11 commented on code in PR #25905: URL: https://github.com/apache/camel/pull/25905#discussion_r3893539799
########## components/camel-hivemq/src/main/java/org/apache/camel/component/hivemq/HiveMQEndpoint.java: ########## @@ -0,0 +1,110 @@ +/* + * 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.hivemq; + +import com.hivemq.client.mqtt.MqttClient; +import com.hivemq.client.mqtt.MqttClientBuilder; +import com.hivemq.client.mqtt.mqtt5.Mqtt5AsyncClient; +import org.apache.camel.Category; +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.spi.EndpointServiceLocation; +import org.apache.camel.spi.Metadata; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.spi.UriParam; +import org.apache.camel.spi.UriPath; +import org.apache.camel.support.DefaultEndpoint; + +@UriEndpoint(firstVersion = "4.23.0", scheme = "hivemq", title = "HiveMQ", syntax = "hivemq:topic", + category = { Category.MESSAGING, Category.IOT }, headersClass = HiveMQConstants.class) +public class HiveMQEndpoint extends DefaultEndpoint implements EndpointServiceLocation { + + /** + * The MQTT topic name or pattern to subscribe to or publish on. + */ + @UriPath + @Metadata(required = true) + private String topic; + + /** + * The HiveMQ component configuration options. + */ + @UriParam + @Metadata(description = "To use a custom HiveMQConfiguration") + private HiveMQConfiguration configuration; + + public HiveMQEndpoint(String uri, HiveMQComponent component, HiveMQConfiguration configuration, String topic) { + super(uri, component); + this.configuration = configuration; + this.topic = topic; + } + + @Override + public Producer createProducer() throws Exception { + return new HiveMQProducer(this); + } + + @Override + public Consumer createConsumer(Processor processor) throws Exception { + HiveMQConsumer consumer = new HiveMQConsumer(this, processor); + configureConsumer(consumer); + return consumer; + } + + public Mqtt5AsyncClient createClient() { Review Comment: Addressed. Automatic reconnect is now enabled using automaticReconnectWithDefaultConfig(). The HiveMQ client also handles resubscription when the session is lost, which covers the default cleanStart=true behavior. For configured clientId, we retain the user-provided value to avoid breaking broker ACLs. Reusing the same clientId across multiple connections can cause broker-side collisions, and this constraint is documented. -- 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]
