Example usage for javax.jms JMSException getMessage

List of usage examples for javax.jms JMSException getMessage

Introduction

In this page you can find the example usage for javax.jms JMSException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:unic.mentoring.jms.ctrl.MessageCtrl.java

@RequestMapping(value = "/message", method = RequestMethod.POST)
public String message(Model model, @RequestParam("message") String message,
        @RequestParam("topic") String topic) {
    if (!StringUtils.isEmpty(message)) {
        try {//from w w w  . java2  s.co m
            sendMessage(message, topic);
            model.addAttribute(ATTR_MESSAGE,
                    "Message (length: " + message.length() + ") has been sent into topic \"" + topic + "\".");
        } catch (JMSException e) {
            model.addAttribute(ATTR_MESSAGE, "Can't send message: " + e.getMessage());
        }
    } else {
        model.addAttribute(ATTR_MESSAGE, "No message has been specified to send.");
    }

    return Constants.Page.INDEX;
}

From source file:org.toobsframework.jms.email.JmsEmailReceiver.java

public EmailBean recieveMessage() throws JmsEmailException {
    Message msg = jmsTemplate.receive();
    if (msg == null) {
        return null;
    }//from w w  w  . j  a v a  2s  . c o m
    EmailBean bean = new EmailBean();
    MapMessage mapMessage = (MapMessage) msg;
    try {
        bean.setEmailSender(mapMessage.getString("sender"));
        bean.setEmailSubject(mapMessage.getString("subject"));
        bean.setRecipients(getRecipientList(mapMessage.getString("recipients")));
        bean.setMessageHtml(mapMessage.getString("messageHtml"));
        bean.setMessageText(mapMessage.getString("messageText"));
        bean.setMailSenderKey(mapMessage.getString("mailSenderKey"));
        bean.setAttempts(mapMessage.getInt("attempts"));
        bean.setType(mapMessage.getInt("type"));
        bean.setFailureCause(mapMessage.getString("failureCause"));
    } catch (JMSException e) {
        log.error("Exception getting email from queue: " + e.getMessage(), e);
        throw new JmsEmailException(e);
    }
    return bean;
}

From source file:com.cognifide.aet.worker.listeners.AbstractTaskMessageListener.java

