List of usage examples for javax.jms TextMessage getText
String getText() throws JMSException;
From source file:com.inkubator.sms.gateway.service.impl.SmsMessagesListener.java
@Override @Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void onMessage(Message message) { try {//from ww w.jav a2 s. com LOGGER.info("Sending SMS Begin"); TextMessage textMessage = (TextMessage) message; String json = textMessage.getText(); SMSSend smss = (SMSSend) jsonConverter.getClassFromJson(json, SMSSend.class); LOGGER.info("Sending Messages " + smss.getContent()); LOGGER.info("Sending Messages " + smss.getDestination()); SmsActivity activity = new SmsActivity(); activity.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(9))); activity.setContentSms(smss.getContent()); activity.setDestination(smss.getDestination()); activity.setIsSchedule(false); activity.setFromSms(smss.getFrom()); activity.setIsSend(true); activity.setSendDate(new Date()); activity.setSendTime(new Date()); activity.setPriceSms(smss.getPricePerSms()); smsActivityDao.save(activity); OutboundMessage msg = new OutboundMessage(smss.getDestination(), smss.getContent()); msg.setFlashSms(false); if (smss.getModemId() == null) { Service.getInstance().sendMessage(msg); } else { Service.getInstance().sendMessage(msg, smss.getModemId()); } LOGGER.info("Sending SMS Done"); } catch (Exception ex) { LOGGER.error("Error", ex); } // } catch (JMSException | TimeoutException | GatewayException | IOException | InterruptedException ex) { // LOGGER.error("Error", ex); // } }
From source file:org.hoteia.qalingo.core.jms.syncserveur.listener.SyncServeurStatusQueueListener.java
/** * Implementation of <code>MessageListener</code>. *//*w ww. j a v a2 s . c om*/ public void onMessage(Message message) { try { if (message instanceof TextMessage) { TextMessage tm = (TextMessage) message; String valueJMSMessage = tm.getText(); if (StringUtils.isNotEmpty(valueJMSMessage)) { final SyncServeurMessageJms syncServeurMessageJms = xmlMapper.getXmlMapper() .readValue(valueJMSMessage, SyncServeurMessageJms.class); ServerStatus serverStatus = new ServerStatus(); serverStatus.setLastCheckReceived(new Date()); serverStatus.setServerName(syncServeurMessageJms.getServerName()); serverStatus.setServerIp(syncServeurMessageJms.getServerIp()); serverService.saveOrUpdateServerStatus(serverStatus, valueJMSMessage); if (logger.isDebugEnabled()) { logger.debug("Processed message, value: " + valueJMSMessage); } } else { logger.warn("SyncServeur Jms Message is empty"); } } } catch (JMSException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } }
From source file:org.apache.stratos.adc.topology.mgt.subscriber.TopologyListener.java
@SuppressWarnings("unchecked") public void onMessage(Message message) { TextMessage receivedMessage = (TextMessage) message; try {/*from ww w. ja v a 2 s . c om*/ ConfigHolder.getInstance().getSharedTopologyDiffQueue().add(receivedMessage.getText()); } catch (JMSException e) { log.error(e.getMessage(), e); } }
From source file:org.apache.stratos.lb.endpoint.subscriber.TopologyListener.java
@Override public void onMessage(Message message) { TextMessage receivedMessage = (TextMessage) message; try {//from www . java 2 s.c o m ConfigHolder.getInstance().getSharedTopologyDiffQueue().add(receivedMessage.getText()); } catch (JMSException e) { log.error(e.getMessage(), e); } }
From source file:org.logicblaze.lingo.jms.marshall.XStreamMarshaller.java
public RemoteInvocationResult extractInvocationResult(Message message) throws JMSException { if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); return (RemoteInvocationResult) fromXML(text); }/*from ww w. ja v a 2s . c om*/ return super.extractInvocationResult(message); }
From source file:org.logicblaze.lingo.jms.marshall.XStreamMarshaller.java
public RemoteInvocation readRemoteInvocation(Message message) throws JMSException { if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); return (RemoteInvocation) fromXML(text); }//w w w . j av a 2 s. com return super.readRemoteInvocation(message); }
From source file:org.logicblaze.lingo.jms.marshall.XStreamMarshaller.java
public Object readMessage(Message message) throws JMSException { if (message instanceof TextMessage) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); return fromXML(text); }// ww w. jav a 2s . c o m return super.readMessage(message); }
From source file:com.oneops.controller.jms.CmsListenerTest.java
@Test /** test with message where JMSException is forced to happend * but we effectively are asserting it must get swallowed*/ public void testBadMessage() throws Exception { TextMessage message = mock(TextMessage.class); when(message.getText()).thenThrow(new JMSException("mock-forces-errorJMS")); listener.onMessage(message);/*from ww w . j a v a2s . com*/ }
From source file:com.oneops.search.listener.SearchListener.java
/** * //from w w w. ja va 2 s . c om * @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:eu.europa.ec.fisheries.uvms.rules.service.bean.ExchangeRuleServiceBean.java
@Override public boolean identificationExists(String messageGuid, String typeRefType) { Boolean messageGuidIdentificationExists = false; try {/* w w w . j av a 2s . com*/ LogIdByTypeExistsRequest existsRequest = new LogIdByTypeExistsRequest(); existsRequest.setRefType(EnumUtils.getEnum(TypeRefType.class, typeRefType)); existsRequest.setMessageGuid(messageGuid); existsRequest.setMethod(ExchangeModuleMethod.LOG_ID_BY_TYPE_EXISTS); String jaxBObjectToString = marshallJaxBObjectToString(existsRequest); String jmsMessageID = producer.sendDataSourceMessage(jaxBObjectToString, EXCHANGE); TextMessage message = consumer.getMessage(jmsMessageID, TextMessage.class); String text = message.getText(); LogIdByTypeExistsResponse response = unMarshallMessage(text, LogIdByTypeExistsResponse.class); messageGuidIdentificationExists = response.getMessageGuid() != null; } catch (JAXBException | MessageException | JMSException e) { log.error(e.getMessage(), e); } return messageGuidIdentificationExists; }