List of usage examples for javax.jms Message getJMSMessageID
String getJMSMessageID() throws JMSException;
From source file:me.norman.maurer.james.queue.HornetQMailQueue.java
@Override protected void populateMailMimeMessage(Message message, Mail mail) throws MessagingException, JMSException { BytesMessage b = (BytesMessage) message; // as HornetQ can read from the stream via a BytesMessage just do it mail.setMessage(new MimeMessageCopyOnWriteProxy(new MimeMessageWrapper(new MimeMessageInputStreamSource( message.getJMSMessageID().replaceAll(":", "_"), new BytesMessageInputStream(b))))); }
From source file:com.jmstoolkit.logging.JTKLogListenerImpl.java
/** * * @param arg0 the JMS Message//from ww w. j a v a 2 s . c o m */ @Override public final void onMessage(final Message arg0) { try { if (arg0 instanceof TextMessage) { System.out.printf(Locale.getDefault(), "Logger service got the message:\n %s \n", ((TextMessage) arg0).getText()); } else { System.out.printf(Locale.getDefault(), "Logger service got the message. JMS ID: %s\n", arg0.getJMSMessageID()); } } catch (JMSException e) { System.err.printf(Locale.getDefault(), "JMS Failure: \n %s\n", e); } }
From source file:org.fcrepo.integration.jms.observer.HeadersJMSIT.java
@Override public void onMessage(final Message message) { try {// w w w .j a v a 2 s.c om LOGGER.debug( "Received JMS message: {} with path: {}, timestamp: {}, event type: {}, properties: {}," + " and baseURL: {}", message.getJMSMessageID(), getPath(message), getTimestamp(message), getEventTypes(message), getProperties(message), getBaseURL(message)); } catch (final JMSException e) { propagate(e); } messages.add(message); }
From source file:fr.xebia.sample.springframework.jms.requestreply.RequestReplyClientInvoker.java
/** * Request/Reply SpringFramework sample. * // w w w.j av a 2 s . co m * @param request * sent to the remote service * @return reply returned by the remote service * @throws JMSException */ public String requestReply(String request) throws JMSException { Connection connection = connectionFactory.createConnection(); try { connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); try { MessageProducer messageProducer = session.createProducer(this.requestDestination); try { Message requestMessage = session.createTextMessage(request); requestMessage.setJMSReplyTo(this.replyToDestination); // requestMessage.setJMSCorrelationID(String.valueOf(random.nextLong())); messageProducer.send(requestMessage); String messageSelector = "JMSCorrelationID LIKE '" + requestMessage.getJMSMessageID() + "'"; MessageConsumer messageConsumer = session.createConsumer(this.replyToDestination, messageSelector); TextMessage replyMessage = (TextMessage) messageConsumer.receive(timeoutInMillis); Assert.notNull(replyMessage, "Timeout waiting for jms response"); logger.debug( "requestReply " + "\r\nrequest : " + requestMessage + "\r\nreply : " + replyMessage); String result = replyMessage.getText(); logger.debug("requestReply('" + request + "'): '" + result + "'"); return result; } finally { JmsUtils.closeMessageProducer(messageProducer); } } finally { JmsUtils.closeSession(session); } } finally { JmsUtils.closeConnection(connection); } }
From source file:hermes.store.schema.DefaultJDBCAdapter.java
public void remove(Connection connection, String storeId, Message message) throws SQLException, JMSException { final QueryRunner runner = new QueryRunner(); if (runner.update(connection, "delete from stores where storeid=? and messageid=?", new Object[] { storeId, message.getJMSMessageID() }) > 0) { runner.update(connection, "delete from messages where messageid=?", new Object[] { message.getJMSMessageID() }); } else {// ww w.ja v a 2 s .c o m throw new SQLException("No message id=" + message.getJMSMessageID() + " exists in store=" + storeId); } }
From source file:com.datatorrent.lib.io.jms.AbstractJMSInputOperator.java
/** * This method is called when a message is added to {@link #holdingBuffer} and can be overwritten by subclasses * if required. This is called by the JMS thread not Operator thread. * * @param message/*from w w w .j a va2 s.c o m*/ * @return message is accepted. * @throws javax.jms.JMSException */ protected boolean messageConsumed(Message message) throws JMSException { if (message.getJMSRedelivered() && pendingAck.contains(message.getJMSMessageID())) { counters.getCounter(CounterKeys.REDELIVERED).increment(); LOG.warn("IGNORING: Redelivered Message {}", message.getJMSMessageID()); return false; } pendingAck.add(message.getJMSMessageID()); MutableLong receivedCt = counters.getCounter(CounterKeys.RECEIVED); receivedCt.increment(); LOG.debug("message id: {} buffer size: {} received: {}", message.getJMSMessageID(), holdingBuffer.size(), receivedCt.longValue()); return true; }
From source file:com.adaptris.core.jms.activemq.BlobMessageTranslator.java
/** * <p>/*www . j a v a2s . c o m*/ * Translates a <code>BlobMessage</code> into an <code>AdaptrisMessage</code> * . * </p> * * @param msg the <code>BlobMessage</code> to translate * @return an <code>AdaptrisMessage</code> * @throws JMSException on exception */ @Override public AdaptrisMessage translate(Message msg) throws JMSException { OutputStream out = null; InputStream in = null; AdaptrisMessage result = currentMessageFactory().newMessage(); try { if (msg instanceof BlobMessage) { in = ((BlobMessage) msg).getInputStream(); if (in == null) { log.warn("BlobMessage [{}] has no content", msg.getJMSMessageID()); } else { out = result.getOutputStream(); IOUtils.copy(in, out); out.flush(); } } else { result = fallback.translate(msg); } } catch (IOException e) { JmsUtils.rethrowJMSException("Failed to translate BlobMessage", e); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } return helper.moveMetadata(msg, result); }
From source file:com.datatorrent.lib.io.jms.AbstractJMSInputOperator.java
/** * Process jms message.//from ww w . j av a 2 s . c o m * * @param message */ protected void processMessage(Message message) { try { T payload = convert(message); if (payload != null) { currentWindowRecoveryState.put(message.getJMSMessageID(), payload); emit(payload); } } catch (JMSException e) { throw new RuntimeException("processing msg", e); } }
From source file:hermes.store.schema.DefaultJDBCAdapter.java
@Override public void update(Connection connection, String id, Message message) throws SQLException, JMSException { final String messageAsXMLString = xmlHelper.toXML(message); final InputStream messageAsXML = new StringInputStream(messageAsXMLString); final PreparedStatement pstmt = connection .prepareStatement("update messages set message = ? where messageid = ?"); pstmt.setString(1, message.getJMSMessageID()); pstmt.setAsciiStream(2, messageAsXML, messageAsXMLString.length()); pstmt.execute();// w w w .java 2s. c o m pstmt.close(); }
From source file:com.jmstoolkit.beans.MessageTableModel.java
/** * * @param message/*from w w w .j av a 2 s. c o m*/ */ @Override public void onMessage(Message message) { LOGGER.log(Level.FINE, "Message Received"); messagesReceived++; try { MessageTableRecord qRecord = new MessageTableRecord(); qRecord.setJMSCorrelationID(message.getJMSCorrelationID()); qRecord.setJMSDeliveryMode(message.getJMSDeliveryMode()); qRecord.setJMSExpiration(message.getJMSExpiration()); qRecord.setJMSMessageID(message.getJMSMessageID()); qRecord.setJMSTimestamp(message.getJMSTimestamp()); qRecord.setJMSType(message.getJMSType()); qRecord.setJMSDestination(message.getJMSDestination()); qRecord.setJMSCorrelationIDAsBytes(message.getJMSCorrelationIDAsBytes()); qRecord.setJMSPriority(message.getJMSPriority()); qRecord.setJMSType(message.getJMSType()); qRecord.setJMSReplyTo(message.getJMSReplyTo()); qRecord.setJMSRedelivered(message.getJMSRedelivered()); Enumeration pEnumerator = message.getPropertyNames(); Properties props = new Properties(); while (pEnumerator.hasMoreElements()) { String pElement = (String) pEnumerator.nextElement(); props.put(pElement, message.getStringProperty(pElement)); } qRecord.setProperties(props); if (message instanceof TextMessage) { qRecord.setText(((TextMessage) message).getText()); } if (message instanceof ObjectMessage) { qRecord.setObject(((ObjectMessage) message).getObject()); } List newData = data; newData.add(qRecord); this.setData(newData); } catch (JMSException e) { LOGGER.log(Level.WARNING, "JMS problem", e); } }