Java Code Examples for javax.jms.Message#getClass()
The following examples show how to use
javax.jms.Message#getClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmsSession.java From qpid-jms with Apache License 2.0 | 8 votes |
private void setForeignMessageDeliveryTime(Message foreignMessage, long deliveryTime) throws JMSException { // Verify if the setJMSDeliveryTime method exists, i.e the foreign provider isn't only JMS 1.1. Method deliveryTimeMethod = null; try { Class<?> clazz = foreignMessage.getClass(); Method method = clazz.getMethod("setJMSDeliveryTime", new Class[] { long.class }); if (!Modifier.isAbstract(method.getModifiers())) { deliveryTimeMethod = method; } } catch (NoSuchMethodException e) { // Assume its a JMS 1.1 Message, we will no-op. } if (deliveryTimeMethod != null) { // Method exists, isn't abstract, so use it. foreignMessage.setJMSDeliveryTime(deliveryTime); } }
Example 2
Source File: ProcessMessageConverter.java From c2mon with GNU Lesser General Public License v3.0 | 6 votes |
/** * Convert from a JMS Message to a Java object. * * @param message the message to convert for discovering who sends it * @return the converted Java object * @throws javax.jms.JMSException if thrown by JMS API methods */ @Override public Object fromMessage(final Message message) throws JMSException { if (!(message instanceof TextMessage)) { throw new MessageFormatException("Expected TextMessage as response but received " + message.getClass()); } else { try { // LOGGER.debug("fromMessage() - Message received: " + ((TextMessage) message).getText()); LOGGER.debug("fromMessage() - Message properly received"); return this.xmlConverter.fromXml(((TextMessage) message).getText()); } catch (Exception ex) { LOGGER.error("fromMessage() - Error caught in conversion of JMS message to Process Object"); LOGGER.error("Message was: " + ((TextMessage) message).getText()); throw new JMSException(ex.getMessage()); } } }
Example 3
Source File: JmsMessageTransformation.java From qpid-jms with Apache License 2.0 | 6 votes |
private static long getForeignMessageDeliveryTime(Message foreignMessage) throws JMSException { // Verify if the getJMSDeliveryTime method exists, i.e the foreign provider isn't only JMS 1.1. Method deliveryTimeMethod = null; try { Class<?> clazz = foreignMessage.getClass(); Method method = clazz.getMethod("getJMSDeliveryTime", (Class[]) null); if (!Modifier.isAbstract(method.getModifiers())) { deliveryTimeMethod = method; } } catch (NoSuchMethodException e) { // Assume its a JMS 1.1 Message, we will return 0. } if (deliveryTimeMethod != null) { // Method exists, isn't abstract, so use it. return foreignMessage.getJMSDeliveryTime(); } return 0; }
Example 4
Source File: MarshallingMessageConverter.java From spring-analysis-note with MIT License | 3 votes |
/** * Template method that allows for custom message unmarshalling. * Invoked when {@link #fromMessage(Message)} is invoked with a message * that is not a {@link TextMessage} or {@link BytesMessage}. * <p>The default implementation throws an {@link IllegalArgumentException}. * @param message the message * @param unmarshaller the unmarshaller to use * @return the unmarshalled object * @throws JMSException if thrown by JMS methods * @throws IOException in case of I/O errors * @throws XmlMappingException in case of OXM mapping errors */ protected Object unmarshalFromMessage(Message message, Unmarshaller unmarshaller) throws JMSException, IOException, XmlMappingException { throw new IllegalArgumentException("Unsupported message type [" + message.getClass() + "]. MarshallingMessageConverter by default only supports TextMessages and BytesMessages."); }
Example 5
Source File: MappingJackson2MessageConverter.java From spring-analysis-note with MIT License | 3 votes |
/** * Template method that allows for custom message mapping. * Invoked when {@link #setTargetType} is not {@link MessageType#TEXT} or * {@link MessageType#BYTES}. * <p>The default implementation throws an {@link IllegalArgumentException}. * @param message the input message * @param targetJavaType the target type * @return the message converted to an object * @throws JMSException if thrown by JMS * @throws IOException in case of I/O errors */ protected Object convertFromMessage(Message message, JavaType targetJavaType) throws JMSException, IOException { throw new IllegalArgumentException("Unsupported message type [" + message.getClass() + "]. MappingJacksonMessageConverter by default only supports TextMessages and BytesMessages."); }
Example 6
Source File: MarshallingMessageConverter.java From java-technology-stack with MIT License | 3 votes |
/** * Template method that allows for custom message unmarshalling. * Invoked when {@link #fromMessage(Message)} is invoked with a message * that is not a {@link TextMessage} or {@link BytesMessage}. * <p>The default implementation throws an {@link IllegalArgumentException}. * @param message the message * @param unmarshaller the unmarshaller to use * @return the unmarshalled object * @throws JMSException if thrown by JMS methods * @throws IOException in case of I/O errors * @throws XmlMappingException in case of OXM mapping errors */ protected Object unmarshalFromMessage(Message message, Unmarshaller unmarshaller) throws JMSException, IOException, XmlMappingException { throw new IllegalArgumentException("Unsupported message type [" + message.getClass() + "]. MarshallingMessageConverter by default only supports TextMessages and BytesMessages."); }
Example 7
Source File: MappingJackson2MessageConverter.java From java-technology-stack with MIT License | 3 votes |
/** * Template method that allows for custom message mapping. * Invoked when {@link #setTargetType} is not {@link MessageType#TEXT} or * {@link MessageType#BYTES}. * <p>The default implementation throws an {@link IllegalArgumentException}. * @param message the input message * @param targetJavaType the target type * @return the message converted to an object * @throws JMSException if thrown by JMS * @throws IOException in case of I/O errors */ protected Object convertFromMessage(Message message, JavaType targetJavaType) throws JMSException, IOException { throw new IllegalArgumentException("Unsupported message type [" + message.getClass() + "]. MappingJacksonMessageConverter by default only supports TextMessages and BytesMessages."); }
Example 8
Source File: MarshallingMessageConverter.java From spring4-understanding with Apache License 2.0 | 3 votes |
/** * Template method that allows for custom message unmarshalling. * Invoked when {@link #fromMessage(Message)} is invoked with a message * that is not a {@link TextMessage} or {@link BytesMessage}. * <p>The default implementation throws an {@link IllegalArgumentException}. * @param message the message * @param unmarshaller the unmarshaller to use * @return the unmarshalled object * @throws JMSException if thrown by JMS methods * @throws IOException in case of I/O errors * @throws XmlMappingException in case of OXM mapping errors */ protected Object unmarshalFromMessage(Message message, Unmarshaller unmarshaller) throws JMSException, IOException, XmlMappingException { throw new IllegalArgumentException("Unsupported message type [" + message.getClass() + "]. MarshallingMessageConverter by default only supports TextMessages and BytesMessages."); }
Example 9
Source File: MappingJackson2MessageConverter.java From spring4-understanding with Apache License 2.0 | 3 votes |
/** * Template method that allows for custom message mapping. * Invoked when {@link #setTargetType} is not {@link MessageType#TEXT} or * {@link MessageType#BYTES}. * <p>The default implementation throws an {@link IllegalArgumentException}. * @param message the input message * @param targetJavaType the target type * @return the message converted to an object * @throws JMSException if thrown by JMS * @throws IOException in case of I/O errors */ protected Object convertFromMessage(Message message, JavaType targetJavaType) throws JMSException, IOException { throw new IllegalArgumentException("Unsupported message type [" + message.getClass() + "]. MappingJacksonMessageConverter by default only supports TextMessages and BytesMessages."); }