Search in sources :

Example 1 with PushConsumerResource

use of org.apache.activemq.artemis.rest.queue.push.PushConsumerResource in project activemq-artemis by apache.

the class QueueDestinationsResource method createQueueResource.

public QueueResource createQueueResource(String queueName, boolean defaultDurable, int timeoutSeconds, boolean duplicates) throws Exception {
    QueueResource queueResource = new QueueResource();
    queueResource.setQueueDestinationsResource(this);
    queueResource.setDestination(queueName);
    queueResource.setServiceManager(manager);
    ConsumersResource consumers = new ConsumersResource();
    consumers.setConsumerTimeoutSeconds(timeoutSeconds);
    consumers.setDestination(queueName);
    consumers.setSessionFactory(manager.getConsumerSessionFactory());
    consumers.setServiceManager(manager);
    queueResource.setConsumers(consumers);
    PushConsumerResource push = new PushConsumerResource();
    push.setDestination(queueName);
    push.setSessionFactory(manager.getConsumerSessionFactory());
    push.setJmsOptions(manager.getJmsOptions());
    queueResource.setPushConsumers(push);
    PostMessage sender = null;
    if (duplicates) {
        sender = new PostMessageDupsOk();
    } else {
        sender = new PostMessageNoDups();
    }
    sender.setServiceManager(manager);
    sender.setDefaultDurable(defaultDurable);
    sender.setDestination(queueName);
    sender.setSessionFactory(manager.getSessionFactory());
    sender.setPoolSize(manager.getProducerPoolSize());
    sender.setProducerTimeToLive(manager.getProducerTimeToLive());
    sender.init();
    queueResource.setSender(sender);
    if (manager.getPushStore() != null) {
        push.setPushStore(manager.getPushStore());
        List<PushRegistration> regs = manager.getPushStore().getByDestination(queueName);
        for (PushRegistration reg : regs) {
            push.addRegistration(reg);
        }
    }
    queueResource.start();
    getQueues().put(queueName, queueResource);
    return queueResource;
}
Also used : PushConsumerResource(org.apache.activemq.artemis.rest.queue.push.PushConsumerResource) PushRegistration(org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration)

Aggregations

PushConsumerResource (org.apache.activemq.artemis.rest.queue.push.PushConsumerResource)1 PushRegistration (org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration)1