<commit_before>package org.fusesource.jmsbenchmark

import org.apache.activemq.ActiveMQConnectionFactory
import javax.jms.{Destination, ConnectionFactory}
import org.apache.activemq.command.{ActiveMQTopic, ActiveMQQueue}
import management.ManagementFactory
import javax.management.ObjectName
import javax.management.openmbean.CompositeData

object ActiveMQScenario {
  def main(args:Array[String]):Unit = {
    val scenario = new ActiveMQScenario
    scenario.url = "tcp://localhost:61613"
    scenario.display_errors = true
    scenario.user_name = "admin"
    scenario.password = "password"
    scenario.message_size = 20
    scenario.producers = 1
    scenario.consumers = 100
    scenario.destination_type = "topic"
    scenario.run()
  }
}

/**
 * <p>
 * ActiveMQ implementation of the JMS Scenario class.
 * </p>
 *
 * @author <a href="http://hiramchirino.com"><NAME></a>
 */
class ActiveMQScenario extends JMSClientScenario {

  override protected def factory:ConnectionFactory = {
    val rc = new ActiveMQConnectionFactory
    rc.setBrokerURL(url)

    // Lets optimize the prefetch used for the scenario.
    val mbean_server = ManagementFactory.getPlatformMBeanServer()
    val heap_usage = mbean_server.getAttribute(new ObjectName("java.lang:type=Memory"), "HeapMemoryUsage").asInstanceOf[CompositeData]
    val heap_max = heap_usage.get("max").asInstanceOf[java.lang.Long].longValue()

    val prefetch_available_heap = (heap_max-(1024*1024*500))/10
    val prefech_size = prefetch_available_heap/(consumers*message_size)
    if( prefech_size < 1000 ) {
      rc.getPrefetchPolicy.setAll(prefech_size.toInt)
    }

    rc
  }

  override protected def destination(i:Int):Destination = destination_type match {
    case "queue" => new ActiveMQQueue(indexed_destination_name(i))
    case "topic" => new ActiveMQTopic(indexed_destination_name(i))
    case _ => sys.error("Unsuported destination type: "+destination_type)
  }

}<commit_msg>Use a 3 second close timeout.<commit_after>package org.fusesource.jmsbenchmark

import org.apache.activemq.ActiveMQConnectionFactory
import javax.jms.{Destination, ConnectionFactory}
import org.apache.activemq.command.{ActiveMQTopic, ActiveMQQueue}
import management.ManagementFactory
import javax.management.ObjectName
import javax.management.openmbean.CompositeData

object ActiveMQScenario {
  def main(args:Array[String]):Unit = {
    val scenario = new ActiveMQScenario
    scenario.url = "tcp://localhost:61613"
    scenario.display_errors = true
    scenario.user_name = "admin"
    scenario.password = "password"
    scenario.message_size = 20
    scenario.producers = 1
    scenario.consumers = 100
    scenario.destination_type = "topic"
    scenario.run()
  }
}

/**
 * <p>
 * ActiveMQ implementation of the JMS Scenario class.
 * </p>
 *
 * @author <a href="http://hiramchirino.com"><NAME></a>
 */
class ActiveMQScenario extends JMSClientScenario {

  override protected def factory:ConnectionFactory = {
    val rc = new ActiveMQConnectionFactory
    rc.setBrokerURL(url)
    rc.setCloseTimeout(3*1000)

    // Lets optimize the prefetch used for the scenario.
    val mbean_server = ManagementFactory.getPlatformMBeanServer()
    val heap_usage = mbean_server.getAttribute(new ObjectName("java.lang:type=Memory"), "HeapMemoryUsage").asInstanceOf[CompositeData]
    val heap_max = heap_usage.get("max").asInstanceOf[java.lang.Long].longValue()

    val prefetch_available_heap = (heap_max-(1024*1024*500))/10
    val prefech_size = prefetch_available_heap/(consumers*message_size)
    if( prefech_size < 1000 ) {
      rc.getPrefetchPolicy.setAll(prefech_size.toInt)
    }

    rc
  }

  override protected def destination(i:Int):Destination = destination_type match {
    case "queue" => new ActiveMQQueue(indexed_destination_name(i))
    case "topic" => new ActiveMQTopic(indexed_destination_name(i))
    case _ => sys.error("Unsuported destination type: "+destination_type)
  }

}
{'fraction_non_alphanumeric': 0.1046894803548796, 'fraction_numerical': 0.015716096324461342, 'mean_word_length': 4.645207439198855, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4674353', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1210, 'n_words': 236}