use of com.odysseusinc.arachne.commons.service.messaging.ConsumerTemplate in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeMessagingController method getEntityRequests.
@RequestMapping(value = "/api/v1/data-nodes/entities", method = GET)
public List<CommonEntityRequestDTO> getEntityRequests(Principal principal) throws PermissionDeniedException, JMSException {
DataNode dataNode = getDatanode(principal);
final String requestQueue = getRequestQueueName(MessagingUtils.Entities.getBaseQueue(dataNode));
ConsumerTemplate consumerTpl = new ConsumerTemplate(destinationResolver, requestQueue, // Give some time for case when new connection to a broker is established
1000L);
List<CommonEntityRequestDTO> cohortRequests = new ArrayList<>();
while (true) {
ObjectMessage requestMessage = jmsTemplate.execute(consumerTpl, true);
if (requestMessage == null) {
break;
}
final CommonEntityRequestDTO cohortRequest = (CommonEntityRequestDTO) requestMessage.getObject();
cohortRequest.setId(requestMessage.getJMSCorrelationID());
cohortRequests.add(cohortRequest);
}
return cohortRequests;
}
use of com.odysseusinc.arachne.commons.service.messaging.ConsumerTemplate in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeMessageServiceImpl method getListRequest.
@Override
public CommonListEntityRequest getListRequest(DN dataNode) throws JMSException {
Map<String, CommonEntityRequestObject> requestMap = new LinkedHashMap<>();
String requestQueue = getRequestQueueName(MessagingUtils.EntitiesList.getBaseQueue(dataNode));
ConsumerTemplate consumerTpl = new ConsumerTemplate(destinationResolver, requestQueue, // Give some time for case when new connection to a broker is established
1000L);
while (true) {
ObjectMessage requestMessage = jmsTemplate.execute(consumerTpl, true);
if (requestMessage == null) {
break;
}
requestMap.put(requestMessage.getJMSCorrelationID(), (CommonEntityRequestObject) requestMessage.getObject());
}
return new CommonListEntityRequest(requestMap);
}
Aggregations