Example usage for javax.jms Message getJMSMessageID

List of usage examples for javax.jms Message getJMSMessageID

Introduction

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

Prototype


String getJMSMessageID() throws JMSException;

Source Link

Document

Gets the message ID.

Usage

From source file:com.espertech.esperio.regression.adapter.SupportJMSReceiver.java

public static void print(Message msg) throws JMSException {
    log.info(".print received message: " + msg.getJMSMessageID());
    if (msg instanceof ObjectMessage) {
        ObjectMessage objMsg = (ObjectMessage) msg;
        log.info(".print object: " + objMsg.getObject().toString());
    } else {/*from ww w  .  j  av  a 2  s .c o  m*/
        MapMessage mapMsg = (MapMessage) msg;
        HashMap map = new HashMap();
        Enumeration en = mapMsg.getMapNames();
        while (en.hasMoreElements()) {
            String property = (String) en.nextElement();
            Object mapObject = mapMsg.getObject(property);
            map.put(property, mapObject);
        }
        log.info(".print map: " + map);
    }
}

From source file:com.egt.core.aplicacion.Bitacora.java

public static void traceMessage(Class clase, String metodo, Message message) throws JMSException {
    logTrace(Utils.getTraceMessageFormat(getCallingMethodStackTraceElementTrack(clase, metodo, 4),
            new Object[] { message.getJMSType(), message.getJMSMessageID(), message.getJMSCorrelationID(),
                    message.getJMSRedelivered() }));
}

From source file:com.kinglcc.spring.jms.filter.SharedTopicFilter.java

@Override
public boolean doFilter(Message jmsMessage, Session session) {
    try {/*www . java2s.c o m*/
        String messageId = jmsMessage.getJMSMessageID();
        return putIfAbsent(messageId, VALUE_STORE_IN_REDIS, MSGID_EXPIREDTIME, TimeUnit.MINUTES);
    } catch (JMSException e) {
        LOGGER.error("Get JMS message id error", e);
    }
    return false;
}

From source file:fr.xebia.sample.springframework.jms.SpringFrameworkJmsSenderSample.java

/**
 * Send a JMS Message with the given <code>message</code> and retrieves the generated
 * JMSMessageID.//w ww.  jav  a 2  s. c  o m
 */
public void simpleSend(Object message) throws Exception {

    ReferenceHolderMessagePostProcessor messagePostProcessor = new ReferenceHolderMessagePostProcessor();
    this.jmsTemplate.convertAndSend(message, messagePostProcessor);

    Message sentMessage = messagePostProcessor.getSentMessage();
    System.out.println("Generated JMSMessageID" + sentMessage.getJMSMessageID());
}

From source file:org.test.app.web.framework.backend.messaging.services.integration.impl.live.OtherAsyncRepositoryImpl.java

@Override
public void processMessage(final Message message) throws Exception {
    SampleDTO dto = (SampleDTO) getMessageConverter().fromMessage(message);

    String messageId = message.getJMSMessageID();
    dto.setMessageId(messageId);//from www  .  j  av a  2  s . c om
    this.processMessage(dto);
}

From source file:com.jmstoolkit.pipeline.plugin.XMLTransform.java

/**
 * Implementation of JMS <code>MessageListener</code> interface. Performs
 * the work when a message is received./*from   w w  w.  ja  va2s .  co m*/
 *
 * @param message The JMS Message received.
 */
@Override
public final void onMessage(final Message message) {
    String messageId = "xxx";
    try {
        messageId = message.getJMSMessageID();
    } catch (JMSException ex) {
        LOGGER.log(Level.SEVERE, "Failed to get message id", ex);
    }
    try {
        if (message instanceof TextMessage) {
            final String body = trim(((TextMessage) message).getText());
            try {
                System.out.println("############################################");
                System.out.println("Transform input message received by " + getName() + ":");
                System.out.println(body.subSequence(0, 78));
                System.out.println("############################################");
                LOGGER.log(Level.INFO, "{0} Transform performed by service: {1}",
                        new Object[] { messageId, getName() });
                getJmsTemplate().convertAndSend(getXslt().transform(body));
                this.setOperationCount(this.getOperationCount() + 1);
            } catch (XSLTransformerException ex) {
                LOGGER.log(Level.SEVERE, messageId + " XSL Transform failed: ", ex);
            }
        }
    } catch (JMSException ex) {
        LOGGER.log(Level.SEVERE, messageId + " Failed to get message text: ", ex);
    }
}

From source file:com.mirth.connect.connectors.jms.DefaultRedeliveryHandler.java

/**
 * process the redelivered message. If the Jms receiver should process the
 * message, it should be returned. Otherwise the connector should throw a
 * <code>MessageRedeliveredException</code> to indicate that the message
 * should be handled by the connector Exception Handler.
 * /*from  w w w.  j a  v  a2 s.  c o  m*/
 * @param message
 */
