Search in sources :

Example 1 with PolicyMap

use of org.apache.activemq.broker.region.policy.PolicyMap in project camel by apache.

the class QueueProducerQoSTest method configureBroker.

@Override
protected void configureBroker(BrokerService broker) throws Exception {
    broker.setUseJmx(true);
    broker.setPersistent(true);
    broker.setDataDirectory("target/activemq-data");
    broker.deleteAllMessages();
    broker.setAdvisorySupport(true);
    broker.addConnector(brokerUri);
    // configure expiration rate
    ActiveMQQueue queueName = new ActiveMQQueue(">");
    PolicyEntry entry = new PolicyEntry();
    entry.setDestination(queueName);
    entry.setExpireMessagesPeriod(1000);
    PolicyMap policyMap = new PolicyMap();
    policyMap.put(queueName, entry);
    broker.setDestinationPolicy(policyMap);
}
Also used : PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry)

Example 2 with PolicyMap

use of org.apache.activemq.broker.region.policy.PolicyMap in project ignite by apache.

the class IgniteJmsStreamerTest method beforeTest.

/**
     * @throws Exception If failed.
     */
@Before
@SuppressWarnings("unchecked")
public void beforeTest() throws Exception {
    grid().<Integer, String>getOrCreateCache(defaultCacheConfiguration());
    broker = new BrokerService();
    broker.setDeleteAllMessagesOnStartup(true);
    broker.setPersistent(false);
    broker.setPersistenceAdapter(null);
    broker.setPersistenceFactory(null);
    PolicyMap plcMap = new PolicyMap();
    PolicyEntry plc = new PolicyEntry();
    plc.setQueuePrefetch(1);
    broker.setDestinationPolicy(plcMap);
    broker.getDestinationPolicy().setDefaultEntry(plc);
    broker.setSchedulerSupport(false);
    broker.start(true);
    connFactory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) BrokerService(org.apache.activemq.broker.BrokerService) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry) Before(org.junit.Before)

Example 3 with PolicyMap

use of org.apache.activemq.broker.region.policy.PolicyMap in project ignite by apache.

the class IgniteMqttStreamerTest method beforeTest.

/**
     * @throws Exception If failed.
     */
@Before
@SuppressWarnings("unchecked")
public void beforeTest() throws Exception {
    grid().<Integer, String>getOrCreateCache(defaultCacheConfiguration());
    // find an available local port
    try (ServerSocket ss = new ServerSocket(0)) {
        port = ss.getLocalPort();
    }
    // create the broker
    broker = new BrokerService();
    broker.setDeleteAllMessagesOnStartup(true);
    broker.setPersistent(false);
    broker.setPersistenceAdapter(null);
    broker.setPersistenceFactory(null);
    PolicyMap plcMap = new PolicyMap();
    PolicyEntry plc = new PolicyEntry();
    plc.setQueuePrefetch(1);
    broker.setDestinationPolicy(plcMap);
    broker.getDestinationPolicy().setDefaultEntry(plc);
    broker.setSchedulerSupport(false);
    // add the MQTT transport connector to the broker
    broker.addConnector("mqtt://localhost:" + port);
    broker.setStartAsync(false);
    broker.start(true);
    // create the broker URL
    brokerUrl = "tcp://localhost:" + port;
    // create the client and connect
    client = new MqttClient(brokerUrl, UUID.randomUUID().toString(), new MemoryPersistence());
    client.connect();
    // create mqtt streamer
    dataStreamer = grid().dataStreamer(DEFAULT_CACHE_NAME);
    streamer = createMqttStreamer(dataStreamer);
}
Also used : MqttClient(org.eclipse.paho.client.mqttv3.MqttClient) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) MemoryPersistence(org.eclipse.paho.client.mqttv3.persist.MemoryPersistence) ServerSocket(java.net.ServerSocket) BrokerService(org.apache.activemq.broker.BrokerService) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry) Before(org.junit.Before)

Aggregations

PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)3 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)3 BrokerService (org.apache.activemq.broker.BrokerService)2 Before (org.junit.Before)2 ServerSocket (java.net.ServerSocket)1 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)1 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)1 MqttClient (org.eclipse.paho.client.mqttv3.MqttClient)1 MemoryPersistence (org.eclipse.paho.client.mqttv3.persist.MemoryPersistence)1