private Message receive() throws JMSException { try { return messageConsumer.receive(pollTimeout); } catch (RuntimeException runtimeException) { JMSException jmsException = new JMSException("JMS provider has thrown runtime exception: " + runtimeException.getMessage()); jmsException.setLinkedException(runtimeException); throw jmsException; } }
private Message receiveNoWait() throws JMSException { try { return messageConsumer.receiveNoWait(); } catch (RuntimeException runtimeException) { JMSException jmsException = new JMSException("JMS provider has thrown runtime exception: " + runtimeException.getMessage()); jmsException.setLinkedException(runtimeException); throw jmsException; } }
private JMSException handleOutputException(final IOException e) { JMSException ex = new JMSException(e.getMessage()); ex.initCause(e); ex.setLinkedException(e); return ex; }
@Override public void setObject(final Serializable object) throws JMSException { checkWrite(); if (object != null) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(object); oos.flush(); data = baos.toByteArray(); } catch (Exception e) { JMSException je = new JMSException("Failed to serialize object"); je.setLinkedException(e); je.initCause(e); throw je; } } }
public static JMSException create(String msg, Exception cause) { JMSException exception = new JMSException(msg); exception.setLinkedException(cause); exception.initCause(cause); return exception; }
private JMSException handleInputException(final IOException e) { JMSException ex; if (e instanceof EOFException) { ex = new MessageEOFException(e.getMessage()); } else { ex = new MessageFormatException(e.getMessage()); } ex.initCause(e); ex.setLinkedException(e); return ex; } }
public static JMSException create(Exception cause) { if (cause instanceof JMSException) { return (JMSException)cause; } String msg = cause.getMessage(); if (msg == null || msg.length() == 0) { msg = cause.toString(); } JMSException exception; if (cause instanceof SecurityException) { exception = new JMSSecurityException(msg); } else { exception = new JMSException(msg); } exception.setLinkedException(cause); exception.initCause(cause); return exception; }
@Test public void testExceptionStackTrace() { JMSException jmsEx = new JMSException("could not connect"); Exception innerEx = new Exception("host not found"); jmsEx.setLinkedException(innerEx); JmsException springJmsEx = JmsUtils.convertJmsAccessException(jmsEx); StringWriter sw = new StringWriter(); PrintWriter out = new PrintWriter(sw); springJmsEx.printStackTrace(out); String trace = sw.toString(); assertTrue("inner jms exception not found", trace.indexOf("host not found") > 0); }
LOG.error(errStr, e); JMSException jmsEx = new JMSException(errStr); jmsEx.setLinkedException(e1); throw jmsEx; LOG.error(errStr, e); JMSException jmsEx = new JMSException(errStr); jmsEx.setLinkedException(e1); throw jmsEx;
LOG.error(errStr, e); JMSException jmsEx = new JMSException(errStr); jmsEx.setLinkedException(e1); throw jmsEx; LOG.error(errStr, e); JMSException jmsEx = new JMSException(errStr); jmsEx.setLinkedException(e1); throw jmsEx;
jmsEx.setLinkedException(e); throw jmsEx; } catch (IOException e) { JMSException jmsEx = new MessageFormatException(e.getMessage()); jmsEx.setLinkedException(e); throw jmsEx;
@Override public void writeUTF(final String value) throws JMSException { checkWrite(); try { bytesWriteUTF(message.getBodyBuffer(), value); } catch (Exception e) { JMSException je = new JMSException("Failed to write UTF"); je.setLinkedException(e); je.initCause(e); throw je; } }
jmsEx.setLinkedException(e); throw jmsEx; } catch (IOException e) { JMSException jmsEx = new MessageFormatException(e.getMessage()); jmsEx.setLinkedException(e); throw jmsEx;
jmsException.setLinkedException(e); throw jmsException;
@Override public String readUTF() throws JMSException { checkRead(); try { return bytesReadUTF(message.getBodyBuffer()); } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } catch (Exception e) { JMSException je = new JMSException("Failed to get UTF"); je.setLinkedException(e); je.initCause(e); throw je; } }
@Override public void setClientID(final String clientID) throws JMSException { checkClosed(); if (this.clientID != null) { throw new IllegalStateException("Client id has already been set"); } if (!justCreated) { throw new IllegalStateException("setClientID can only be called directly after the connection is created"); } validateClientID(initialSession, clientID); this.clientID = clientID; try { this.addSessionMetaData(initialSession); } catch (ActiveMQException e) { JMSException ex = new JMSException("Internal error setting metadata jms-client-id"); ex.setLinkedException(e); ex.initCause(e); throw ex; } justCreated = false; }
protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info) throws JMSException { if (info.isDurable()) { throw new JMSException("A durable subscription cannot be created for a temporary topic."); } try { TopicSubscription answer = new TopicSubscription(broker, context, info, usageManager); // lets configure the subscription depending on the destination ActiveMQDestination destination = info.getDestination(); if (destination != null && broker.getDestinationPolicy() != null) { PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination); if (entry != null) { entry.configure(broker, usageManager, answer); } } answer.init(); return answer; } catch (Exception e) { LOG.error("Failed to create TopicSubscription ", e); JMSException jmsEx = new JMSException("Couldn't create TopicSubscription"); jmsEx.setLinkedException(e); throw jmsEx; } }
@Override public void add(ConnectionContext context, Destination destination) throws Exception { if (!destinations.contains(destination)) { super.add(context, destination); } // do it just once per destination if (durableDestinations.containsKey(destination.getActiveMQDestination())) { return; } durableDestinations.put(destination.getActiveMQDestination(), destination); if (active.get() || keepDurableSubsActive) { Topic topic = (Topic) destination; topic.activate(context, this); getSubscriptionStatistics().getEnqueues().add(pending.size()); } else if (destination.getMessageStore() != null) { TopicMessageStore store = (TopicMessageStore) destination.getMessageStore(); try { getSubscriptionStatistics().getEnqueues().add(store.getMessageCount(subscriptionKey.getClientId(), subscriptionKey.getSubscriptionName())); } catch (IOException e) { JMSException jmsEx = new JMSException("Failed to retrieve enqueueCount from store " + e); jmsEx.setLinkedException(e); throw jmsEx; } } dispatchPending(); }
LOG.error("Failed to create TopicSubscription ", e); JMSException jmsEx = new JMSException("Couldn't create TopicSubscription"); jmsEx.setLinkedException(e); throw jmsEx;