public class classicHashDemoProducer {
public static void main(String[] args) throws IOException, TimeoutException, NoSuchAlgorithmException, KeyManagementException, InterruptedException {
final String host = "xxxxxxx.rabbitmq.volces.com";
final String username = "xxxx";
final String password = "xxxxxx";
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername(username);
factory.setPassword(password);
factory.setAutomaticRecoveryEnabled(true);
factory.setNetworkRecoveryInterval(5000);
factory.setConnectionTimeout(30 * 1000);
factory.setHandshakeTimeout(30 * 1000);
factory.setShutdownTimeout(0);
factory.useSslProtocol();
final String vhost = "/";
final String EXCHANGE_NAME = "HashExchange";
factory.setVirtualHost(vhost);
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
for (int i = 0; i < 10000; i++) {
String message = "Hello, RabbitMQ!";
String messageId = UUID.randomUUID().toString();
String RoutingKey = UUID.randomUUID().toString();
channel.basicPublish(EXCHANGE_NAME, RoutingKey,
MessageProperties.PERSISTENT_TEXT_PLAIN.builder()
.build(), message.getBytes());
System.out.println(" Sent message: '" + message + "' with id: " + messageId);