public void handleRedelivery(Message message) throws JMSException, MessagingException {
    if (connector.getMaxRedelivery() <= 0)
        return;

    String id = message.getJMSMessageID();
    Integer i = (Integer) messages.remove(id);
    if (i == null) {
        if (logger.isDebugEnabled()) {
            logger.debug("Message with id: " + id + " has been redelivered for the fist time");
        }
        messages.put(id, new Integer(1));
        return;
    } else if (i.intValue() == connector.getMaxRedelivery()) {
        if (logger.isDebugEnabled()) {
            logger.debug("Message with id: " + id + " has been redelivered " + (i.intValue() + 1)
                    + " times, which exceeds the maxRedelivery setting on the connector");
        }
        JmsMessageAdapter adapter = (JmsMessageAdapter) connector.getMessageAdapter(message);
        throw new MessageRedeliveredException(adapter);

    } else {
        messages.put(id, new Integer(i.intValue() + 1));
        if (logger.isDebugEnabled()) {
            logger.debug("Message with id: " + id + " has been redelivered " + i.intValue() + " times");
        }
    }
}

From source file:org.fcrepo.indexer.IndexerGroupTest.java

/**
 * Creates a mock message an updates the mock HTTPClient to respond to
 * the expected request for that object.
 *///from  w  w  w  .j  a  va  2 s  .  c om
private Message createMockMessage(boolean jmsExceptionOnGetMessage, String eventType, String identifier,
        boolean indexable, String indexerName, boolean property) throws Exception {
    Message m = mock(Message.class);
    if (jmsExceptionOnGetMessage) {
        JMSException e = mock(JMSException.class);
        when(m.getJMSMessageID()).thenThrow(e);
    } else {
        when(m.getJMSMessageID()).thenReturn("mocked-message-id");
    }
    if (eventType != null) {
        when(m.getStringProperty(IndexerGroup.EVENT_TYPE_HEADER_NAME)).thenReturn(eventType);
    }
    if (identifier != null) {
        when(m.getStringProperty(IndexerGroup.IDENTIFIER_HEADER_NAME)).thenReturn(identifier);
        mockContent(property ? parentId(identifier) : identifier, indexable, indexerName);
    }
    return m;
}

From source file:com.kinglcc.spring.jms.core.listener.MethodJmsFilterListenerAdapter.java

@Override
public void onMessage(javax.jms.Message jmsMessage, Session session) throws JMSException {
    for (MessageFilter filter : filters) {
        if (!filter.doFilter(jmsMessage, session)) {
            LOGGER.debug("Reject the message {} because it has already resolved!",
                    jmsMessage.getJMSMessageID());
            return;
        }//from  w ww  .j  av a 2 s. c  o m
    }
    super.onMessage(jmsMessage, session);
}

From source file:com.jmstoolkit.pipeline.plugin.XMLValueTransform.java

/**
 * Implementation of JMS <code>MessageListener</code> interface. Performs
 * the work when a message is received./*from ww  w.ja  v a  2s .c o  m*/
 *
 * @param message The JMS Message received.
 */
@Override
public final void onMessage(final Message message) {
    String messageId = "";
    try {
        messageId = message.getJMSMessageID();
    } catch (JMSException ex) {
        LOGGER.log(Level.SEVERE, "Failed to get message id", ex);
    }
    if (message instanceof TextMessage) {
        try {
            final String body = ((TextMessage) message).getText();

            System.out.println("############################################");
            System.out.println("Transform input message received by " + getName() + ":");
            System.out.println(body.substring(0, 78));
            System.out.println("############################################");

            try {
                // do NOT validate vs. DTD
                final SAXReader saxReader = new SAXReader();
                Document doc = saxReader.read(new StringReader(body));
                int count = 0;
                for (XMLValueTransformer xvt : this.getXforms()) {
                    try {
                        doc = xvt.transform(doc);
                        count++;
                    } catch (DataAccessException ex) {
                        LOGGER.log(Level.WARNING, messageId + " JDBC failed: " + xvt.toString(), ex);
                    }
                }
                LOGGER.log(Level.INFO, "{0} {1} of {2} XMLValueTransformers succeeded",
                        new Object[] { messageId, count, getXforms().size() });
                LOGGER.log(Level.INFO, "{0} Transform performed by service: {1}",
                        new Object[] { messageId, getName() });

                getJmsTemplate().convertAndSend(doc.asXML());

                this.operationCount++;
            } catch (DocumentException ex) {
                LOGGER.log(Level.SEVERE, messageId + " Unable to parse XML message: " + body + ". ", ex);
            }
        } catch (JMSException ex) {
            LOGGER.log(Level.SEVERE, messageId + " Failed to get message text: ", ex);
        }
    } else {
        LOGGER.log(Level.WARNING, "{0} Message is not a TextMessage. TextMessages only please.",
                new Object[] { messageId });
    }
}