List of usage examples for org.springframework.jms.core JmsTemplate receiveAndConvert
@Override @Nullable public Object receiveAndConvert(String destinationName) throws JmsException
From source file:camelpoc.AmqBrokerTest.java
@Test public void shouldCreateAmqBroker() throws Exception { // Given//from w w w. j av a 2 s .c o m ServiceProxy<FabricService> fabricService = ServiceProxy.createServiceProxy(bundleContext, FabricService.class); String message = "message"; String queue = "queue"; System.err.println(executeCommand("fabric:create -n")); containers = create(fabricService).withName("router-container").withProfiles("mq-amq") .assertProvisioningResult().build(); ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "admin", "discovery:(fabric:default)"); JmsTemplate jms = new JmsTemplate(connectionFactory); // When jms.convertAndSend(queue, message); String receivedMessage = (String) jms.receiveAndConvert(queue); // Then assertEquals(message, receivedMessage); }
From source file:org.openengsb.ports.jms.JMSOutgoingPort.java
@Override protected String doFilter(String input, Map<String, Object> metaData) { String destination = (String) metaData.get("destination"); String callId = (String) metaData.get("callId"); LOGGER.info("sending message with callId {} to destination {}", callId, destination); sendMessage(destination, input);//from w w w . j a va 2s. co m if (ObjectUtils.notEqual(metaData.get("answer"), true)) { LOGGER.debug("no answer expected, just returning null"); return null; } LOGGER.info("waiting {}ms for response on call with id {}", timeout, callId); JmsTemplate createJMSTemplate = createJMSTemplate(destination); createJMSTemplate.setReceiveTimeout(timeout); Object receiveAndConvert = createJMSTemplate.receiveAndConvert(callId); if (receiveAndConvert == null) { throw new RuntimeException("JMS Receive Timeout reached"); } LOGGER.info("response for call with id {} received", callId); return (String) receiveAndConvert; }