List of usage examples for javax.jms TextMessage getStringProperty
String getStringProperty(String name) throws JMSException;
From source file:de.slub.fedora.jms.MessageMapperTest.java
@Test public void returnsIndexJobForPurgeObjectMessage() throws Exception { TextMessage message = mock(TextMessage.class); when(message.getStringProperty(eq("pid"))).thenReturn("test-rest:1"); when(message.getStringProperty(eq("methodName"))).thenReturn("purgeObject"); when(message.getText()).thenReturn(getContent("/jms/purgeObject.xml")); IndexJob ij = findFirstByClass(MessageMapper.map(message), ObjectIndexJob.class); assertEquals(new ObjectIndexJob(IndexJob.Type.DELETE, "test-rest:1"), ij); }
From source file:de.slub.fedora.jms.MessageMapperTest.java
@Test public void returnsObjectIndexJobForUpdateDatastreamMessage() throws Exception { TextMessage message = mock(TextMessage.class); when(message.getStringProperty(eq("pid"))).thenReturn("test-rest:1"); when(message.getStringProperty(eq("methodName"))).thenReturn("modifyDatastreamByValue"); when(message.getText()).thenReturn(getContent("/jms/modifyDatastreamByValue.xml")); IndexJob ij = findFirstByClass(MessageMapper.map(message), ObjectIndexJob.class); assertEquals(new ObjectIndexJob(IndexJob.Type.UPDATE, "test-rest:1", "testModifyDatastream"), ij); }
From source file:com.oneops.controller.jms.InductorListenerTest.java
@Test /** test the message impl */ public void testListening() throws JMSException { try {/*from ww w. java2 s . c om*/ listener.init(); TextMessage message = mock(TextMessage.class); when(message.getText()).thenReturn("{messgetext:true}"); when(message.getStringProperty("task_id")).thenReturn("corel-id"); when(message.getStringProperty("task_result_code")).thenReturn("200"); when(message.getStringProperty("type")).thenReturn("deploybom"); when(message.getJMSCorrelationID()).thenReturn("jms|cor!rel!ation!id"); listener.onMessage(message); listener.cleanup(); listener.getConnectionStats(); } catch (JMSException e) { System.out.println("CAUTH EXCEPTION " + e.getMessage()); e.printStackTrace(); throw e; } }
From source file:com.oneops.search.listener.SearchListener.java
/** * /*from w w w. j av a2 s . c o m*/ * @param message * @throws JMSException */ private void processMessage(TextMessage message) throws JMSException { //System.out.println(message); String jsonMsg = message.getText(); String type = message.getStringProperty("type"); //Check if message is coming from Dead Letter Queue if (message.getStringProperty("dlqDeliveryFailureCause") != null) { type = "dlq"; } if (type == null) { type = message.getStringProperty("source"); } ; String msgId = message.getStringProperty("msgId"); if (msgId == null) { msgId = message.getStringProperty("sourceId"); } ; String action = message.getStringProperty("action"); if ("delete".equals(action) && "cm_ci".equals(type)) { msgId = message.getStringProperty("sourceId"); } else if ("delete".equals(action) && "namespace".equals(type)) { msgId = message.getStringProperty("sourceId"); } if (StringUtils.isNotBlank(jsonMsg)) { msgProcessor.processMessage(jsonMsg, type, msgId); } else { if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(msgId)) { msgProcessor.deleteMessage(type, msgId); } logger.warn("Received blank message for message type::" + type + ", id ::" + msgId); } }
From source file:de.adorsys.jmspojo.JMSMessageListenerServiceAdapterTest.java
@Test public void testCreateAdapterWithReply() throws JMSException { TextMessage textMessage = queueSession.createTextMessage(OBJECT_MAPPER.serialize(new PingMessage("ping"))); textMessage.setJMSReplyTo(reqlayQ);//ww w . jav a 2 s . c o m SampleMessageServiceWithReply service = new SampleMessageServiceWithReply(); JMSMessageListenerServiceAdapter<SampleMessageServiceWithReply> adapter = JMSMessageListenerServiceAdapter .createAdapter(service, cf, OBJECT_MAPPER); adapter.onMessage(textMessage); TextMessage message = (TextMessage) queueSession.createReceiver(reqlayQ).receive(1000); assertNotNull(message); assertNull(message.getStringProperty("ERROR")); assertEquals("{\"ping\":\"ping\"}", message.getText()); }
From source file:de.adorsys.jmspojo.JMSMessageListenerServiceAdapterTest.java
@Test public void testCreateAdapterVoid() throws JMSException { TextMessage textMessage = queueSession.createTextMessage(OBJECT_MAPPER.serialize(new PingMessage("ping"))); textMessage.setJMSReplyTo(reqlayQ);/*ww w.j a v a2 s. co m*/ SampleMessageServiceVoid service = new SampleMessageServiceVoid(); JMSMessageListenerServiceAdapter<SampleMessageServiceVoid> adapter = JMSMessageListenerServiceAdapter .createAdapter(service, cf, OBJECT_MAPPER); adapter.onMessage(textMessage); TextMessage message = (TextMessage) queueSession.createReceiver(reqlayQ).receive(1000); assertNotNull(message); assertNull(message.getStringProperty("ERROR")); assertNull(message.getText()); }
From source file:de.adorsys.jmspojo.JMSMessageListenerServiceAdapterTest.java
@Test public void testCreateAdapterWithHeaders() throws JMSException { TextMessage textMessage = queueSession.createTextMessage(OBJECT_MAPPER.serialize(new PingMessage("ping"))); textMessage.setJMSReplyTo(reqlayQ);//from w ww. j ava2 s . co m textMessage.setBooleanProperty("testHeader", true); SampleMessageServiceWithHeaders service = new SampleMessageServiceWithHeaders(); JMSMessageListenerServiceAdapter<SampleMessageServiceWithHeaders> adapter = JMSMessageListenerServiceAdapter .createAdapter(service, cf, OBJECT_MAPPER); adapter.onMessage(textMessage); TextMessage message = (TextMessage) queueSession.createReceiver(reqlayQ).receive(1000); assertNotNull(message); assertNull(message.getStringProperty("ERROR")); assertNull(message.getText()); }
From source file:de.adorsys.jmspojo.JMSMessageListenerServiceAdapterTest.java
@Test public void testCreateAdapterWithException() throws JMSException { TextMessage textMessage = queueSession.createTextMessage(OBJECT_MAPPER.serialize(new PingMessage("ping"))); textMessage.setJMSReplyTo(reqlayQ);//from w ww.ja v a 2 s.c o m SampleMessageServiceWithException service = new SampleMessageServiceWithException(); JMSMessageListenerServiceAdapter<SampleMessageServiceWithException> adapter = JMSMessageListenerServiceAdapter .createAdapter(service, cf, OBJECT_MAPPER); adapter.onMessage(textMessage); TextMessage message = (TextMessage) queueSession.createReceiver(reqlayQ).receive(1000); assertNotNull(message); assertEquals("java.lang.RuntimeException: expected problem", message.getStringProperty("ERROR")); }
From source file:org.ala.jms.JmsMessageProducer.java
@Test public void generateInvalidMethod() throws JMSException { template.send(new MessageCreator() { public Message createMessage(Session session) throws JMSException { String json = getJson("" + myGuid); TextMessage message = session.createTextMessage(json); message.setStringProperty(JmsMessageListener.MESSAGE_METHOD, ""); logger.debug("B Sending message: " + message.getStringProperty(JmsMessageListener.MESSAGE_METHOD) + " == " + json); return message; }// w ww .ja v a 2s.c om }); }