import logging


def split_and_put_into_ques(message_batch, que_urls, client, max_batch_size=10):
    """
    Args:
        message_batch: List of all messages to be put onto the que
        que_urls: List of que_urls for messages to be put onto
        max_batch_size: Maximum batch size (default to 10 for sqs)
        client: boto3 sqs client
    :return
        num_messages_success: Number of successful messages
    """

    num_messages_success = 0
    num_messages_failed = 0
    logger = logging.getLogger('__main__')

    # Split message batch into equal chunk sizes for each SQS Que
    chunks = [message_batch[i::len(que_urls)] for i in range(len(que_urls))]
    messages_per_que = zip(chunks, que_urls)

    # For each que and chunk, put onto SQS
    for chunk, que_url in messages_per_que:

        for k in range(0, len(chunk), max_batch_size):
            response = client.send_message_batch(QueueUrl=que_url,
                                                 Entries=chunk[k:k + max_batch_size])
            num_messages_success += len(response.get('Successful', []))
            num_messages_failed += len(response.get('Failed', []))
        logger.info(f"Total Successful Messages: {len(chunk)} successful for {que_url}")

    logger.info(f"Total Successful messages for all ques: {num_messages_success}")
    logger.info(f"Total failed messages for all ques: {num_messages_failed}")

    return num_messages_success