Tabnine Logo
SimpleMessageConverter.fromMessage
Code IndexAdd Tabnine to your IDE (free)

How to use
fromMessage
method
in
org.springframework.jms.support.converter.SimpleMessageConverter

Best Java code snippets using org.springframework.jms.support.converter.SimpleMessageConverter.fromMessage (Showing top 10 results out of 315)

origin: spring-projects/spring-framework

@Test
public void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
  Message message = mock(Message.class);
  SimpleMessageConverter converter = new SimpleMessageConverter();
  Object msg = converter.fromMessage(message);
  assertSame(message, msg);
}
origin: spring-projects/spring-framework

@Test
public void testStringConversion() throws JMSException {
  Session session = mock(Session.class);
  TextMessage message = mock(TextMessage.class);
  String content = "test";
  given(session.createTextMessage(content)).willReturn(message);
  given(message.getText()).willReturn(content);
  SimpleMessageConverter converter = new SimpleMessageConverter();
  Message msg = converter.toMessage(content, session);
  assertEquals(content, converter.fromMessage(msg));
}
origin: spring-projects/spring-framework

@Test
public void testSerializableConversion() throws JMSException {
  Session session = mock(Session.class);
  ObjectMessage message = mock(ObjectMessage.class);
  Integer content = new Integer(5);
  given(session.createObjectMessage(content)).willReturn(message);
  given(message.getObject()).willReturn(content);
  SimpleMessageConverter converter = new SimpleMessageConverter();
  Message msg = converter.toMessage(content, session);
  assertEquals(content, converter.fromMessage(msg));
}
origin: spring-projects/spring-framework

@Test
public void testMapConversion() throws JMSException {
  Session session = mock(Session.class);
  MapMessage message = mock(MapMessage.class);
  Map<String, String> content = new HashMap<>(2);
  content.put("key1", "value1");
  content.put("key2", "value2");
  given(session.createMapMessage()).willReturn(message);
  given(message.getMapNames()).willReturn(Collections.enumeration(content.keySet()));
  given(message.getObject("key1")).willReturn("value1");
  given(message.getObject("key2")).willReturn("value2");
  SimpleMessageConverter converter = new SimpleMessageConverter();
  Message msg = converter.toMessage(content, session);
  assertEquals(content, converter.fromMessage(msg));
  verify(message).setObject("key1", "value1");
  verify(message).setObject("key2", "value2");
}
origin: spring-projects/spring-framework

@Test
public void testByteArrayConversion() throws JMSException {
  Session session = mock(Session.class);
  BytesMessage message = mock(BytesMessage.class);
  byte[] content = "test".getBytes();
  final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content);
  given(session.createBytesMessage()).willReturn(message);
  given(message.getBodyLength()).willReturn((long) content.length);
  given(message.readBytes(any(byte[].class))).willAnswer(new Answer<Integer>() {
    @Override
    public Integer answer(InvocationOnMock invocation) throws Throwable {
      return byteArrayInputStream.read((byte[]) invocation.getArguments()[0]);
    }
  });
  SimpleMessageConverter converter = new SimpleMessageConverter();
  Message msg = converter.toMessage(content, session);
  assertEquals(content.length, ((byte[]) converter.fromMessage(msg)).length);
  verify(message).writeBytes(content);
}
origin: spring-projects/spring-integration

  private Object extractPayload(Message jmsMessage) {
    try {
      return converter.fromMessage(jmsMessage);
    }
    catch (Exception e) {
      e.printStackTrace();
      fail();
    }
    return null;
  }
}
origin: spring-projects/spring-integration

  private Object extractPayload(Message jmsMessage) {
    try {
      return converter.fromMessage(jmsMessage);
    }
    catch (Exception e) {
      e.printStackTrace();
      fail();
    }
    return null;
  }
}
origin: org.opennms.features.nrtg/nrtg-nrtbroker-jms

@Override
public List<MeasurementSet> receiveMeasurementSets(String nrtCollectionTaskId) {
  List<MeasurementSet> result = new ArrayList<MeasurementSet>();
  m_jmsTemplate.setReceiveTimeout(125);
  Message message = m_jmsTemplate.receive(nrtCollectionTaskId);
  while (message != null) {
    MeasurementSet measurementSet;
    try {
      measurementSet = (MeasurementSet) simpleMessageConverter.fromMessage(message);

      result.add(measurementSet);
    } catch (JMSException ex) {
      logger.error("Error receiving messages", ex);
      return result;
    } catch (MessageConversionException ex) {
      logger.error("Error converting messages", ex);
      
      return result;
    }
    
    message = m_jmsTemplate.receive(nrtCollectionTaskId);
  }
  return result;
}
origin: OpenNMS/opennms

@Override
public List<MeasurementSet> receiveMeasurementSets(String nrtCollectionTaskId) {
  List<MeasurementSet> result = new ArrayList<MeasurementSet>();
  m_jmsTemplate.setReceiveTimeout(125);
  Message message = m_jmsTemplate.receive(nrtCollectionTaskId);
  while (message != null) {
    MeasurementSet measurementSet;
    try {
      measurementSet = (MeasurementSet) simpleMessageConverter.fromMessage(message);

      result.add(measurementSet);
    } catch (JMSException ex) {
      logger.error("Error receiving messages", ex);
      return result;
    } catch (MessageConversionException ex) {
      logger.error("Error converting messages", ex);
      
      return result;
    }
    
    message = m_jmsTemplate.receive(nrtCollectionTaskId);
  }
  return result;
}
origin: OpenNMS/opennms

CollectionJob collectionJob = (CollectionJob) simpleMessageConverter.fromMessage(message);
org.springframework.jms.support.converterSimpleMessageConverterfromMessage

Javadoc

This implementation converts a TextMessage back to a String, a ByteMessage back to a byte array, a MapMessage back to a Map, and an ObjectMessage back to a Serializable object. Returns the plain Message object in case of an unknown message type.

Popular methods of SimpleMessageConverter

  • <init>
  • createMessageForByteArray
    Create a JMS BytesMessage for the given byte array.
  • createMessageForMap
    Create a JMS MapMessage for the given Map.
  • createMessageForSerializable
    Create a JMS ObjectMessage for the given Serializable object.
  • createMessageForString
    Create a JMS TextMessage for the given String.
  • extractByteArrayFromMessage
    Extract a byte array from the given BytesMessage.
  • extractMapFromMessage
    Extract a Map from the given MapMessage.
  • extractSerializableFromMessage
    Extract a Serializable object from the given ObjectMessage.
  • extractStringFromMessage
    Extract a String from the given TextMessage.
  • toMessage
    This implementation creates a TextMessage for a String, a BytesMessage for a byte array, a MapMessag

Popular in Java

  • Making http post requests using okhttp
  • startActivity (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onRequestPermissionsResult (Fragment)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now