use of javax.jms.ObjectMessage in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeMessagingController method saveCommonEntity.
private void saveCommonEntity(Principal principal, String id, Serializable object) throws PermissionDeniedException {
DataNode dataNode = getDatanode(principal);
String queueBase = MessagingUtils.Entities.getBaseQueue(dataNode);
String responseQueue = getResponseQueueName(queueBase);
jmsTemplate.send(responseQueue, session -> {
ObjectMessage message = session.createObjectMessage(object);
message.setJMSCorrelationID(id);
return message;
});
}
use of javax.jms.ObjectMessage in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeMessagingController method saveListResponse.
/**
* Posts responses for for CommonEntity list requests
* (for pushing by Node's back)
*/
@ApiOperation("Posts responses for for CommonEntity list requests")
@RequestMapping(value = "/api/v1/data-nodes/entity-lists/responses", method = POST)
public void saveListResponse(@RequestBody @Valid CommonListEntityResponseDTO commonListEntityResponseDTO, Principal principal) throws PermissionDeniedException {
DataNode dataNode = getDatanode(principal);
String responseQueue = getResponseQueueName(MessagingUtils.EntitiesList.getBaseQueue(dataNode));
List<CommonEntityDTO> response = (List<CommonEntityDTO>) commonListEntityResponseDTO.getEntities();
for (String correlationId : commonListEntityResponseDTO.getRequestIds()) {
jmsTemplate.send(responseQueue, session -> {
ObjectMessage message = session.createObjectMessage((Serializable) response);
message.setJMSCorrelationID(correlationId);
return message;
});
}
}
use of javax.jms.ObjectMessage in project qpid-broker-j by apache.
the class ObjectMessageClassAllowlistingTest method doTestAllowListedEnclosedClassTest.
private void doTestAllowListedEnclosedClassTest(Connection c, Serializable content) throws Exception {
Queue destination = createQueue(getTestName());
c.start();
Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = s.createConsumer(destination);
MessageProducer producer = s.createProducer(destination);
final ObjectMessage sendMessage = s.createObjectMessage();
sendMessage.setObject(content);
producer.send(sendMessage);
Message receivedMessage = consumer.receive(getReceiveTimeout());
assertNotNull("did not receive message within receive timeout", receivedMessage);
assertTrue("message is of wrong type", receivedMessage instanceof ObjectMessage);
Object receivedObject = ((ObjectMessage) receivedMessage).getObject();
assertEquals("Received object has unexpected class", content.getClass(), receivedObject.getClass());
assertEquals("Received object has unexpected content", content, receivedObject);
}
use of javax.jms.ObjectMessage in project qpid-broker-j by apache.
the class ObjectMessageClassAllowlistingTest method testDenyListedClassByConnectionUrlObjectMessage.
@Test
public void testDenyListedClassByConnectionUrlObjectMessage() throws Exception {
Queue destination = createQueue(getTestName());
final Connection c = getConnectionBuilder().setDeserializationPolicyAllowList("java").setDeserializationPolicyDenyList("java.lang.Integer").build();
try {
c.start();
Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = s.createConsumer(destination);
MessageProducer producer = s.createProducer(destination);
sendTestObjectMessage(s, producer);
Message receivedMessage = consumer.receive(getReceiveTimeout());
assertNotNull("did not receive message within receive timeout", receivedMessage);
assertTrue("message is of wrong type", receivedMessage instanceof ObjectMessage);
ObjectMessage receivedObjectMessage = (ObjectMessage) receivedMessage;
try {
receivedObjectMessage.getObject();
fail("Should not be allowed to deserialize black listed class");
} catch (JMSException e) {
// pass
}
} finally {
c.close();
}
}
use of javax.jms.ObjectMessage in project qpid-broker-j by apache.
the class ObjectMessageClassAllowlistingTest method sendTestObjectMessage.
private void sendTestObjectMessage(final Session s, final MessageProducer producer) throws JMSException {
HashMap<String, Integer> messageContent = new HashMap<>();
messageContent.put("value", TEST_VALUE);
Message objectMessage = s.createObjectMessage(messageContent);
producer.send(objectMessage);
}
Aggregations