0

I have messages in Map - key as a Queue Name and value as a List of messages. Whenever I publish the multiple message to queue server throws an exception as user has reached the maximum number of sign-ins permitted.

while publishing messages to 1 queue. Below is code which executes:

public class MessageManager {

public static void publish(String exchange, HashMap<String, List<String>> queueNameWithMessages) throws IOException {
    ...
    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost(Constants.HOST_NAME);
    factory.setUsername(Constants.USER_NAME);
    factory.setPassword(Constants.PASSWORD);
    factory.setPort(Constants.PORT);
    Connection connection = factory.newConnection();
    Channel ch = connection.createChannel();
    Channel ch1 =  connection.createChannel();
    try {
        for(Entry<String, List<String>> entry : queueNameWithMessages) {
            String routingKey = entry.getKey();
            for(String  messageToBeSent : entry.value()) {
                ch.basicPublish(exchange, routingKey, true, MessageProperties.PERSISTENT_BASIC,  messageToBeSent.getValue().getBytes());
            }
            ExecutorService threadExecutor = Executors.newFixedThreadPool(5);
            String responseKey = props.getProperty(routingKey);
            if(!CLAMUtility.workingListnerToRespnseQueue.contains(responseKey)) {
                Worker fast = new Worker(0, threadExecutor, ch1,responseKey, routingKey);
                CLAMUtility.workingListnerToRespnseQueue.add(responseKey);
            }
        }
        ch.close();
        System.out.println("Message published successfully!\n \n");
    } catch (Exception e) {
        e.printStackTrace();
    } 
}

}

Bharat
  • 407
  • 2
  • 7
  • 16
  • Are you publishing the same message to multiple queues? If so, this is what an exchange is for. And as a general best practice you should always publish to exchanges rather than directly to queues. – jhilden Mar 24 '15 at 15:24
  • I am sending all different messages to each queue, that's what I have applied loop over `Entry> entry : queueNameWithMessages` . Thanks for quick reference towards publish exchange. I am looking to publish that way – Bharat Mar 24 '15 at 17:19
  • What do you mean by "server throws an exception as user has reached the maximum number of sign-ins permitted". I don't recall RabbitMQ having this kind of error message – old_sound Apr 17 '15 at 18:51

1 Answers1

0

We discover that this issue is not related to Rabbit MQ. Message consumer system has some user interaction related limitations that is not handled properly.

Thanks!

Bharat
  • 407
  • 2
  • 7
  • 16