Example usage for javax.jms JMSException JMSException

List of usage examples for javax.jms JMSException JMSException

Introduction

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

Prototype

public JMSException(String reason) 

Source Link

Document

Constructs a JMSException with the specified reason and with the error code defaulting to null.

Usage

From source file:org.addsimplicity.anicetus.io.jms.JsonMessageConverter.java

/**
 * Convert a JMS text message with a JSON payload to a telemetry artifact.
 * /*from   w  w w.  j  a v  a  2s  .  c  om*/
 * @param msg
 *          The JMS text message.
 * @return the telemetry artifact.
 * @see org.springframework.jms.support.converter.MessageConverter#fromMessage(javax.jms.Message)
 */
public Object fromMessage(Message msg) throws JMSException, MessageConversionException {
    if (msg instanceof TextMessage) {
        return m_decoder.decode(((TextMessage) msg).getText().toCharArray());
    } else {
        throw new JMSException(
                "Message of type " + msg.getClass().getName() + " is not supported. Only TextMessage");
    }

}

From source file:it.geosolutions.geoserver.jms.JMSPublisher.java

/**
 * Used to publish the event on the queue.
 * /* www  .  ja v a 2 s .  c  o  m*/
 * @param <S> a serializable object
 * @param <O> the object to serialize using a JMSEventHandler
 * @param destination
 * @param jmsTemplate the template to use to publish on the topic <br>
 *        (default destination should be already set)
 * @param props the JMSProperties used by this instance of GeoServer
 * @param object the object (or event) to serialize and send on the JMS topic
 * 
 * @throws JMSException
 */
public <S extends Serializable, O> void publish(final Topic destination, final JmsTemplate jmsTemplate,
        final Properties props, final O object) throws JMSException {
    try {

        final JMSEventHandler<S, O> handler = jmsManager.getHandler(object);

        // set the used SPI
        props.put(JMSEventHandlerSPI.getKeyName(), handler.getGeneratorClass().getSimpleName());

        // TODO make this configurable
        final MessageCreator creator = new JMSObjectMessageCreator(handler.serialize(object), props);

        jmsTemplate.send(destination, creator);

    } catch (Exception e) {
        if (LOGGER.isLoggable(java.util.logging.Level.SEVERE)) {
            LOGGER.severe(e.getLocalizedMessage());
        }
        final JMSException ex = new JMSException(e.getLocalizedMessage());
        ex.initCause(e);
        throw ex;
    }
}

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

@Test
/** test with message where JMSException is forced to happend
 * but we effectively are asserting it must get swallowed*/
public void testBadMessage() throws JMSException {
    TextMessage message = mock(TextMessage.class);
    when(message.getJMSCorrelationID()).thenThrow(new JMSException("mock-force"));
    listener.onMessage(message);//w ww  .jav a 2  s .c  o  m
}

From source file:de.taimos.dvalin.interconnect.core.spring.DaemonMessageSender.java

private void sendIVO(final String correlationID, final Destination replyTo, final InterconnectObject ico,
        final boolean secure) throws Exception {
    final String json = InterconnectMapper.toJson(ico);
    this.logger.debug("TextMessage send: " + json);
    this.template.send(replyTo, new MessageCreator() {

        @Override//from ww  w  . j  a v a  2s  .c o  m
        public Message createMessage(final Session session) throws JMSException {
            final TextMessage textMessage = session.createTextMessage();
            textMessage.setStringProperty(InterconnectConnector.HEADER_ICO_CLASS, ico.getClass().getName());
            textMessage.setJMSCorrelationID(correlationID);
            textMessage.setText(json);
            if (secure) {
                try {
                    MessageConnector.secureMessage(textMessage);
                } catch (CryptoException e) {
                    throw new JMSException(e.getMessage());
                }
            }
            return textMessage;
        }
    });
}

From source file:com.amalto.core.storage.task.staging.ClusteredStagingTaskManager.java

protected void sendCancellationMessage(final String dataContainer, final String taskId) {
    jmsTemplate.send(new MessageCreator() {
        @Override/* w ww  . j av a2 s  . c o  m*/
        public Message createMessage(Session session) throws JMSException {
            TextMessage message = session.createTextMessage();
            try {
                String msg = StagingJobCancellationMessage
                        .toString(new StagingJobCancellationMessage(dataContainer, taskId));
                message.setText(msg);
                return message;
            } catch (JAXBException e) {
                LOGGER.error("Cannot unmarshall message", e);
                throw new JMSException("Cannot unmarshall message");
            }
        }
    });
}

From source file:com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper.java

/**
 * @param amazonSQSClient//from  www.jav  a  2 s  .  co  m
 *            The AWS SDK Client for SQS.
 * @throws JMSException
 *            if the client is null
 */
public AmazonSQSMessagingClientWrapper(AmazonSQS amazonSQSClient) throws JMSException {
    if (amazonSQSClient == null) {
        throw new JMSException("Amazon SQS client cannot be null");
    }
    this.amazonSQSClient = amazonSQSClient;
}

From source file:com.adaptris.core.jms.JmsPollingConsumer.java

@Override
protected MessageConsumer createConsumer() throws JMSException {
    String rfc6167 = getDestination().getDestination();
    String filterExp = getDestination().getFilterExpression();
    MessageConsumer consumer = null;/* w  w  w  .  ja v  a2  s  .  c o m*/

    VendorImplementation vendor = configuredVendorImplementation();
    JmsDestination d = vendor.createDestination(rfc6167, this);
    if (d.destinationType().equals(DestinationType.TOPIC)) {
        if (!isEmpty(d.subscriptionId()) && !isEmpty(getClientId())) {
            consumer = currentSession().createDurableSubscriber((Topic) d.getDestination(), d.subscriptionId(),
                    filterExp, false);
        } else {
            throw new JMSException("Cannot create durable subscription clientId=[" + getClientId()
                    + "], subscriptionId=[" + d.subscriptionId() + "]");
        }
    } else {
        consumer = currentSession().createConsumer(d.getDestination(), filterExp);
    }
    return consumer;
}

From source file:com.mothsoft.alexis.engine.textual.ParseResponseMessageListener.java

@Override
public void onMessage(final TextMessage message, final Session session) throws JMSException {

    final long documentId = message.getLongProperty(DOCUMENT_ID);
    logger.info("Received response for document ID: " + documentId);

    final String xml = message.getText();

    try {/* w w w  . j  av  a  2  s.  com*/
        final ParsedContent parsedContent = readResponse(xml);
        updateDocument(documentId, parsedContent);
    } catch (final IOException e) {
        final JMSException e2 = new JMSException(e.getMessage());
        e2.setLinkedException(e);
        throw e2;
    }
}

From source file:org.logicblaze.lingo.jms.impl.OneWayRequestor.java

public Message receive(long timeout) throws JMSException {
    throw new JMSException("receive(long) not implemented for OneWayRequestor");
}

From source file:org.logicblaze.lingo.jms.impl.OneWayRequestor.java

public Message request(Destination destination, Message message) throws JMSException {
    throw new JMSException("request(Destination, Message) not implemented for OneWayRequestor");
}