protected void doActivate(Map<String, String> properties) {
    setName(properties.get(LISTENER_NAME));
    this.prefetchSize = StringUtils.defaultString(properties.get(PREFETCH_SIZE_NAME),
            PREFETCH_SIZE_DEFAULT_VALUE);
    String consumerQueueName = properties.get(CONSUMER_QUEUE_NAME);
    setConsumerQueueName(consumerQueueName);
    String producerQueueName = properties.get(PRODUCER_QUEUE_NAME);
    setProducerQueueName(producerQueueName);

    String queueName = consumerQueueName + "?consumer.prefetchSize=" + prefetchSize;
    try {/*from   w  w w.ja  va 2  s  . c  o  m*/
        jmsSession = getJmsConnection().getJmsSession();
        consumer = jmsSession.createConsumer(jmsSession.createQueue(queueName));
        consumer.setMessageListener(this);
        feedbackQueue = new FeedbackQueue(jmsSession, producerQueueName);
    } catch (JMSException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}

From source file:org.hoteia.qalingo.core.jms.document.listener.DocumentQueueListener.java

/**
 * Implementation of <code>MessageListener</code>.
 *///from  w w w.  j av a2 s  . c  o  m
public void onMessage(Message message) {
    try {
        if (message instanceof TextMessage) {
            TextMessage tm = (TextMessage) message;
            String valueJMSMessage = tm.getText();

            if (StringUtils.isNotEmpty(valueJMSMessage)) {
                final GenerationDocumentMessageJms documentMessageJms = xmlMapper.getXmlMapper()
                        .readValue(valueJMSMessage, GenerationDocumentMessageJms.class);

                final OrderPurchase order = orderPurchaseService.getOrderById(documentMessageJms.getOrderId());

                if (documentMessageJms.getDocumentType()
                        .equals(OrderDocumentType.ORDER_CONFIRMATION.getPropertyKey())) {
                    documentService.generateOrderConfirmation(order);

                } else if (documentMessageJms.getDocumentType()
                        .equals(OrderDocumentType.SHIPPING_CONFIRMATION.getPropertyKey())) {
                    documentService.generateShippingConfirmation(order);

                } else if (documentMessageJms.getDocumentType()
                        .equals(OrderDocumentType.INVOICE.getPropertyKey())) {
                    documentService.generateInvoice(order);

                }

                if (logger.isDebugEnabled()) {
                    logger.debug("Processed message, value: " + valueJMSMessage);
                }
            } else {
                logger.warn("Document generation: Jms Message is empty");
            }
        }
    } catch (JMSException e) {
        logger.error(e.getMessage(), e);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:com.oneops.controller.jms.InductorListenerTest.java

@Test
/** test the message impl */
public void testListening() throws JMSException {
    try {//www .  jav a  2  s .c o  m
        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:org.hoteia.qalingo.core.jms.entitycheck.listener.EntityCheckQueueListener.java

/**
 * Implementation of <code>MessageListener</code>.
 *///from ww w .  j a  v  a 2  s.  c o  m
public void onMessage(Message message) {
    try {
        if (message instanceof TextMessage) {
            TextMessage tm = (TextMessage) message;
            String valueJMSMessage = tm.getText();

            if (StringUtils.isNotEmpty(valueJMSMessage)) {
                final EntityCheckMessageJms documentMessageJms = xmlMapper.getXmlMapper()
                        .readValue(valueJMSMessage, EntityCheckMessageJms.class);

                if (logger.isDebugEnabled()) {
                    logger.debug("Processed message, value: " + valueJMSMessage);
                }

                //                    try {
                //                        SpringCamelContext camelContext = (SpringCamelContext) context.getBean("camelContext");
                //                        
                //                        if(!camelContext.getRouteStatus("entityCheckRoute").isStarted()){
                //                            camelContext.startRoute("entityCheckRoute");
                //                        }
                //                        ProducerTemplate template = context.getBean("camelTemplate", ProducerTemplate.class);
                //
                //                        Map<String, Object> params = new HashMap<String, Object>();
                //                        params.put("id", documentMessageJms.getObjectId());
                //                        params.put("type", documentMessageJms.getObjectType());
                //                        template.asyncSendBody("direct:startEntityCheckRoute", params);
                //                        
                //                    } catch (Exception e) {
                //                        e.printStackTrace();
                //                    }
            } else {
                logger.warn("Document generation: Jms Message is empty");
            }
        }
    } catch (JMSException e) {
        logger.error(e.getMessage(), e);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:org.sakaiproject.kernel.messaging.JmsEmailMessageHandler.java

/**
 * {@inheritDoc}/*from w  w  w . j  a v  a  2 s. c  om*/
 *
 * @see org.sakaiproject.kernel.api.messaging.MessageHandler#handle(java.lang.String,
 *      java.lang.String, java.lang.String, javax.jcr.Node)
 */
public void handle(String userID, String filePath, String fileName, Node node) {
    try {
        InputStream inputStream = nodeFactory.getInputStream(filePath);
        String content = IOUtils.readFully(inputStream, "UTF-8");
        Connection conn = connFactory.createConnection();
        conn.setClientID("sakai.emailmessagehandler");
        Session clientSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination emailTopic = clientSession.createTopic(emailQueueName);
        MessageProducer client = clientSession.createProducer(emailTopic);
        ObjectMessage mesg = clientSession.createObjectMessage(content);
        mesg.setJMSType(emailJmsType);
        client.send(mesg);
    } catch (JMSException e) {
        log.error(e.getMessage(), e);
    } catch (RepositoryException e) {
        log.error(e.getMessage(), e);
    } catch (JCRNodeFactoryServiceException e) {
        log.error(e.getMessage(), e);
    } catch (UnsupportedEncodingException e) {
        log.error(e.getMessage(), e);
    } catch (IOException e) {
        log.error(e.getMessage(), e);
    }
}

From source file:com.alliander.osgp.signing.server.infra.messaging.SigningServerRequestMessageListener.java

@Override
public void onMessage(final Message message) {
    try {/*from w ww  .j  a v a 2 s . c om*/
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final Destination replyToQueue = objectMessage.getJMSReplyTo();
        final RequestMessage requestMessage = (RequestMessage) objectMessage.getObject();
        final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = (UnsignedOslpEnvelopeDto) requestMessage
                .getRequest();
        final String correlationUid = objectMessage.getJMSCorrelationID();
        final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);

        LOGGER.info("Received message of type: {}, for device: {} with correlationId: {} and replyToQueue: {}",
                objectMessage.getJMSType(), deviceIdentification, correlationUid, replyToQueue.toString());

        LOGGER.debug("-----------------------------------------------------------------------------");
        LOGGER.debug("unsignedOslpEnvelopeDto.getCorrelationUid() : {}",
                unsignedOslpEnvelopeDto.getCorrelationUid());
        LOGGER.debug("unsignedOslpEnvelopeDto.getDeviceId() : {}", unsignedOslpEnvelopeDto.getDeviceId());
        LOGGER.debug("unsignedOslpEnvelopeDto.getDomain() : {}", unsignedOslpEnvelopeDto.getDomain());
        LOGGER.debug("unsignedOslpEnvelopeDto.getDomainVersion() : {}",
                unsignedOslpEnvelopeDto.getDomainVersion());
        LOGGER.debug("unsignedOslpEnvelopeDto.getIpAddress() : {}", unsignedOslpEnvelopeDto.getIpAddress());
        LOGGER.debug("unsignedOslpEnvelopeDto.getMessageType() : {}", unsignedOslpEnvelopeDto.getMessageType());
        LOGGER.debug("unsignedOslpEnvelopeDto.getOrganisationIdentification() : {}",
                unsignedOslpEnvelopeDto.getOrganisationIdentification());
        LOGGER.debug("unsignedOslpEnvelopeDto.getPayloadMessage() : {}",
                unsignedOslpEnvelopeDto.getPayloadMessage().toString());
        LOGGER.debug("unsignedOslpEnvelopeDto.getRetryCount() : {}", unsignedOslpEnvelopeDto.getRetryCount());
        LOGGER.debug("unsignedOslpEnvelopeDto.getSequenceNumber() : {}",
                unsignedOslpEnvelopeDto.getSequenceNumber());
        LOGGER.debug("unsignedOslpEnvelopeDto.isScheduled() : {}", unsignedOslpEnvelopeDto.isScheduled());
        LOGGER.debug("-----------------------------------------------------------------------------");

        this.signingService.sign(unsignedOslpEnvelopeDto, correlationUid, deviceIdentification, replyToQueue);

    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    }
}

From source file:pl.psnc.synat.wrdz.zmkd.message.ObjectRequestListener.java

@Override
public void onMessage(Message message) {

    AsyncRequestMessage requestMessage;/*from www  .  j  av  a 2s .c o m*/
    try {
        requestMessage = (AsyncRequestMessage) ((ObjectMessage) message).getObject();
    } catch (JMSException e) {
        throw new WrdzRuntimeException(e.getMessage(), e);
    }

    if (ObjectAsyncRequestEnum.FETCH_OBJECT.name().equals(requestMessage.getRequestType())) {
        ObjectFetchingRequest request = (ObjectFetchingRequest) requestMessage.getRequest();

        deliveryPlanExecutor.notifyAvailable(request.getIdentifier());

        List<MigrationPlan> plans = migrationPlanManager.findPlansWaitingForObject(request.getIdentifier());
        for (MigrationPlan plan : plans) {
            migrationPlanProcessorsManager.notifyObjectAvailable(plan);
        }
    } else if (ObjectAsyncRequestEnum.CREATE_OBJECT.name().equals(requestMessage.getRequestType())) {
        if (requestMessage.getResultCode() != null && requestMessage.getResultCode() == HttpStatus.SC_OK) {
            migrationItemManager.logCreationSuccessful(requestMessage.getRequestId());
        } else {
            migrationItemManager.logCreationError(requestMessage.getRequestId(),
                    "" + requestMessage.getResultCode());
        }
    }
}

From source file:de.fzi.ALERT.actor.MessageObserver.NotificationObserver.JMSNotificationListener.java

public void onMessage(Message msg) {
    // TODO Auto-generated method stub

    if (msg instanceof TextMessage) {
        //         model.Message message = new model.Message();
        //         message.setMsgID(1);
        ////         Pattern pattern = (Pattern) patternDAO.findByPatternName("pattern1");
        //         Pattern pattern = (Pattern) patternDAO.find(2);
        //         message.setPatternId(pattern);
        TextMessage tMsg = (TextMessage) msg;
        try {/*from   w w w  . j a  v a2  s . com*/
            //            message.setContent(tMsg.getText());
            de.fzi.ALERT.actor.Model.Message message = parser.parseJsoup(tMsg.getText());
            if (message == null) {
                System.out.println("message is null!!!!");
                return;
            }
            //            messageDAO.create(message);
            if (!message.getContent().equals("ERROR!") && !message.getContent().equals("")) {
                manager.saveMessage(message);
                //               manager.sendAnnouncement(message);
            } else {
                System.out.println("message doesn't have content and will be discarded!");
            }

        } catch (JMSException e) {
            System.out.println("ERROR in paring complex event: " + e.getMessage());
        }
    }
}