Maven java mqttproject

Hi , how to test mqtt publish / subscribers by send a dataset row by row on java maven?

Hello, @Neema ,

Thank you for the outreach, and interest in MQTT!

Could I have you confirm the Java client that is currently being used? Maven is a build automation tool for the Java language, rather than an MQTT client/library. We do have a Java client available here.

Could you provide some more details regarding the broker you are currently using, as well as any additional extensions that have been installed? Additionally, could you provide a more detailed scope of what you are looking to achieve?

A data set can be included as the message contents for MQTT publish requests, and can be broken up and set as multiple messages as well. A cursory implementation would be to build a helper function to send messages, iterating until the data set has been completely published.

Best,
Aaron from HiveMQ Team

Thank you Aaron,
My project is for testing that whether mqtt can publish subscrib my pollutiondata picked up from available repository. The data has gas and time stamp. These 3 columns has to publish row by row after every 10 seconds.

Hi Aaron, I am using Netbeans maven and tcp// mqtt.eclipseprojects.io or sometimes test.mosquito 1883 but everytime the output shows the data file cannot be accessed? Could you guide and provide me to use the right environment to solve this problem? Thanks again

Hello @Neema ,

Thank you for the additional details. I’m afraid I’m still not entirely certain of the tools being utilized for this purpose. It sounds like we are working on a Java project, as Netbeans is a Java IDE (integrated development environment), though I do not know which MQTT library is currently being used. Both Eclipse Projects and Test.Mosquitto are MQTT brokers, rather than clients. Are you currently using the HiveMQ Java client, as linked in my previous message?

Could you share the code that is being used for the MQTT connection, as well as the errors that you are receiving?

Best,
Aaron from HiveMQ Team

Thank you Aaron for helping. Here is the code . The aystem is not allowing zip file of the code that is why sending jpeg images.

Here are the image. The system is not allowing more than one image for new users. Should I post the zip code by email? Here is the main code image

The left part of the code

Hi Aaron, I have sent five images one by one of the main code. Could you check?
Thanks again! :pray:

Hello @neema,

Could you please provide imported client library where MqttClient is defined? This is likely to be the client library that is being used that we are looking to identify. It does look like we are providing accurate broker information to the connection method for the client.

Please provide the specific error that is being received when attempting to utilize the current implementation - my current theory is that we are presenting an invalid message payload, but we will need to see the specific error to identify further.

Additionally, the community forum here does support code snippets directly imbedded in the message, which will be much easier than screenshots moving forward. Here is an example using our Java client, in which a client is created, connected to an MQTT broker, and then subscribing to a topic :

Mqtt5BlockingClient client = Mqtt5Client.builder()
        .identifier(UUID.randomUUID().toString())
        .serverHost("broker.hivemq.com")
        .buildBlocking();

client.connect();

client.toAsync().subscribeWith()
        .topicFilter("test/topic")
        .qos(MqttQos.AT_LEAST_ONCE)
        .callback(System.out::println)
        .send();

Best,
Aaron from HiveMQ Team

Hi Aaron, the error is in the last of the output, which shows error in reading data csv file.

Hi,
It is java.nio. Filepathexception error

Hi, could u send ur email, so that I send the whole code? Thanks again!

Hi,
What shoild be the dependency for the broker you mentioned and the library?
Here are the lbrary I haveused

Hello @Neema ,

Please be sure to read the entire request to ensure that all of the requested items are provided so we can best provide additional support.

It would be best to provide the code via the code support through the community forum, as to best assist any other users that may require assistance on this topic in the future.

With that said, it looks like the issue here is that the CSV is unable to be parsed by this code, which is not an MQTT error and is instead an error with the way the CSV data is being parsed. Based on the snippet provided in the error, it’s likely because the path utilized has a leading /, which is not usable for Windows systems, which looks to be the system in use.

I would recommend removing this leading ‘/’ from the file path. I was able to find some another user encountering a similar issue here.

Best,
Aaron from HiveMQ Team


Hi, after removing / sign it is showing
Java. Net. Unknown hostException: mqtt.eclipseprojects.io

Hi, you have mentioned different broker, could you guide the the pom dependecy and library for the broker uou have mentione??
Thanks again,

Hello @Neema ,

Based on the libraries imaged above, it appears that you are using the Eclipse Paho Java MQTT3 client. The documentation for that client can be found here : GitHub - eclipse/paho.mqtt.java: Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project..

This has connection and code samples to get started with an MQTT connection. This would be my recommended first place to start, as it will allow you get functional MQTT communication up and running before performing debugging on the specific messages that are being sent.

It is also worth clarifying the difference between an MQTT broker and an MQTT client, as these are two different components for an MQTT deployment. Many different brokers and clients are available. At present, it looks like you are using the Eclipse Paho client, as included in the libraries image you previously provided, and the eclipse project open MQTT broker for testing. I suggest reviewing the MQTT fundamentals material, provided here, for some more background information on MQTT. We also offer a Java client, mentioned in a previous message, which has documentation, including dependencies and library information, available here.

As for the current error, it appears that the domain being used is invalid, or unable to be reached. Be sure that port 1883 is open on the client, as well, to allow the connection to succeed.

Best,
Aaron from HiveMQ Team