Search in sources :

Example 1 with InMemoryTbQueueProducer

use of org.thingsboard.server.queue.memory.InMemoryTbQueueProducer in project thingsboard by thingsboard.

the class InMemoryTbTransportQueueFactory method createTransportApiRequestTemplate.

@Override
public TbQueueRequestTemplate<TbProtoQueueMsg<TransportApiRequestMsg>, TbProtoQueueMsg<TransportApiResponseMsg>> createTransportApiRequestTemplate() {
    InMemoryTbQueueProducer<TbProtoQueueMsg<TransportApiRequestMsg>> producerTemplate = new InMemoryTbQueueProducer<>(transportApiSettings.getRequestsTopic());
    InMemoryTbQueueConsumer<TbProtoQueueMsg<TransportApiResponseMsg>> consumerTemplate = new InMemoryTbQueueConsumer<>(transportApiSettings.getResponsesTopic() + "." + serviceInfoProvider.getServiceId());
    DefaultTbQueueRequestTemplate.DefaultTbQueueRequestTemplateBuilder<TbProtoQueueMsg<TransportApiRequestMsg>, TbProtoQueueMsg<TransportApiResponseMsg>> templateBuilder = DefaultTbQueueRequestTemplate.builder();
    templateBuilder.queueAdmin(new TbQueueAdmin() {

        @Override
        public void createTopicIfNotExists(String topic) {
        }

        @Override
        public void destroy() {
        }
    });
    templateBuilder.requestTemplate(producerTemplate);
    templateBuilder.responseTemplate(consumerTemplate);
    templateBuilder.maxPendingRequests(transportApiSettings.getMaxPendingRequests());
    templateBuilder.maxRequestTimeout(transportApiSettings.getMaxRequestsTimeout());
    templateBuilder.pollInterval(transportApiSettings.getResponsePollInterval());
    return templateBuilder.build();
}
Also used : InMemoryTbQueueConsumer(org.thingsboard.server.queue.memory.InMemoryTbQueueConsumer) TbProtoQueueMsg(org.thingsboard.server.queue.common.TbProtoQueueMsg) InMemoryTbQueueProducer(org.thingsboard.server.queue.memory.InMemoryTbQueueProducer) TbQueueAdmin(org.thingsboard.server.queue.TbQueueAdmin) DefaultTbQueueRequestTemplate(org.thingsboard.server.queue.common.DefaultTbQueueRequestTemplate)

Aggregations

TbQueueAdmin (org.thingsboard.server.queue.TbQueueAdmin)1 DefaultTbQueueRequestTemplate (org.thingsboard.server.queue.common.DefaultTbQueueRequestTemplate)1 TbProtoQueueMsg (org.thingsboard.server.queue.common.TbProtoQueueMsg)1 InMemoryTbQueueConsumer (org.thingsboard.server.queue.memory.InMemoryTbQueueConsumer)1 InMemoryTbQueueProducer (org.thingsboard.server.queue.memory.InMemoryTbQueueProducer)1